From 658b68891c1811adc2856ef1eb4ce8007fd3f5e3 Mon Sep 17 00:00:00 2001 From: Samq64 <81489795+Samq64@users.noreply.github.com> Date: Sun, 15 Dec 2024 15:25:02 -0500 Subject: [PATCH 1/2] Commit on Existing PRs --- scripts/commit.sh | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/scripts/commit.sh b/scripts/commit.sh index 425c1cd..ef7b407 100644 --- a/scripts/commit.sh +++ b/scripts/commit.sh @@ -7,14 +7,24 @@ git config user.name "scratchaddons-bot[bot]" if git status | grep -q "git add"; then echo New strings available. Pushing to GitHub... BRANCH=tx - git branch -D $BRANCH - git push origin --delete $BRANCH - git checkout -b $BRANCH + + git show-ref --verify --quiet refs/heads/$BRANCH && BRANCH_EXISTS=true + if [ -n "$BRANCH_EXISTS" ]; then + git checkout $BRANCH + else + git checkout -b $BRANCH + fi + git add _locales/* git add addons-l10n/* git commit --no-gpg-sign -m "New strings from Transifex" git push origin $BRANCH echo Pushed as $BRANCH - - node $GITHUB_ACTION_PATH/scripts/pr.js "$BRANCH" + + if [ -n "$BRANCH_EXISTS" ]; then + echo "Skipping PR creation" + else + echo "Creating a pull request..." + node $GITHUB_ACTION_PATH/scripts/pr.js "$BRANCH" + fi fi From 2a655fcb10f7bba6786d3b3ec424021ab189d828 Mon Sep 17 00:00:00 2001 From: Samq64 <81489795+Samq64@users.noreply.github.com> Date: Sun, 15 Dec 2024 15:58:07 -0500 Subject: [PATCH 2/2] Only PR if BRANCH_EXISTS is set to false --- scripts/commit.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/scripts/commit.sh b/scripts/commit.sh index ef7b407..efac77d 100644 --- a/scripts/commit.sh +++ b/scripts/commit.sh @@ -8,10 +8,11 @@ if git status | grep -q "git add"; then echo New strings available. Pushing to GitHub... BRANCH=tx - git show-ref --verify --quiet refs/heads/$BRANCH && BRANCH_EXISTS=true - if [ -n "$BRANCH_EXISTS" ]; then + if git show-ref --verify --quiet refs/heads/$BRANCH; then + BRANCH_EXISTS=true git checkout $BRANCH else + BRANCH_EXISTS=false git checkout -b $BRANCH fi @@ -21,10 +22,10 @@ if git status | grep -q "git add"; then git push origin $BRANCH echo Pushed as $BRANCH - if [ -n "$BRANCH_EXISTS" ]; then - echo "Skipping PR creation" - else + if [ "$BRANCH_EXISTS" = "false" ]; then echo "Creating a pull request..." node $GITHUB_ACTION_PATH/scripts/pr.js "$BRANCH" + else + echo "Skipping PR creation" fi fi