Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support branch pattern #399

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions assets/check
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ configure_credentials "$payload"

uri=$(jq -r '.source.uri // ""' <<< "$payload")
branch=$(jq -r '.source.branch // ""' <<< "$payload")
branch_pattern=$(jq -r '.source.branch_pattern // ""' <<< "$payload")
paths="$(jq -r '(.source.paths // ["."])[]' <<< "$payload")" # those "'s are important
ignore_paths="$(jq -r '":!" + (.source.ignore_paths // [])[]' <<< "$payload")" # these ones too
tag_filter=$(jq -r '.source.tag_filter // ""' <<< "$payload")
Expand Down Expand Up @@ -53,10 +54,10 @@ if [ -d $destination ]; then
else
branchflag=""
if [ -n "$branch" ]; then
branchflag="--branch $branch"
branchflag="--single-branch --branch $branch"
fi

git clone --single-branch $uri $branchflag $destination $tagflag
git clone $uri $branchflag $destination $tagflag
cd $destination
fi

Expand Down Expand Up @@ -167,6 +168,12 @@ elif [ -n "$tag_regex" ]; then
get_commit $tag
fi
} | jq -s "map(.)" >&3
elif [ -n "$branch_pattern" ]; then
git fetch --all
git branch --all \
| grep "$branch_pattern" \
| xargs -n 1 git rev-parse \
| jq -R '.' | jq -s "map({ref: .})" >&3
else
{
set -f
Expand Down