github-merge-pr: fix loading .config if symbolic link is used master
authorChristian Marangi <ansuelsmth@gmail.com>
Thu, 2 May 2024 12:26:40 +0000 (14:26 +0200)
committerChristian Marangi <ansuelsmth@gmail.com>
Thu, 2 May 2024 12:26:40 +0000 (14:26 +0200)
Fix loading of .config is symbolic link is used to reference the
github-merge-pr.sh script.

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

index cce2586df3a9634b8e81d14886a69d1ea1fa0d48..dd08a89019cf78f41c9dc0a9a81fd45783a0b007 100755 (executable)
@@ -29,8 +29,11 @@ GITHUB_REPO_OWNER="openwrt"
 # Set this line in .config to use SSH key to rebase PR branch
 # GITHUB_USE_SSH=1
 
+SCRIPT_DIR="$(dirname $0)"
+[ -h $0 ] && SCRIPT_DIR="$(dirname $(readlink $0))"
+
 # Everything in .config will overwrite the default values set up
-[ -f "$(dirname $0)/.config" ] && source $(dirname $0)/.config
+[ -f "$SCRIPT_DIR/.config" ] && source "$SCRIPT_DIR"/.config
 
 PRID="$1"
 BRANCH="${2:-main}"