Smartgit: Auto insert commit message

后端 未结 3 1385
孤独总比滥情好
孤独总比滥情好 2021-02-15 01:38

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.

3条回答
  •  隐瞒了意图╮
    2021-02-15 02:21

    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.

提交回复
热议问题