Stash is not popped when using `--rebase --autostash`
See original GitHub issueDescribe the bug We noticed that the action fails to commit if external changes were introduced to the repo between checking out the repo and running the commit action. The worst thing is that the step doesn’t fail and it seems like everything works fine.
I am able to consistently reproduce this on Windows (on windows-latest runners) and Mac (on macos-latest runners)
Workflow used
name: Tests
on:
workflow_dispatch:
jobs:
test:
runs-on: windows-latest
steps:
- name: Initialize workflow parameters
id: git-branch-name
uses: EthanSK/git-branch-name-action@v1
- name: repository check out
timeout-minutes: 10
uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Write to file and sleep
run: |
echo "hello" >> test.txt
Start-Sleep -Seconds 60
- name: Commit and push to repo
uses: EndBug/add-and-commit@v9
with:
pull: --rebase --autostash
message: "testing"
tag: "new_try_${{ github.run_id }}"
add: "['test.txt']"
author_name: tester
author_email: tester@tester.com
Expected behavior I wrote this workflow just to reproduce the bug. If you manually push to the repo while this workflow is sleeping, you’d expect it to pull the external changes, rebase over them and then commit the new change. That doesn’t happen.
What actually happens is the action fails to commit, but the step ends up with success status
Logs Either provide a link to the action run or (if your repo is private) paste here the logs from the step that uses it. If you paste the logs, please use this template, and remember to paste the logs from all the different sections.
Logs
Pulling from remote... ##[debug]Current git pull arguments: --rebase --autostash ##[debug]Git args parsed: ##[debug] - Original: --rebase --autostash ##[debug] - Parsed: ["--rebase","--autostash"] { raw: '', remote: null, branches: [], tags: [] } PullSummary { remoteMessages: RemoteMessageSummary { all: [] }, created: [ 'another_test.txt' ], deleted: [], files: [ 'another_test.txt' ], deletions: {}, insertions: { 'another_test.txt': 1 }, summary: { changes: 1, deletions: 0, insertions: 1 } } > Creating commit... ##[debug]Git args parsed: ##[debug] - Original: ##[debug] - Parsed: [] { author: null, branch: '', commit: '', summary: { changes: 0, insertions: 0, deletions: 0 } } ##[debug]Setting output: committed=true::set-output name=committed::true ##[debug]=‘true’ ##[debug]Setting output: commit_sha=
::set-output name=commit_sha:: ##[debug]=‘’ Warning: Couldn’t parse long SHA: Error: fatal: ambiguous argument ‘’: unknown revision or path not in the working tree. Use ‘–’ to separate paths from revisions, like this: ‘git <command> [<revision>…] – [<file>…]’
> Tagging commit…
Issue Analytics
- State:
- Created a year ago
- Comments:10 (5 by maintainers)
Top GitHub Comments
You’re right, I’m able to reproduce the issue: the stash is not popped back even when there are no conflicts. I’ll investigate further.
Yeah, that’s what I would expect if you were using
git pull --rebase
, but you’re usinggit pull --rebase --autostash
: that means that your local uncommitted changes (test.txt) will be stashed before the rebase.