Smartgit: Auto insert commit message

烂漫一生 提交于 2019-12-04 19:16:09

问题


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.



来源:https://stackoverflow.com/questions/9207556/smartgit-auto-insert-commit-message

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!