From 296a93efe6d19454af19b153437f87e21cea44fe Mon Sep 17 00:00:00 2001 From: amousavigourabi <28668597+amousavigourabi@users.noreply.github.com> Date: Thu, 17 Aug 2023 02:34:43 +0200 Subject: [PATCH 01/16] debug statements --- setup-branch.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/setup-branch.sh b/setup-branch.sh index 86c20fc..8e66640 100755 --- a/setup-branch.sh +++ b/setup-branch.sh @@ -2,12 +2,22 @@ git fetch --all --quiet if git rev-parse --quiet --verify "origin/$1" >/dev/null then + echo "aaaaaaaa" + ls -la git stash --include-untracked stash_ref=$(git stash create) work_branch=$(git symbolic-ref --short HEAD) + echo "eeeeeeee" + ls -la git switch $1 + echo "iiiiiiii" + ls -la git merge --squash --strategy-option=theirs --allow-unrelated-histories $work_branch + echo "oooooooo" + ls -la git stash apply "$stash_ref" + echo "uuuuuuuu" + ls -la git reset HEAD -- . else git switch --orphan $1 From 8e5fc69e74cf2de2e045d265f2394967559e0275 Mon Sep 17 00:00:00 2001 From: amousavigourabi <28668597+amousavigourabi@users.noreply.github.com> Date: Thu, 17 Aug 2023 02:42:02 +0200 Subject: [PATCH 02/16] Resolve discrepancy between docs and action --- action.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/action.yml b/action.yml index f50fe17..a0dd2f0 100644 --- a/action.yml +++ b/action.yml @@ -18,11 +18,11 @@ inputs: rebase: description: 'Pull rebase config' required: false - default: true + default: false fast-forward: description: 'Pull fast-forward config' required: false - default: false + default: true branch: description: 'Git branch' required: false @@ -44,12 +44,12 @@ runs: git config --global user.email ${{ inputs.email }} shell: bash - name: 'Set rebase pull mode' - if: ${{ !inputs.fast-forward && inputs.rebase }} + if: ${{ inputs.rebase }} run: | git config pull.rebase true shell: bash - name: 'Set fast-forward pull mode' - if: ${{ inputs.fast-forward }} + if: ${{ !inputs.rebase && inputs.fast-forward }} run: | git config pull.ff true shell: bash From 8141c0f44bf8f9864d5e67cc348c0c03f4734f95 Mon Sep 17 00:00:00 2001 From: amousavigourabi <28668597+amousavigourabi@users.noreply.github.com> Date: Thu, 17 Aug 2023 02:43:29 +0200 Subject: [PATCH 03/16] some more debug statements --- action.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/action.yml b/action.yml index a0dd2f0..1c9c4cc 100644 --- a/action.yml +++ b/action.yml @@ -55,7 +55,9 @@ runs: shell: bash - name: 'Commit and push the changed files' run: | + ls -la sudo ${{ github.action_path }}/setup-branch.sh ${{ inputs.branch }} + ls -la git stage -A ${{ inputs.files }} ${{ github.action_path }}/commit.sh "${{ inputs.message }}" ${{ inputs.allow-empty }} sudo ${{ github.action_path }}/push.sh ${{ inputs.branch }} From f006c20d2969305fe82afb47884a2158e50e8618 Mon Sep 17 00:00:00 2001 From: amousavigourabi <28668597+amousavigourabi@users.noreply.github.com> Date: Thu, 17 Aug 2023 03:07:09 +0200 Subject: [PATCH 04/16] Stash and merge for new branches too --- setup-branch.sh | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/setup-branch.sh b/setup-branch.sh index 8e66640..355312a 100755 --- a/setup-branch.sh +++ b/setup-branch.sh @@ -1,24 +1,14 @@ #!/bin/sh git fetch --all --quiet +git stash --include-untracked +stash_ref=$(git stash create) +work_branch=$(git symbolic-ref --short HEAD) if git rev-parse --quiet --verify "origin/$1" >/dev/null then - echo "aaaaaaaa" - ls -la - git stash --include-untracked - stash_ref=$(git stash create) - work_branch=$(git symbolic-ref --short HEAD) - echo "eeeeeeee" - ls -la git switch $1 - echo "iiiiiiii" - ls -la - git merge --squash --strategy-option=theirs --allow-unrelated-histories $work_branch - echo "oooooooo" - ls -la - git stash apply "$stash_ref" - echo "uuuuuuuu" - ls -la - git reset HEAD -- . else git switch --orphan $1 fi +git merge --squash --strategy-option=theirs --allow-unrelated-histories $work_branch +git stash apply "$stash_ref" +git reset HEAD -- . From ff8951fd28b2149872a853d6e075b388babffe71 Mon Sep 17 00:00:00 2001 From: amousavigourabi <28668597+amousavigourabi@users.noreply.github.com> Date: Thu, 17 Aug 2023 03:35:01 +0200 Subject: [PATCH 05/16] Add empty init commit --- setup-branch.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/setup-branch.sh b/setup-branch.sh index 355312a..28b919b 100755 --- a/setup-branch.sh +++ b/setup-branch.sh @@ -8,6 +8,7 @@ then git switch $1 else git switch --orphan $1 + git commit --allow-empty -m "Initialize branch" fi git merge --squash --strategy-option=theirs --allow-unrelated-histories $work_branch git stash apply "$stash_ref" From 3df11231ff46f2539ac9d869916b4b83629053da Mon Sep 17 00:00:00 2001 From: amousavigourabi <28668597+amousavigourabi@users.noreply.github.com> Date: Thu, 17 Aug 2023 03:35:46 +0200 Subject: [PATCH 06/16] Add stash pop guard --- setup-branch.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/setup-branch.sh b/setup-branch.sh index 28b919b..1b9f100 100755 --- a/setup-branch.sh +++ b/setup-branch.sh @@ -11,5 +11,8 @@ else git commit --allow-empty -m "Initialize branch" fi git merge --squash --strategy-option=theirs --allow-unrelated-histories $work_branch -git stash apply "$stash_ref" +if [ -n "$stash_ref" ] +then + git stash pop "$stash_ref" +fi git reset HEAD -- . From b50adbb19e77e4f50917442fbfd048a9b4c80a62 Mon Sep 17 00:00:00 2001 From: amousavigourabi <28668597+amousavigourabi@users.noreply.github.com> Date: Thu, 17 Aug 2023 03:44:25 +0200 Subject: [PATCH 07/16] Set git config for system --- action.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/action.yml b/action.yml index 1c9c4cc..eb0257d 100644 --- a/action.yml +++ b/action.yml @@ -40,18 +40,18 @@ runs: steps: - name: 'Configure the runner' run: | - git config --global user.name ${{ inputs.author }} - git config --global user.email ${{ inputs.email }} + git config --system user.name ${{ inputs.author }} + git config --system user.email ${{ inputs.email }} shell: bash - name: 'Set rebase pull mode' if: ${{ inputs.rebase }} run: | - git config pull.rebase true + git config --system pull.rebase true shell: bash - name: 'Set fast-forward pull mode' if: ${{ !inputs.rebase && inputs.fast-forward }} run: | - git config pull.ff true + git config --system pull.ff true shell: bash - name: 'Commit and push the changed files' run: | From 9983951cf152992167e667331283cdae4d18e7fb Mon Sep 17 00:00:00 2001 From: amousavigourabi <28668597+amousavigourabi@users.noreply.github.com> Date: Thu, 17 Aug 2023 03:49:27 +0200 Subject: [PATCH 08/16] Add diagnostic for stash --- setup-branch.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/setup-branch.sh b/setup-branch.sh index 1b9f100..f571a15 100755 --- a/setup-branch.sh +++ b/setup-branch.sh @@ -2,6 +2,7 @@ git fetch --all --quiet git stash --include-untracked stash_ref=$(git stash create) +git stash list work_branch=$(git symbolic-ref --short HEAD) if git rev-parse --quiet --verify "origin/$1" >/dev/null then From 82e5017e6eeecb2ce21c08da3fddc19b72655409 Mon Sep 17 00:00:00 2001 From: amousavigourabi <28668597+amousavigourabi@users.noreply.github.com> Date: Thu, 17 Aug 2023 03:55:38 +0200 Subject: [PATCH 09/16] Revert "Set git config for system" --- action.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/action.yml b/action.yml index eb0257d..b587f7d 100644 --- a/action.yml +++ b/action.yml @@ -40,18 +40,18 @@ runs: steps: - name: 'Configure the runner' run: | - git config --system user.name ${{ inputs.author }} - git config --system user.email ${{ inputs.email }} + git config --global user.name ${{ inputs.author }} + git config --global user.email ${{ inputs.email }} shell: bash - name: 'Set rebase pull mode' if: ${{ inputs.rebase }} run: | - git config --system pull.rebase true + git config --global pull.rebase true shell: bash - name: 'Set fast-forward pull mode' if: ${{ !inputs.rebase && inputs.fast-forward }} run: | - git config --system pull.ff true + git config --global pull.ff true shell: bash - name: 'Commit and push the changed files' run: | From c9fd508e38779fee5547eb797218838f05182559 Mon Sep 17 00:00:00 2001 From: amousavigourabi <28668597+amousavigourabi@users.noreply.github.com> Date: Thu, 17 Aug 2023 04:00:57 +0200 Subject: [PATCH 10/16] Add quotes for git config --- action.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/action.yml b/action.yml index b587f7d..cbf670c 100644 --- a/action.yml +++ b/action.yml @@ -10,11 +10,11 @@ inputs: author: description: 'Commit author' required: false - default: '${GITHUB_ACTOR}' + default: '"${GITHUB_ACTOR}"' email: description: 'Committer email' required: false - default: '${GITHUB_ACTOR_ID}+${GITHUB_ACTOR}@users.noreply.github.com' + default: '"${GITHUB_ACTOR_ID}+${GITHUB_ACTOR}@users.noreply.github.com"' rebase: description: 'Pull rebase config' required: false @@ -26,7 +26,7 @@ inputs: branch: description: 'Git branch' required: false - default: '${GITHUB_REF_NAME}' + default: '"${GITHUB_REF_NAME}"' files: description: 'Files to push' required: false From 06454e45b7048e076e0594aa3c2b39c19323898d Mon Sep 17 00:00:00 2001 From: amousavigourabi <28668597+amousavigourabi@users.noreply.github.com> Date: Thu, 17 Aug 2023 04:07:10 +0200 Subject: [PATCH 11/16] Add quotes for command substitution --- setup-branch.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup-branch.sh b/setup-branch.sh index f571a15..331cfbf 100755 --- a/setup-branch.sh +++ b/setup-branch.sh @@ -1,7 +1,7 @@ #!/bin/sh git fetch --all --quiet git stash --include-untracked -stash_ref=$(git stash create) +stash_ref="$(git stash create)" git stash list work_branch=$(git symbolic-ref --short HEAD) if git rev-parse --quiet --verify "origin/$1" >/dev/null From 3c7d833032ab87d6278457ff9eb5fb74b997a228 Mon Sep 17 00:00:00 2001 From: amousavigourabi <28668597+amousavigourabi@users.noreply.github.com> Date: Thu, 17 Aug 2023 04:17:20 +0200 Subject: [PATCH 12/16] Make the stash tracked by staging all first --- setup-branch.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/setup-branch.sh b/setup-branch.sh index 331cfbf..a61586f 100755 --- a/setup-branch.sh +++ b/setup-branch.sh @@ -1,6 +1,7 @@ #!/bin/sh git fetch --all --quiet -git stash --include-untracked +git stage -A . +git stash stash_ref="$(git stash create)" git stash list work_branch=$(git symbolic-ref --short HEAD) From ce4f0ef13290fc16dd9a7c5602d23b13f553a621 Mon Sep 17 00:00:00 2001 From: amousavigourabi <28668597+amousavigourabi@users.noreply.github.com> Date: Thu, 17 Aug 2023 04:19:57 +0200 Subject: [PATCH 13/16] Remove diagnostics --- action.yml | 2 -- setup-branch.sh | 1 - 2 files changed, 3 deletions(-) diff --git a/action.yml b/action.yml index cbf670c..31aea59 100644 --- a/action.yml +++ b/action.yml @@ -55,9 +55,7 @@ runs: shell: bash - name: 'Commit and push the changed files' run: | - ls -la sudo ${{ github.action_path }}/setup-branch.sh ${{ inputs.branch }} - ls -la git stage -A ${{ inputs.files }} ${{ github.action_path }}/commit.sh "${{ inputs.message }}" ${{ inputs.allow-empty }} sudo ${{ github.action_path }}/push.sh ${{ inputs.branch }} diff --git a/setup-branch.sh b/setup-branch.sh index a61586f..39a4c32 100755 --- a/setup-branch.sh +++ b/setup-branch.sh @@ -3,7 +3,6 @@ git fetch --all --quiet git stage -A . git stash stash_ref="$(git stash create)" -git stash list work_branch=$(git symbolic-ref --short HEAD) if git rev-parse --quiet --verify "origin/$1" >/dev/null then From d50bcaecf43e6f509243517b634e838ce26a9830 Mon Sep 17 00:00:00 2001 From: amousavigourabi <28668597+amousavigourabi@users.noreply.github.com> Date: Thu, 17 Aug 2023 04:24:49 +0200 Subject: [PATCH 14/16] Remove explicit stash before stash create --- setup-branch.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/setup-branch.sh b/setup-branch.sh index 39a4c32..6b6efb2 100755 --- a/setup-branch.sh +++ b/setup-branch.sh @@ -1,7 +1,6 @@ #!/bin/sh git fetch --all --quiet git stage -A . -git stash stash_ref="$(git stash create)" work_branch=$(git symbolic-ref --short HEAD) if git rev-parse --quiet --verify "origin/$1" >/dev/null From f660d573fdac4a054d4c03941adb93f641e5ed1a Mon Sep 17 00:00:00 2001 From: amousavigourabi <28668597+amousavigourabi@users.noreply.github.com> Date: Thu, 17 Aug 2023 04:33:36 +0200 Subject: [PATCH 15/16] Local git config --- action.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/action.yml b/action.yml index 31aea59..e926c4f 100644 --- a/action.yml +++ b/action.yml @@ -40,18 +40,18 @@ runs: steps: - name: 'Configure the runner' run: | - git config --global user.name ${{ inputs.author }} - git config --global user.email ${{ inputs.email }} + git config user.name ${{ inputs.author }} + git config user.email ${{ inputs.email }} shell: bash - name: 'Set rebase pull mode' if: ${{ inputs.rebase }} run: | - git config --global pull.rebase true + git config pull.rebase true shell: bash - name: 'Set fast-forward pull mode' if: ${{ !inputs.rebase && inputs.fast-forward }} run: | - git config --global pull.ff true + git config pull.ff true shell: bash - name: 'Commit and push the changed files' run: | From 1d48cd81da7f230cbe94105865d415c270c10859 Mon Sep 17 00:00:00 2001 From: amousavigourabi <28668597+amousavigourabi@users.noreply.github.com> Date: Thu, 17 Aug 2023 04:43:49 +0200 Subject: [PATCH 16/16] Git stash apply --- setup-branch.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup-branch.sh b/setup-branch.sh index 6b6efb2..d58cf01 100755 --- a/setup-branch.sh +++ b/setup-branch.sh @@ -13,6 +13,6 @@ fi git merge --squash --strategy-option=theirs --allow-unrelated-histories $work_branch if [ -n "$stash_ref" ] then - git stash pop "$stash_ref" + git stash apply $stash_ref fi git reset HEAD -- .