Add "Allow empty commit" option to commit options context menu#21771
Add "Allow empty commit" option to commit options context menu#21771niik merged 4 commits intodevelopmentfrom
Conversation
Co-authored-by: niik <634063+niik@users.noreply.github.com>
niik
left a comment
There was a problem hiding this comment.
When the CommitMessage component is used inside of the CommitMessageDialog it should be configurable (via props on CommitMessageDialog) whether it should be possible to toggle allowing empty commits. Since the CommitMesssageDialog is currently only used when squashing commits it should default to false. If showAllowEmptyCommitOption (or whatever you name this new prop) is false the context menu item should not be included in the context menu.
Co-authored-by: niik <634063+niik@users.noreply.github.com>
Done in b8ff77c. Added an optional |
niik
left a comment
There was a problem hiding this comment.
One last thing. Can we make it so that the updateCommitOptions method in AppStore (and all the places it's called or forwarded to) accept a Partial such that we don't have to pass the entire CommitOptions object just to change allowEmptyCommit? Do that then update all callsities in commit-message.tsx so only pass the commit option they're changing.
…hain Co-authored-by: niik <634063+niik@users.noreply.github.com>
Done in 842efdb. |
Adds a toggleable "Allow empty commit" option to the commit options gear menu, enabling
git commit --allow-emptyfrom within GitHub Desktop. The option is per-repository and resets tofalseafter each commit.Description
app-state.ts/repository-state-cache.ts: AddedallowEmptyCommit: booleantoIRepositoryState(defaultfalse) and included it in theCommitOptionspick type.git/commit.ts: AddedallowEmpty?: booleanoption tocreateCommit()→ passes--allow-emptytogit commit.app-store.ts: ForwardsallowEmpty: state.allowEmptyCommittocreateCommit(); resetsallowEmptyCommittofalseon successful commit._updateCommitOptionsnow acceptsPartial<CommitOptions>and merges the partial options over current state, so callers only need to pass the option(s) they want to change.dispatcher.ts:updateCommitOptionsupdated to acceptPartial<CommitOptions>.commit-message.tsx:allowEmptyCommitprop.showAllowEmptyCommitOption?: booleanprop — the "Allow empty commit" checkbox in the gear context menu is only shown when this istrue.canCommit()now returnstruewhenallowEmptyCommitis set and a summary exists, even with no files staged.default-optionsstyling whenallowEmptyCommitis active.allowEmptyCommitis on.{ skipCommitHooks: !this.props.skipCommitHooks }).filter-changes-list.tsx: PassesshowAllowEmptyCommitOption={true}toCommitMessage— the main commit panel where the option is applicable.sidebar.tsx,repository.tsx,app.tsx:allowEmptyCommitprop andPartial<CommitOptions>callback type threaded through the component chain.commit-message-dialog.tsx: Added optionalshowAllowEmptyCommitOption?: booleanprop (defaults tofalse) and forwards it toCommitMessage. SinceCommitMessageDialogis currently only used for squash commits, the "Allow empty commit" option is hidden by default.commit-test.ts: Tests thatallowEmpty: trueproduces an empty commit and that omitting it rejects with nothing to commit.Screenshots
Release notes
Notes: [Added] Allow empty commits via the commit options menu
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.