Skip to content

Commit abb0629

Browse files
authored
Merge pull request #425 from david-baylibre/fast-check
fast check skipping repo download
2 parents 2b63599 + 871fb4b commit abb0629

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

assets/check

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,32 @@ configure_git_global "${git_config_payload}"
3636

3737
destination=$TMPDIR/git-resource-repo-cache
3838

39+
# Optimization when last commit only is checked and skip ci is disabled
40+
# Get the commit id with git ls-remote instead of downloading the whole repo
41+
if [ "$skip_ci_disabled" = "true" ] && \
42+
[ "$version_depth" = "1" ] && \
43+
[ "$paths" = "." ] && \
44+
[ -z "$ignore_paths" ] && \
45+
[ -z "$tag_filter" ] && \
46+
[ -z "$tag_regex" ] && \
47+
jq -e 'length == 0' <<<"$filter_include" && \
48+
jq -e 'length == 0' <<<"$filter_exclude"
49+
then
50+
branchflag="HEAD"
51+
if [ -n "$branch" ]; then
52+
branchflag="$branch"
53+
fi
54+
commit=$(git ls-remote $uri $branchflag | awk 'NR<=1{print $1}')
55+
if [ -z "$commit" ]; then
56+
echo "No commit returned. Invalid branch?"
57+
exit 1
58+
fi
59+
if [ -z "$ref" ] || [ "$ref" = "$commit" ]; then
60+
echo $commit | jq -R '.' | jq -s "map({ref: .})" >&3
61+
exit 0
62+
fi
63+
fi
64+
3965
tagflag=""
4066
if [ -n "$tag_filter" ] || [ -n "$tag_regex" ] ; then
4167
tagflag="--tags"

0 commit comments

Comments
 (0)