From 694d159b46b517dc4eba700bbd4f93d17c9af2e3 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Thu, 28 Mar 2019 12:05:51 +0800 Subject: [PATCH] script/ceph-backport.sh: allow user to specify remote repo before this change, the script always push to "origin", in my case, "origin" points to "ceph/ceph", while we need to create the branch in private repo. and the name of private repo might vary. so would be great if we can customize this setting. Signed-off-by: Kefu Chai --- src/script/ceph-backport.sh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/script/ceph-backport.sh b/src/script/ceph-backport.sh index 0022393cffd5b..783bd3558d4c9 100755 --- a/src/script/ceph-backport.sh +++ b/src/script/ceph-backport.sh @@ -37,7 +37,13 @@ # redmine_user_id=[your_redmine_user_id] # github_token=[your_github_personal_access_token] # github_user=[your_github_username] -# +# +# you can also optionally add the remote repo's name in this file, like +# +# github_repo=[your_github_repo_name] +# +# If you don't add it, it will default to "origin". +# # Obviously, since this file contains secrets, you should protect it from # exposure using all available means (restricted file privileges, encrypted # filesystem, etc.). Without correct values for these four variables, this @@ -56,6 +62,7 @@ test "$redmine_key" || failed_required_variable_check redmine_key test "$redmine_user_id" || failed_required_variable_check redmine_user_id test "$github_token" || failed_required_variable_check github_token test "$github_user" || failed_required_variable_check github_user +: "${github_repo:=origin}" function usage () { echo "Usage:" @@ -123,7 +130,8 @@ fi title=$(curl --silent 'http://tracker.ceph.com/issues/'$issue.json?key=$redmine_key | jq .issue.subject | tr -d '\\"') echo "Issue title: $title" -git push -u origin wip-$issue-$milestone +git push -u $github_repo wip-$issue-$milestone + number=$(curl --silent --data-binary '{"title":"'"$title"'","head":"'$github_user':wip-'$issue-$milestone'","base":"'$target_branch'","body":"http://tracker.ceph.com/issues/'$issue'"}' 'https://api.github.com/repos/ceph/ceph/pulls?access_token='$github_token | jq .number) echo "Opened pull request $number" -- 2.39.5