X-Git-Url: https://gerrit.linuxfoundation.org/infra/gitweb?a=blobdiff_plain;f=shell%2Fgerrit-push-patch.sh;h=09453f43e4c66bff4d05bbfe04201d0cdd108f19;hb=4867c0799530acf13f7527c6a026879bdfb34e06;hp=d075cddaa05523b25177a156420449ff8b225362;hpb=39abe0daab310c07b85f834d81f07c82218ef504;p=releng%2Fglobal-jjb.git diff --git a/shell/gerrit-push-patch.sh b/shell/gerrit-push-patch.sh index d075cdda..09453f43 100644 --- a/shell/gerrit-push-patch.sh +++ b/shell/gerrit-push-patch.sh @@ -47,25 +47,27 @@ echo -e "INFO: Staged for commit:\n$staged_commits\n" # shellcheck disable=SC1090 source ~/lf-env.sh -lf-activate-venv "git-review>=1.28" +lf-activate-venv --python python3 "git-review==2.3.1" # Query for a pre-existing gerrit review query_result=$(ssh -p 29418 "$GERRIT_USER@$GERRIT_HOST" gerrit query \ - limit:1 owner:self is:open project:"$PROJECT" \ - message: "$GERRIT_COMMIT_MESSAGE" \ - topic: "$GERRIT_TOPIC") + limit:1 owner:self is:open project:"$PROJECT" \ + message: "$GERRIT_COMMIT_MESSAGE" \ + topic: "$GERRIT_TOPIC") # Extract the change_id from the query_result job=$JOB_NAME/$BUILD_NUMBER # If available, add change_id to commit message if change_id=$(echo "$query_result" | grep 'Change-Id:' | awk '{print $2}'); then echo "NOTE: Found gerrit review: $change_id" - message="Job: $job"$'\n\n'"Change-Id: $change_id" + message="Job: $job"$'\n'"Change-Id: $change_id" else echo "NOTE: No gerrit review found" message="Job: $job" fi -git commit -sm "$GERRIT_COMMIT_MESSAGE" -m "$message" +git commit -sm "$GERRIT_COMMIT_MESSAGE + +$message" git status git remote add gerrit "ssh://$GERRIT_USER@$GERRIT_HOST:29418/$PROJECT.git" @@ -73,4 +75,7 @@ git remote add gerrit "ssh://$GERRIT_USER@$GERRIT_HOST:29418/$PROJECT.git" # If the reviewers email is unset/empty then use a default reviewers_email=${REVIEWERS_EMAIL:-"$GERRIT_USER@$GERRIT_HOST"} +# Workaround for git-review failing to copy the commit-msg hook to submodules +git config core.hooksPath "$(git rev-parse --show-toplevel)/.git/hooks" + git review --yes -t "$GERRIT_TOPIC" --reviewers "$reviewers_email"