-
-
Notifications
You must be signed in to change notification settings - Fork 230
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot --amend --no-edit
#159
Comments
Thanks for reporting. Am I understanding this right that you only set the
Or do you also use the Checking for certain values in - name: Get last commit message
id: last-commit-message
run: |
echo "::set-output name=msg::$(git log -1 --pretty=%B | cat)"
- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: ${{ steps.last-commit-message.outputs.msg }}
commit_options: '--amend --no-edit' Or does |
Yes, at least that's what I tried.
... 🤦🏻 I should, thanks, just hadn't had it work yet so hadn't realised my omission.
That's exactly what I've done (I don't think the |
I can understand the frustration. However, I've kept the Action low level by design.
This seems weird. According to the virtual-environments repo, I tried to test the approach with providing the commit_message as I mentioned above, but the global Actions outage today blocks me from actually running this. If this works as expected I'more than happy to add it as an example to the README. |
Actions is working again and I did a little test in a test-repo. The approach of defining the message in combination with - name: Get last commit message
id: last-commit-message
run: |
echo "::set-output name=msg::$(git log -1 --pretty=%B)"
- uses: stefanzweifel/git-auto-commit-action@v4
id: commit
with:
commit_message: ${{ steps.last-commit-message.outputs.msg }}
commit_options: '--amend --no-edit'
push_options: '--force' But using the Action in that way vaporized my previous git history - as is expected when using
So I wouldn't recommend doing that. Just let the Action generate a new commit. |
As I mentioned, my use case is (re-)rendering a template on a schedule; there's no value to the rendering changes, the important commits are the template changes. So at first I had it amend when the latest commit was also a CI render, but otherwise create one. Then I realised, there's no point even in that, semantically, the rendering should change at the same time as the template, and if it also renders differently at a later time (without other template change), that's still semantically part of the same commit, so, now I have it always amend. I'm not sure what you mean by 'vaporized my previous git history', that seems quite an exaggeration? Just the latest commit would be updated with whatever diff, and the committer date & user (but not author date & user) would update. To me it seems unexpected that Cheers. |
I should have been more specific. I've been using that test repository since the beginning to test the Action. Had something like 150 commits. After running my test workflow with I reran the Workflow this morning to reproduce this behaviour: https://github.com/stefanzweifel/git-auto-commit-action-demo-app/runs/2627309671?check_suite_focus=true#step:6:78 I'm not sure if this is just a mis-configuration on my side or if this is the intended result of using Just as I was writing this response I've browsed through your profile and landed on https://github.com/OJFord/OJFord/blob/master/.github/workflows/render.yml. For now, I will document this behaviour in the README, so that others don't stumble over this edge case. |
No, You're right about my own repo though, that was not the case when I last checked it. (Also something up with the message adding quotes by the look of it.) What must be happening here is If you had 150 commits in sequence, you had the 150th checked out, It also shows that it doesn't work with multiline commit messages - even with my attempt to quote around the output (which just duplicated each time, and didn't quote the multiline successfully) - |
Oh, I see what's happening with the 'single commit' - it's because of a shallow fetch ( 🤞🏻 - run: sudo apt update && sudo apt -y install git
- uses: actions/checkout@master
with:
# so we can commit --amend and push -f
fetch-depth: 2
# [ cause the diff ]
- name: Reuse message
run: |
# Actions do not support multiline `::set-output`s
echo 'COMMIT_MSG<<EOM' >> "$GITHUB_ENV"
git log -n1 --pretty='%B' >> "$GITHUB_ENV"
echo 'EOM' >> "$GITHUB_ENV"
- uses: stefanzweifel/git-auto-commit-action@v4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
# --amend --no-edit doesn't work because of default --message
# (effectively --no-edit is ignored)
commit_message: ${{ env.COMMIT_MSG }}
commit_options: --amend --no-edit
push_options: --force
# so as not to make too shallow for commit --amend and push -f
skip_fetch: true Worked on push, just waiting for the scheduled run to check that works too. It's quite a lot of setup just to avoid a default
Another option, if it's possible, I'm not sure, might be if you could distinguish a with:
commit_message: null if it can be determined apart from |
Just a note that the default By default That is:
I would suggest removing the dirty check, and just leaving it to |
@OJFord Thanks for all the research and comments. Especially the find that the The My decision to add a I consider removing this in v5. 🙌 |
I'm rendering markdown in an Action on a cron, and want it to just amend the last commit rather than create a continuous stream of 'render' commits that don't have any value.
Unfortunately though (I've tested this), this prevents
--amend --no-edit
from working:git-auto-commit-action/entrypoint.sh
Lines 86 to 88 in 5dd17c3
since the
--no-edit
is effectively ignored if a--message
is specified.I'm not sure what to suggest as a fix, but two options I can think of are:
--no-edit
appears incommit_options
; do not specify-m ..
if it does;with: amend: true
config, which adds--amend --no-edit
to options and doesn't specify-m ..
The text was updated successfully, but these errors were encountered: