Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream-rcm7/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
o-orand committed Jul 1, 2020
2 parents 9cf043f + cf42265 commit 34095f4
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM concourse/git-resource
FROM concourse/git-resource:1.6.2

ENV LC_ALL C
RUN apk add --update coreutils
Expand Down
38 changes: 36 additions & 2 deletions assets/check
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,57 @@ uri=$(jq -r '.source.uri // ""' < $payload)
exclude_branches=$(jq -r '.source.exclude // ""' < $payload)
branch_filter=$(jq -r '.source.branches // [] | join(" ")' < $payload)
git_config_payload=$(jq -r '.source.git_config // []' < $payload)
paths="$(jq -r '(.source.paths // ["."])[]' < $payload)" # those "'s are important
ignore_paths="$(jq -r '":!" + (.source.ignore_paths // [])[]' < $payload)" # these ones too

previous_branches="$(jq -r '.version.branches // ""' < $payload)"

configure_git_global "${git_config_payload}"


# Download repo so we can do rev-list after

destination=$TMPDIR/git-resource-repo-cache
if [ -d $destination ]; then
cd $destination
git fetch -f
git reset --quiet --hard FETCH_HEAD
else
git clone $uri $destination
cd $destination
fi

e_point=!
current_heads=$(git ls-remote -h "$uri" $branch_filter | sed 's/refs\/heads\///' | awk '{print $2, $1}' | awk "\$1 $e_point~ \"^($exclude_branches)$\"" | sort -V)

if [ "$paths" = "." ] && [ -z "$ignore_paths" ]; then
paths_search=""
else
paths_search=$(echo "-- $paths $ignore_paths" | tr "\n\r" " ")
fi

last_commits_on_path=$(git rev-list --all --first-parent $paths_search | git rev-list --stdin --grep="\\[ci\\sskip\\]" --grep="\\[skip\\sci\\]" --invert-grep --first-parent --no-walk)
current_filtered_heads=$(
echo "$current_heads" |
while read head commit; do
echo "$last_commits_on_path" |
while read com; do
if [[ "$com" = "$commit" ]]; then
echo "$head $commit"
fi
done;
done
)

current_heads_map=$(
jq -n '
$heads | rtrimstr("\n") | split("\n") |
map(split(" ") | {key: .[0], value: .[1]}) |
from_entries
' --arg heads "$current_heads"
' --arg heads "$current_filtered_heads"
)

echo "$current_heads" |
echo "$current_filtered_heads" |
while read branch ref; do
if [ -z "$branch" ]; then
continue
Expand Down
3 changes: 2 additions & 1 deletion assets/in
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ jq \
}' < $payload |
${GIT_RESOURCE_IN:-/opt/git-resource/in} "$@" |
jq --slurpfile payload $payload \
'. + {version: ($payload | .[0].version)}'
'. + {version: ($payload | .[0].version)}' |
jq '.version.changed as $branch | {version: {changed: $branch, ($branch): .version[$branch]}, metadata: .metadata}'

cd "$@"
mkdir .git/git-branch-heads-resource
Expand Down

0 comments on commit 34095f4

Please sign in to comment.