Skip to content

Comments

feat: store json file listing all branches#468

Draft
gegoune wants to merge 4 commits intoconcourse:masterfrom
gegoune:all-branches-output
Draft

feat: store json file listing all branches#468
gegoune wants to merge 4 commits intoconcourse:masterfrom
gegoune:all-branches-output

Conversation

@gegoune
Copy link

@gegoune gegoune commented Feb 17, 2026

No description provided.

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Feb 17, 2026

CLA Not Signed

Copy link
Member

@taylorsilva taylorsilva left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, so not exactly sure what shape you're hoping this takes. This is what I'm seeing and thinking so far.

It looks like we can scope this change to just the in script (get step) of the resource. Looks like you're suggesting adding a new param called all_branches. You'll want to add that here: https://github.com/concourse/git-resource/blob/master/assets/in_schema.json

and then pull in the value of that here:

git-resource/assets/in

Lines 52 to 75 in 917f8c5

uri=$(jq -r '.source.uri // ""' <<< "$payload")
branch=$(jq -r '.source.branch // ""' <<< "$payload")
sparse_paths="$(jq -r '(.source.sparse_paths // ["."])[]' <<< "$payload")" # those "'s are important
git_config_payload=$(jq -r '.source.git_config // []' <<< "$payload")
ref=$(jq -r '.version.ref // "HEAD"' <<< "$payload")
override_branch=$(jq -r '.version.branch // ""' <<< "$payload")
depth=$(jq -r '(.params.depth // 0)' <<< "$payload")
fetch=$(jq -r '(.params.fetch // [])[]' <<< "$payload")
submodules=$(jq -r '(.params.submodules // "all")' <<< "$payload")
submodule_recursive=$(jq -r '(.params.submodule_recursive // true)' <<< "$payload")
submodule_remote=$(jq -r '(.params.submodule_remote // false)' <<< "$payload")
commit_verification_key_ids=$(jq -r '(.source.commit_verification_key_ids // [])[]' <<< "$payload")
commit_verification_keys=$(jq -r '(.source.commit_verification_keys // [])[]' <<< "$payload")
tag_filter=$(jq -r '.source.tag_filter // ""' <<< "$payload")
tag_regex=$(jq -r '.source.tag_regex // ""' <<< "$payload")
fetch_tags=$(jq -r '.params.fetch_tags' <<< "$payload")
gpg_keyserver=$(jq -r '.source.gpg_keyserver // "hkp://keyserver.ubuntu.com/"' <<< "$payload")
disable_git_lfs=$(jq -r '(.params.disable_git_lfs // false)' <<< "$payload")
clean_tags=$(jq -r '(.params.clean_tags // false)' <<< "$payload")
short_ref_format=$(jq -r '(.params.short_ref_format // "%s")' <<< "$payload")
timestamp_format=$(jq -r '(.params.timestamp_format // "iso8601")' <<< "$payload")
describe_ref_options=$(jq -r '(.params.describe_ref_options // "--always --dirty --broken")' <<< "$payload")
search_remote_refs_flag=$(jq -r '(.source.search_remote_refs // false)' <<< "$payload")
all_branches=$(jq -r '(.params.all_branches // false)' <<< "$payload")

all_branches=$(jq -r '(.params.all_branches // false)' <<< "$payload")

You'll also want to add all_branches to this table in the README:

git-resource/README.md

Lines 399 to 406 in 917f8c5

#### Parameters
<table>
<tr>
<th>Field Name</th>
<th>Description</th>
</tr>
<tr>

Off the top of my head I'm not sure what git command(s) you would need to run to get all branches. Looks like we store and fetch most of the metadata info at the end of the script:

git-resource/assets/in

Lines 266 to 299 in 917f8c5

# Store committer email in .git/committer. Can be used to send email to last committer on failed build
# Using https://github.com/mdomke/concourse-email-resource for example
git --no-pager log -1 --pretty=format:"%ae" > .git/committer
git --no-pager log -1 --pretty=format:"%an" > .git/committer_name
# Store git-resource returned version ref .git/ref. Useful to know concourse
# pulled ref in following tasks and resources.
echo "${return_ref}" > .git/ref
metadata=$(git_metadata)
echo "${metadata}" | jq '.' > .git/metadata.json
# Store short ref with templating. Useful to build Docker images with
# a custom tag
echo "${return_ref}" | cut -c1-7 | awk "{ printf \"${short_ref_format}\", \$1 }" > .git/short_ref
# Write individual metadata fields to separate files
# .git/commit - full SHA hash
echo "${metadata}" | jq -r '.[] | select(.name == "commit") | .value' > .git/commit
# .git/author - commit author name
echo "${metadata}" | jq -r '.[] | select(.name == "author") | .value' > .git/author
# .git/author_date - timestamp when the author originally created the commit
echo "${metadata}" | jq -r '.[] | select(.name == "author_date") | .value' > .git/author_date
# .git/tags - branch name(s) containing this commit (comma-separated if multiple)
echo "${metadata}" | jq -r '.[] | select(.name == "branch") | .value // ""' > .git/branch
# .git/tags - comma-separated list of tags
echo "${metadata}" | jq -r '.[] | select(.name == "tags") | .value // ""' > .git/tags
# .git/url - web URL to view commit (if applicable)
echo "${metadata}" | jq -r '.[] | select(.name == "url") | .value // ""' > .git/url
# .git/committer_date - timestamp when the commit was created in the repository
echo "${metadata}" | jq -r '.[] | select(.name == "committer_date") | .value // ""' > .git/committer_date

Hope that helps!

@gegoune gegoune changed the title feat: output list of all branches to metadata feat: store json file listing all branches Feb 19, 2026
@gegoune gegoune force-pushed the all-branches-output branch from 9db4b01 to acb7ab5 Compare February 19, 2026 20:18
@gegoune
Copy link
Author

gegoune commented Feb 19, 2026

It looks like we can scope this change to just the in script (get step) of the resource. Looks like you're suggesting adding a new param called all_branches. You'll want to add that here: master/assets/in_schema.json

I meant to add a list of all branches to that file, not the value of already existing all_branches parameter. 🤦 I have corrected it in latest commit.

Quick local test (git standalone git, no concourseci) it looks like git clone without --single-branch, so with all_branches parameter, fetches all remote branches:

$ git clone git@github.com:concourse/concourse.git
Cloning into 'concourse'...
remote: Enumerating objects: 216047, done.
remote: Counting objects: 100% (804/804), done.
remote: Compressing objects: 100% (417/417), done.
remote: Total 216047 (delta 453), reused 436 (delta 386), pack-reused 215243 (from 3)
Receiving objects: 100% (216047/216047), 150.54 MiB | 10.06 MiB/s, done.
Resolving deltas: 100% (157499/157499), done.

$ git for-each-ref --no-omit-empty refs/remotes/ --format='%(refname:lstrip=3)'
HEAD
add-defaults
alg-tracing
bug/6215-no-version-abort-rerun-build
centralize-api-routes
containerd-bump-7.4
containerd-default-namespace
containerd-timeouts
disable-microsoft-user
first-occ-query
fix-k8s-topgun-panic-6.7
get-var
get-var-2
goccy-yaml
improve-interp
issue/5418
issue/7697
issue/8215-bump-cloudfoundry-deps
issue/942
log-ip-address
masked-and-readonly-mounts
master
name-claim
origin/issue/6627-ldap-password
pure-go-zstd-fixed
refactor-metrics
release/5.2.x
release/5.5.x
release/5.7.x
release/5.8.x
release/6.1.x
release/6.2.x
release/6.3.x
release/6.4.x
release/6.5.x
release/6.6.x
release/6.7.x
release/6.8.x
release/7.0.x
release/7.1.x
release/7.10.x
release/7.11.x
release/7.12.x
release/7.13.x
release/7.14.x
release/7.2.x
release/7.3.x
release/7.4.x
release/7.5.x
release/7.6.x
release/7.7.x
release/7.8.x
release/7.9.x
release/8.0.x
remove-check-sessions
renovate/all
resource-check-timeout
resource-ui-polish
revert-containerd-1.6.0
shared-webhooks
topgun-fix
upstream-sync-dex
using-upstream-dex
watch-endpoints
wip-algorithm-v3
worker-overload/8317

then for-each-ref + jq produce

$ git for-each-ref --format='%(refname:lstrip=3)' refs/remotes/ | jq --raw-input --slurp --compact-output 'split("\n")[:-1]'
["HEAD","add-defaults","alg-tracing","bug/6215-no-version-abort-rerun-build","centralize-api-routes","containerd-bump-7.4","containerd-default-namespace","containerd-timeouts","disable-microsoft-user","first-occ-query","fix-k8s-topgun-panic-6.7","get-var","get-var-2","goccy-yaml","improve-interp","issue/5418","issue/7697","issue/8215-bump-cloudfoundry-deps","issue/942","log-ip-address","masked-and-readonly-mounts","master","name-claim","origin/issue/6627-ldap-password","pure-go-zstd-fixed","refactor-metrics","release/5.2.x","release/5.5.x","release/5.7.x","release/5.8.x","release/6.1.x","release/6.2.x","release/6.3.x","release/6.4.x","release/6.5.x","release/6.6.x","release/6.7.x","release/6.8.x","release/7.0.x","release/7.1.x","release/7.10.x","release/7.11.x","release/7.12.x","release/7.13.x","release/7.14.x","release/7.2.x","release/7.3.x","release/7.4.x","release/7.5.x","release/7.6.x","release/7.7.x","release/7.8.x","release/7.9.x","release/8.0.x","remove-check-sessions","renovate/all","resource-check-timeout","resource-ui-polish","revert-containerd-1.6.0","shared-webhooks","topgun-fix","upstream-sync-dex","using-upstream-dex","watch-endpoints","wip-algorithm-v3","worker-overload/8317"]

I have removed HEAD in another commit.

My idea is to use that output with across, instead of https://github.com/aoldershaw/git-branches-resource.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants