(Optionally) call prepare-commit-msg hook to customize the default commit message
The problem with the current template support is that it completely overrides the merge-conflict generated messages, which we very much prefer over a static-warning commit style message.
I'd like to use SmartGIT in a project with customer provided (mandatory!) git hooks to
check and process files and prepare preformatted commit messages.
It would be nice if the generated commit message would be transferred automatically
into the SmartGIT commit GUI messagebox.
In our organization, each commit shall begin with Ticket ID.
This hook would help every developer.
Workarounds via post-checkout- or commit-hooks are far from ideal.
To be honest, I find it strange, that the prepare commit message hook is not called by SmartGit (as to my mind the most professional Client/GUI out there).
When exactly the pre-commit hook should be invoked? On every refresh?
Hello Mr Singer.
Our use case would be: You manually select changed files for commit and choose "commit" (Ctrl + K)
On the other hand our prepare commit message hook should be robust enough that it should work on every refresh.
I assume refresh refers to periodical git checks for changes in the repo?
Edit: We are working in an environment with several Submodules
My suggestion would be to invoke the prepare-commit-msg hook:
Additionally, if the text area in the Commit window loses focus before the value of the text area is changed, the value of that text area should be set to the contents of the configured commit.template file, or an empty string.
Would you mind invoking an extra action in the Commit view (or dialog) to trigger invoking the .git/hooks/commit-msg script?
Hi Thomas, apologies for the slow reply, I hadn't noticed your message - I think it would be fine to have a button or something to manually invoke the prepare-commit-msg hook, but it would be great if it could be done automatically - is there some reason that my suggestion above wouldn't work?
Also, just for clarity - I'm referring to the
hook, and NOT the
Hooks' essense is automatic execution. Manual way (additional button) would not be so helpful. Don't add the button.It seems developers don't exactly know how to get rid of multiple unneeded triggering of a hook when, for example, Commit area gains/looses focus three times, leading to message like this:TCKT-56536: TCKT-56536: TCKT-56536: when this was expected:TCKT-56536:
I'm using SmartGit for several years now and this is the only hook as far as I know which doesn't get invoked.SmartGit is working great with any of our other hooks, but this one which would be a small QoL improvement just doesn't exist.Like other I would like to infer a commit message prefix from the branch name to match our commit message style.
Why not fixing this 6 years old issue ? Pretty sure it is 2-line fix, just run the hook before opening the commit message window and fill it with the COMMIT_EDITMSG content.
Surprised at the lack of support for this feature - another vote to implement support for this hook, it would improve my workflow.
Please describe your workflow in more details.
All of my commit messages in a certain repository always begin with the identifier of the Jira ticket I'm working on, which can be a string of up to 10 characters.
This identifier is also always at the beginning of the name of the branch, always in the same format. It is used in our tools to link commits, branches, pull requests, and tickets together.
For example, when viewing a ticket in Jira, recent commits and branches which contain the ticket identifier are shown in the sidebar.
At present, I am doing this by either typing the identifier manually, or by copying the branch name, pasting it into the commit message, and manually deleting the git flow prefix and a short ticket description, such as "improve_report_performance".
I have made mistakes in the past when entering it manually (e.g. entering TCKT-56536 instead of TCKT-56356) which leads to the commit being linked to the wrong ticket - this can be resolved by amending the commit message, but it's a pain.
Copying the branch name, then copying the identifier, then pasting it, is quite a repetitive, time-consuming task.
It would be very helpful to make use of the prepare-commit hook to get the ticket identifier from the branch name and prepend it to the commit message using a script.
This is just a very simple example of how the hook could be used; I imagine there are workflows vastly more complex than mine for which this would be a great benefit.
Customer support service by UserEcho