File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -504,6 +504,14 @@ correct key is provided set in `git_crypt_key`.
504504 describe</code></a>. Defaults to <code>--always --dirty --broken</code>.
505505 </td>
506506 </tr>
507+ <tr>
508+ <td><code>all_branches</code><br/><i>Optional</i></td>
509+ <td>
510+ If <code>true</code> the flag <code>--single-branch</code> will be
511+ excluded and all branches will be fetched from the repository. If
512+ <code>false</code> or not specified, only a single branch (either
513+ <code>source.branch</code> or the default branch) will be fetched. </td>
514+ </tr>
507515</table>
508516
509517# ### GPG signature verification
Original file line number Diff line number Diff line change @@ -62,6 +62,7 @@ short_ref_format=$(jq -r '(.params.short_ref_format // "%s")' <<< "$payload")
6262timestamp_format=$( jq -r ' (.params.timestamp_format // "iso8601")' <<< " $payload" )
6363describe_ref_options=$( jq -r ' (.params.describe_ref_options // "--always --dirty --broken")' <<< " $payload" )
6464search_remote_refs_flag=$( jq -r ' (.source.search_remote_refs // false)' <<< " $payload" )
65+ all_branches=$( jq -r ' (.params.all_branches // false)' <<< " $payload" )
6566
6667# If params not defined, get it from source
6768if [ -z " $fetch_tags " ] || [ " $fetch_tags " == " null" ] ; then
@@ -108,7 +109,12 @@ if [ "$disable_git_lfs" == "true" ]; then
108109 export GIT_LFS_SKIP_SMUDGE=1
109110fi
110111
111- git clone --progress --single-branch $depthflag $uri $branchflag $destination $tagflag $nocheckoutflag
112+ singlebranchflag=" --single-branch"
113+ if [ " ${all_branches,,} " == " true" ]; then
114+ singlebranchflag=" "
115+ fi
116+
117+ git clone --progress $singlebranchflag $depthflag $uri $branchflag $destination $tagflag $nocheckoutflag
112118
113119cd $destination
114120
Original file line number Diff line number Diff line change 99 "clean_tags" : " " ,
1010 "short_ref_format" : " " ,
1111 "timestamp_format" : " " ,
12- "describe_ref_options" : " "
12+ "describe_ref_options" : " " ,
13+ "all_branches" : " "
1314}
Original file line number Diff line number Diff line change @@ -102,6 +102,19 @@ it_can_get_from_url_at_override_branch() {
102102 test " $( git -C $dest rev-parse HEAD) " = $ref
103103}
104104
105+ it_can_get_from_url_with_all_branches () {
106+ local repo=$( init_repo)
107+ local ref=$( make_commit $repo )
108+ local dest=$TMPDIR /destination
109+
110+ get_uri_with_all_branches $repo " master" $dest | jq -e "
111+ .version == {ref: $( echo $ref | jq -R .) }
112+ "
113+
114+ git -C $dest show-ref --verify refs/remotes/origin/master
115+ git -C $dest show-ref --verify refs/remotes/origin/bogus
116+ }
117+
105118it_preserves_git_config_in_local_repository () {
106119 local repo=$( init_repo)
107120 local ref=$( make_commit $repo )
@@ -1130,6 +1143,7 @@ run it_can_get_from_url_at_ref
11301143run it_can_get_from_url_at_branch
11311144run it_can_get_from_url_only_single_branch
11321145run it_can_get_from_url_at_override_branch
1146+ run it_can_get_from_url_with_all_branches
11331147run it_preserves_git_config_in_local_repository
11341148run it_can_get_from_url_with_sparse_paths
11351149run it_omits_empty_branch_in_metadata
Original file line number Diff line number Diff line change @@ -1107,6 +1107,18 @@ get_uri_with_fetch_branches() {
11071107 }" | ${resource_dir} /in " $dest " | tee /dev/stderr
11081108}
11091109
1110+ get_uri_with_all_branches () {
1111+ jq -n " {
1112+ source: {
1113+ uri: $( echo $1 | jq -R .) ,
1114+ branch: $( echo $2 | jq -R .) ,
1115+ },
1116+ params: {
1117+ all_branches: \" true\"
1118+ }
1119+ }" | ${resource_dir} /in " $3 " | tee /dev/stderr
1120+ }
1121+
11101122put_uri () {
11111123 jq -n " {
11121124 source: {
You can’t perform that action at this time.
0 commit comments