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.
问题:
回答1:
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.
回答2:
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.