Skip to content
This repository was archived by the owner on May 24, 2024. It is now read-only.

Commit 69c1a97

Browse files
authored
concourse git-hook: check for pipeline generation (#4428)
Author: C.J. Jameson <[email protected]>
1 parent 34d5fc8 commit 69c1a97

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

hooks/pre-push

+19-8
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ url="$2"
99

1010
z40=0000000000000000000000000000000000000000
1111

12+
function user_input_to_proceed() {
13+
read -p 'Proceed with push? (y/N): ' yesno </dev/tty
14+
case "$yesno" in
15+
y|Y|yes|Yes|YES) ;;
16+
*) echo "Aborting push" >&2; exit 1 ;;
17+
esac
18+
}
19+
1220
while read local_ref local_sha remote_ref remote_sha ; do
1321
if [ "$local_sha" = $z40 ] ; then
1422
# Handle delete
@@ -21,15 +29,18 @@ while read local_ref local_sha remote_ref remote_sha ; do
2129
# Update to existing branch, examine new commits
2230
range="$remote_sha..$local_sha"
2331

24-
# Check for WIP commit
25-
commit=$(git rev-list -n 1 "$range" -- concourse/pipelines/*)
26-
if [ -n "$commit" ] ; then
32+
# Check for changed files in concourse/pipelines
33+
changed_pipeline_ymls=$(git rev-list -n 1 "$range" -- concourse/pipelines/*.yml)
34+
changed_pipeline_pys=$(git rev-list -n 1 "$range" -- concourse/pipelines/*.py)
35+
changed_pipeline_templates=$(git rev-list -n 1 "$range" -- concourse/pipelines/templates/*)
36+
37+
# if either a change to generators or a change to the templates, but no new pipeline file, warn user
38+
if [ -n "${changed_pipeline_pys}${changed_pipeline_templates}" ] && [ -z "$changed_pipeline_ymls" ] ; then
39+
echo 'You appear to have changed pipeline inputs (generator or template). Please check in the corresponding generated pipeline.'
40+
user_input_to_proceed
41+
elif [ -n "$changed_pipeline_ymls" ] ; then
2742
echo 'You appear to be pushing a change to a pipeline. Please make sure you ran `fly set-pipeline` first.'
28-
read -p 'Proceed with push? (y/N): ' yesno </dev/tty
29-
case "$yesno" in
30-
y|Y|yes|Yes|YES) ;;
31-
*) echo "Aborting push" >&2; exit 1 ;;
32-
esac
43+
user_input_to_proceed
3344
fi
3445
done
3546

0 commit comments

Comments
 (0)