Closed jawoznia closed 1 year ago
Howdy
Using --amend
can be dangerous. I thought I had a section about this in the README, but there's only this section about using it in combination with --no-edit
.
The problem lies in how actions/checkout
checks out a repository. By default, only the last commit (1 commit) is checked out / fetched and not the entire repo history.
Another user ran into a similar issue in https://github.com/stefanzweifel/git-auto-commit-action/issues/159#issuecomment-845347950.
To solve this, add fetch-depth: 2
and skip_fetch: true
to your job.
- uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}
+ fetch-depth: 2
- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_options: '--amend'
push_options: '--force'
+ skip_fetch: true
fetch-depth: 2
to fetch more than just 1 single commit and not destroy the local commit history.
skip_fetch: true
to disable an internal feature of git-auto-commit, where we run git fetch
just before we try to run git checkout -B
.
Let me know if this works or if you still run into the issue.
Thanks for a quick response and great explanation. It works now.
git-auto-commit Version
v4
Machine Type
Ubuntu (eg. ubuntu-latest)
Bug description
I try to create a workflow that will update PRs on change. I don't want to create a new commit and would prefer to
amend
the automatic change to head commit in PR.What I found is that for some reason the whole history is replaced with single new commit.
Steps to reproduce
It should be enough to run the
example workflow
.Tried solutions
It is fine if I remove the
amend
command but it is not desired solution.Example Workflow
Relevant log output
No response