0

I want to have the ability to fill a form (a couple of questions) for every git-commit I do. Something more than a comment. I mean that every time I git-commit, a little unit-test form will pop-up with a couple of built-in questions and the developer will write what was unit-tested before this feature/change commit.

Usually we do commit from command line or from visual studio (we write in C#).

Does anyone know a nice automatic solution for that ?

Thanks !

MrTux
  • 32,350
  • 30
  • 109
  • 146
user1902346
  • 799
  • 1
  • 12
  • 21
  • 1
    Possible duplicate of [Custom Git Commit Message Template](https://stackoverflow.com/questions/31873577/custom-git-commit-message-template) – MrTux Jun 13 '18 at 12:12

1 Answers1

0

One command line option would be to edit your ~/.gitconfig file and specify a template file for commit messages:

[commit]
template = ~/.committmpl

Then, edit ~/.committmpl and add your content, e.g.

Please describe what was unit tested:

Now, every time someone commits, the above template would populate the commit message. If you wanted to enforce that something is written, perhaps an issue number, etc., you could setup a hook which checks the commit message.

MrTux
  • 32,350
  • 30
  • 109
  • 146
Tim Biegeleisen
  • 502,043
  • 27
  • 286
  • 360
  • thanks. I was not familiar with it. Besides that method - is there any way to call an executable, for example, to run every time a commit is done ? – user1902346 Jun 13 '18 at 12:29
  • @user1902346 I'm not familiar with it. There is probably a way to do the equivalent of what I wrote above from an IDE (e.g. Visual Studio). – Tim Biegeleisen Jun 13 '18 at 12:41
  • Thanks, I will try. I saw that there is a way that I will write my own exe and in the .git\hooks\pre-commit to call this exe. When I am doing a pre-commit file there does it override an existing one ? If so how can I make sure to add my call on pre-commit and then it will continue as before I added the pre-commit ? – user1902346 Jun 13 '18 at 12:46