-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Handle no-changed situation #77
Conversation
another option (not necessarily the one that we should go with 🤷♀️) is to just git add -A
git commit --allow-empty -m "$INPUT_COMMIT_MESSAGE"
# ^^^^^^^^^^^^^ |
However, if we have already handled no-changed situation and exit from the script, there may be no situation to use |
I think there is a potential issue about testing in different scenarios. For now, the test is for modified. |
Here's a concrete demo of what I mean from an alternative GitHub wiki action: https://github.com/Andrew-Chen-Wang/github-wiki-action/blob/jcbhmr/src/clone.sh#L90 # Allowing an empty commit is way easier than detecting empty commits! This also
# makes semantic sense. If you run this action, it adds a commit to your wiki.
# How large that commit is comes down to your changes. 0 change = commit with 0.
# This works well with the default "Update wiki ${{ github.sha }}" message so
# that even if the commit is empty, the message has the SHA there.
git commit --allow-empty -m "$INPUT_COMMIT_MESSAGE" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this looks like a good fix! Thanks for including the StackOverflow link too ❤️
@spenserblack is the owner with write perms, so we'll need to wait for a-OK from them.
If we use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
As far as --allow-empty
goes, IMO this would be some sort of input the user would have so that they would have the choice. So, in pseudocode, basically it would be this:
if git_has_changes OR input.allow_empty:
commit()
else:
report_empty()
Oh, and as far as testing goes, TBH I'd want to switch over to using JS/TS before testing in-depth. |
Hi @spenserblack, will a new version be released soon? |
@all-contributors add @yo-ga for code |
I've put up a pull request to add @yo-ga! 🎉 |
Fix #76
git diff-index --quiet HEAD --
sometimes doesn't handle the no-changed situation.Use
git status --porcelain
to handle modified, created, and deleted.