github-merge-pr: fix loading .config if symbolic link is used
[maintainer-tools.git] / github-merge-pr.sh
index 64cd6bff1046c236d4f4c0e0ba0fa0b240653490..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  .config ] && source .config
+[ -f "$SCRIPT_DIR/.config" ] && source "$SCRIPT_DIR"/.config
 
 PRID="$1"
 BRANCH="${2:-main}"
@@ -137,7 +140,7 @@ if [ "$(echo "$PR_INFO" | jq -r ".maintainer_can_modify")" == "true" ]; then
 
        # Remove any previous SoB tag if the Pull Request Author and Committer match
        if ! $GIT filter-repo --message-callback "
-               return message.replace(b\"Signed-off-by: $(git config user.name) <$(git config user.email)>\",b\"\")
+               return message.replace(b\"Signed-off-by: $(git config user.name) <$(git config user.email)>\n\",b\"\")
        " --refs $BRANCH..$LOCAL_PR_BRANCH --force; then
                echo "Failed to remove previous Committer SoB tag" >&2
                exit 9