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

searches all branches when tag filter is provided and branch isn't #225

Merged
merged 6 commits into from Dec 4, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 12 additions & 4 deletions assets/check
Expand Up @@ -45,10 +45,10 @@ if [ -d $destination ]; then
else
branchflag=""
if [ -n "$branch" ]; then
branchflag="--single-branch --branch $branch"
branchflag="--branch $branch"
fi

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

Expand All @@ -75,13 +75,21 @@ if [ "$skip_ci_disabled" != "true" ]; then
ci_skip="--grep \\[ci\\sskip\\] --grep \\[skip\\sci\\] --invert-grep"
fi

replace_escape_chars() {
sed -e 's/[]\/$*.^[]/\\&/g' <<< $1
}

lines_including_and_after() {
local escaped_string=$(replace_escape_chars $1)
sed -ne "/$escaped_string/,$ p"
}

if [ -n "$tag_filter" ]; then
{
if [ -n "$ref" ] && [ -n "$branch" ]; then
git tag --list "$tag_filter" --sort=creatordate --contains $ref
elif [ -n "$ref" ]; then
ref_for_search=$(sed 's#/#\\/#g' <<< $ref)
git tag --list "$tag_filter" --list --sort=creatordate | sed -ne "/$ref_for_search/,$ p"
git tag --list "$tag_filter" --list --sort=creatordate | lines_including_and_after $ref
else
git tag --list "$tag_filter" --sort=creatordate | tail -1
fi
Expand Down
13 changes: 9 additions & 4 deletions assets/in
Expand Up @@ -39,6 +39,7 @@ 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)
gpg_keyserver=$(jq -r '.source.gpg_keyserver // "hkp://ipv4.pool.sks-keyservers.net/"' < $payload)
disable_git_lfs=$(jq -r '(.params.disable_git_lfs // false)' < $payload)
clean_tags=$(jq -r '(.params.clean_tags // false)' < $payload)
Expand All @@ -62,12 +63,16 @@ if test "$depth" -gt 0 2> /dev/null; then
depthflag="--depth $depth"
fi

git clone $depthflag $uri $branchflag $destination
tagflag=""
if [ -d $tag_filter ]; then
tagflag="--tags"
fi

git clone $depthflag $uri $branchflag $destination $tagflag

cd $destination

git fetch origin refs/notes/*:refs/notes/*
goddenrich marked this conversation as resolved.
Show resolved Hide resolved
git fetch --tags

# A shallow clone may not contain the Git commit $ref:
# 1. The depth of the shallow clone is measured backwards from the latest
Expand Down Expand Up @@ -98,13 +103,13 @@ if [ "$depth" -gt 0 ]; then

if [ "$d" -gt $max_depth ]; then
echo "Reached depth threshold ${max_depth}, falling back to deep clone..."
git fetch --unshallow origin
git fetch --unshallow origin $tagflag

break
fi

echo "Deepening the shallow clone to depth ${d}..."
git fetch --depth $d origin
git fetch --depth $d origin $tagflag
done
fi

Expand Down