github-merge-pr: permit to target other repository name
authorChristian Marangi <ansuelsmth@gmail.com>
Fri, 16 Feb 2024 14:13:46 +0000 (15:13 +0100)
committerChristian Marangi <ansuelsmth@gmail.com>
Fri, 16 Feb 2024 14:17:02 +0000 (15:17 +0100)
Add support to target other repository name by passing the repository as
a 3rd arg to the script.

Example:

github-merge-pr.sh 23 main ubus

Will rebase and merge PR 23 in branch main for repository ubus.

Also add additional info on the additional args the script supports.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
github-merge-pr.sh

index e22f3df4155ee48c0d5e38338fc57f7342505316..7f23435a7c1e9885a54e3f38bdb45c2b74a425dc 100755 (executable)
@@ -6,10 +6,14 @@
 # 2. Make sure you can correctly push and force push to the github
 #    repository
 #
-# Usage: github-merge-pr.sh PR_NUMBER BRANCH
+# Usage: github-merge-pr.sh PR_NUMBER BRANCH REPO_NAME
+#
+# BRANCH is optional and defaults to main.
+# REPO_NAME is optional and defaults to openwrt. It does
+# describe the repository name to use to pull PR info from.
 
-# Github repository, just the name/repo part, no .git suffix, no base url!
-REPO="openwrt/openwrt"
+# Github repository owner or organization name.
+GITHUB_REPO_OWNER="openwrt"
 
 # Your repository token, generate this token at your profile page:
 # - Navigate to https://github.com/settings/tokens
@@ -23,8 +27,11 @@ REPO="openwrt/openwrt"
 
 PRID="$1"
 BRANCH="${2:-main}"
-DRY_RUN="$3"
+GITHUB_REPO_NAME="${3:-openwrt}"
+DRY_RUN="$4"
+
 GIT=git
+REPO="$GITHUB_REPO_OWNER"/"$GITHUB_REPO_NAME"
 
 yesno() {
        local prompt="$1"