Skip to content

Commit

Permalink
Fix stash (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
amousavigourabi authored Aug 17, 2023
2 parents 9f1816d + 1d48cd8 commit 8b18b6e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
18 changes: 9 additions & 9 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,23 @@ 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
default: true
default: false
fast-forward:
description: 'Pull fast-forward config'
required: false
default: false
default: true
branch:
description: 'Git branch'
required: false
default: '${GITHUB_REF_NAME}'
default: '"${GITHUB_REF_NAME}"'
files:
description: 'Files to push'
required: false
Expand All @@ -40,16 +40,16 @@ 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.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
Expand Down
16 changes: 10 additions & 6 deletions setup-branch.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
#!/bin/sh
git fetch --all --quiet
git stage -A .
stash_ref="$(git stash create)"
work_branch=$(git symbolic-ref --short HEAD)
if git rev-parse --quiet --verify "origin/$1" >/dev/null
then
git stash --include-untracked
stash_ref=$(git stash create)
work_branch=$(git symbolic-ref --short HEAD)
git switch $1
git merge --squash --strategy-option=theirs --allow-unrelated-histories $work_branch
git stash apply "$stash_ref"
git reset HEAD -- .
else
git switch --orphan $1
git commit --allow-empty -m "Initialize branch"
fi
git merge --squash --strategy-option=theirs --allow-unrelated-histories $work_branch
if [ -n "$stash_ref" ]
then
git stash apply $stash_ref
fi
git reset HEAD -- .

0 comments on commit 8b18b6e

Please sign in to comment.