Is there a way to auto insert the commit message in Smartgit with a hook script? (Bash). If a user commit's his change, I want to preload the commit message field.
In SmartGit, there are several places from which you can initiate a Revert: Menu and toolbar On the main window, select Branch|Revert to open the Revert dialog, where you can select one or more commits to revert. Depending on your toolbar settings, you can also open this dialog via the Revert button on the toolbar.
I don't see any SmartGit configuration for this feature.
I would rather rely on a prepare-commit-msg
hook as described in "How do I add project-specific information to the Git commit comment?", based on a commit.template
Git configuration.
See also "Including the current branch name in the commit template" for another example.
There are 2 hooks which may be of interest to you: prepare-commit-msg and commit-msg
prepare-commit-msg is probably the better suited to your purposes as it allows you to pre-fill the commit message before the user sees it. Unfortunately Smartgit does not support this hook. ( see My post and the two older posts to which it refers )
commit-msg will also allow you to modify the commit message, but does so after the user has sent the messages. The example hook scripts in your .git/hooks directory should give you a good start on writing your own.
Git hooks are more versatile than templates. Templates are simpler to use. If your preloaded commit message doesn't have anything dynamic or which would require a shell script to work out, a template may be the more appropriate route. To use a template you must set the commit.template option in git-config. To set this in Smartgit, go to "Tools">"Open git shell", then type
git config commit.template tmplfile
where tmplfile is the file which contains your commit message template including the path there from your git project's root.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With