From b2a52500be9d17f51c797b279c1679d0ed5488cb Mon Sep 17 00:00:00 2001 From: Pierre Pronchery Date: Tue, 3 Nov 2020 21:36:19 +0100 Subject: [PATCH] Warn if jobs are not available --- src/deforaos-git-hook | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/src/deforaos-git-hook b/src/deforaos-git-hook index e6cd899..cabb5cf 100755 --- a/src/deforaos-git-hook +++ b/src/deforaos-git-hook @@ -54,27 +54,34 @@ SYSCONFDIR="$PREFIX/etc" #hook_jobs _hook_jobs() { + res=0 + while read oldrev newrev refname; do case "$refname" in refs/heads/*) - _jobs_branch "${refname#refs/heads/}" "$GL_REPO" + _jobs_branch "${refname#refs/heads/}" \ + "$GL_REPO" || res=2 ;; esac done - return $ret + return $res } _jobs_branch() -{ +{( branch="$1" repository="$2" + res=0 if [ "$branch" = "master" -a -n "$JOBS_BRANCH_MASTER" ]; then for job in $JOBS_BRANCH_MASTER; do - $DEFORAOS_JOBS add "$job $repository" + #warn if the job is not available + [ -x "$job" ] || _error "$job: Job not available" + $DEFORAOS_JOBS add "$job $repository" || res=2 done fi -} + return $res +)} #hook_irc @@ -90,6 +97,14 @@ _hook_irc() } +#error +_error() +{ + echo "$PROGNAME: $@" 1>&2 + return 2 +} + + #main #save a copy of the output tmpfile=$($MKTEMP)