Support prepare-commit-msg hooks#2795
Open
DCVortexxx wants to merge 1 commit into
Open
Conversation
Run prepare-commit-msg when GitUp prepares the commit message editor so hook output appears before the user submits the commit. Keep commit-msg validation at commit time using Git's standard COMMIT_EDITMSG file, and preserve user edits if the async prepare hook finishes after typing begins.
Collaborator
|
@DCVortexxx Thank you for the candor in using AI. It gives me the appropriate expectation. I assume you've tested locally? It sounds like a good addition and I will look at the changes soon. This Thursday I'll likely be releasing the 1.5.0 release of GitUp to the stable channel so it won't go in before that. Probably next week is a realistic time for me to start testing out this change. |
Author
|
Hey @lucasderraugh, thanks for getting back to me. Yeah, I tested it locally, through all paths that came to mind :
I also have validated that the implementation is reasonable, according to my knowledge of the codebase of course. Let me know if I can help in any way, and of course, no worries about the timing, |
Collaborator
|
Wonderful, thank you! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Disclosure
I AGREE TO THE GITUP CONTRIBUTOR LICENSE AGREEMENT.
Full disclosure, this has been drafted by AI because I haven't played with ObjC for yeeeeeaaaaars, but I believe that it respects the coding standard and contribution rules.
Of course, I'm open to suggestions and will happily update it to make it into master.
I LOVE GitUp and having to rely on another editor just because a project I work on needs this hook on it is a pain 😅
Summary
This adds support for Git's
prepare-commit-msghook when creating commits from GitUp.Git documents
prepare-commit-msgas running after the default commit message is prepared and before the editor starts.To match that lifecycle, GitUp now runs the hook when the commit view prepares the message editor in
viewWillAppear:prepare-commit-msghook should be allowed to finish.It also runs when the user toggles Amend:
prepare-commit-msgwith Git's amend-stylecommitsourceprepare-commit-msgrun, GitUp replaces it with the amend message flow.This also has a side effect on the
commit-msghook, because it used to rely on a app-owned, temporary file for writing the commit message, instead the the$GIT_DIR/COMMIT_EDITMSGfile Git uses.Since
prepare-commit-msgrelies on this file,commit-msgshould read it as well, as the single source of truth for commit message edition.Note
My first implementation ran it when the user actually commits, right before
commit-msg, and it made the code significantly simpler, since we don't need to handle in-flight edit, and "just" update the message in the same waycommit-msgdoes.However, I changed it to be closer to Git's semantics.
Feel free to let me know if you feel like this is a tradeoff worth having.