From 8c7badb93cccbc8275a6cc2469b3b4f5ee5d6dcf Mon Sep 17 00:00:00 2001
From: Steve Martinelli <stevemar@ca.ibm.com>
Date: Wed, 9 Mar 2016 02:48:31 -0500
Subject: [PATCH] use the correct branch when proposing a new config file

when backported patches are merged the script was proposing
changes to the master branch instead of the stable branch.

refer to https://review.openstack.org/#/c/290180/1 to see
how it proposed a really old change.

Change-Id: I198297c7a1c0044b88709cfedf6628a26e4960bc
---
 jenkins/jobs/keystone.yaml                     | 2 +-
 jenkins/scripts/propose_updated_config_file.sh | 7 ++++---
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/jenkins/jobs/keystone.yaml b/jenkins/jobs/keystone.yaml
index c2ca113d43..5be4f788f9 100644
--- a/jenkins/jobs/keystone.yaml
+++ b/jenkins/jobs/keystone.yaml
@@ -44,7 +44,7 @@
       - link-logs
       - net-info
       - gerrit-git-prep
-      - shell: /usr/local/jenkins/slave_scripts/propose_updated_config_file.sh openstack/keystone master
+      - shell: /usr/local/jenkins/slave_scripts/propose_updated_config_file.sh openstack/keystone
 
     publishers:
       - console-log
diff --git a/jenkins/scripts/propose_updated_config_file.sh b/jenkins/scripts/propose_updated_config_file.sh
index de3b86a456..d33b001eea 100755
--- a/jenkins/scripts/propose_updated_config_file.sh
+++ b/jenkins/scripts/propose_updated_config_file.sh
@@ -15,7 +15,6 @@
 source /usr/local/jenkins/slave_scripts/common.sh
 
 PROJECT=$1
-BRANCH=$2
 INITIAL_COMMIT_MSG="Updating sample configuration file"
 USERNAME="proposal-bot"
 TOPIC="$PROJECT/genconf"
@@ -25,7 +24,9 @@ setup_git
 
 # Function setup_commit_message will set CHANGE_ID if a change
 # exists and will always set COMMIT_MSG.
-setup_commit_message $PROJECT $USERNAME $BRANCH $TOPIC "$INITIAL_COMMIT_MSG"
+# Note, ZUUL_REFNAME always exists and is the branch name, for example, it
+# may be master or stable/liberty
+setup_commit_message $PROJECT $USERNAME $ZUUL_REFNAME $TOPIC "$INITIAL_COMMIT_MSG"
 
 # Function check_already_approved will quit the proposal process if there
 # is already an approved job with the same CHANGE_ID
@@ -47,7 +48,7 @@ if ! git diff --stat --exit-code HEAD ; then
     git commit $git_args <<EOF
 $COMMIT_MSG
 EOF
-    OUTPUT=$(git review -t $TOPIC $BRANCH)
+    OUTPUT=$(git review -t $TOPIC $ZUUL_REFNAME)
     RET=$?
     [[ "$RET" -eq "0" || "$OUTPUT" =~ "no new changes" || "$OUTPUT" =~ "no changes made" ]]
     SUCCESS=$?