From 90de09bc977dc2953dddd0c30e297e1e7affd04b Mon Sep 17 00:00:00 2001 From: "robert.tomczyk" Date: Tue, 13 Apr 2021 18:35:57 +0100 Subject: [PATCH] ONAP: Add Work-In-Progress handling for push-upstream Additional parameters can be specified when pushing upstream: - push-upstream wip - will set flag WIP for a change in upstream - push-upstream ready - will remove WIP flag making a change a patch Change-Id: Ic3ddd8c1406642761813ef1157b613f19efb8851 --- jjb/onap/push-upstream-jobs.sh | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/jjb/onap/push-upstream-jobs.sh b/jjb/onap/push-upstream-jobs.sh index 30853ccb..ce106611 100755 --- a/jjb/onap/push-upstream-jobs.sh +++ b/jjb/onap/push-upstream-jobs.sh @@ -49,12 +49,19 @@ onap_remote_url="ssh://$username@$onap_gerrit_base/$onap_project" # GERRIT_BRANCH is the _intended_ branch of the commit under review # E.g. git push HEAD:refs/for/master => GERRIT_BRANCH='master' -# GERRIT_TOPIC is the rest of the refspec after GERRIT_BRANCH when the topic -# is set for the change. -if [ -z "${GERRIT_TOPIC:-}" ] ; then - refspec="${commit_hash}:refs/for/${GERRIT_BRANCH}" -else - refspec="${commit_hash}:refs/for/${GERRIT_BRANCH}%topic=${GERRIT_TOPIC}" +refspec="${commit_hash}:refs/for/${GERRIT_BRANCH}" + +# When 'push-upstream wip' is specified the Work-In-Progress flag is set to change on push to upstream +if [[ "${GERRIT_EVENT_TYPE:-}" == "comment-added" && "${GERRIT_EVENT_COMMENT_TEXT:-}" =~ "push-upstream wip" ]] ; then + wip_option="--push-option wip" +# When 'push-upstream ready' is specified the Work-In-Progress flag from a change is removed on push to upstream +elif [[ "${GERRIT_EVENT_TYPE:-}" == "comment-added" && "${GERRIT_EVENT_COMMENT_TEXT:-}" =~ "push-upstream ready" ]] ; then + wip_option="--push-option ready" +fi + +# When the topic is set for a change the GERRIT_TOPIC is push upstream using git option +if [ -n "${GERRIT_TOPIC:-}" ] ; then + topic_option="--push-option topic=${GERRIT_TOPIC}" fi echo >&2 "Pushing to ONAP" @@ -62,7 +69,7 @@ echo >&2 "Pushing to ONAP" # do not fail if git push fails as in case of no new changes we want to succeed. See below. set +o pipefail -git push "$onap_remote_url" "$refspec" 2>&1 | tee push_result.txt +git push ${topic_option:-} ${wip_option:-} "$onap_remote_url" "$refspec" 2>&1 | tee push_result.txt push_result=${PIPESTATUS[0]} # make the job a success if the above git push fails due to no new changes are needed -- 2.25.1