6

I'm looking to solve a problem with our CI build definition being triggered by merge commits. I'd like to find where Visual Studio stores the default merge commit message and edit it to include the ***NO_CI*** hack. So far I haven't found any reference to where the default commit message values are stored. I dug through the settings in the IDE and there aren't any that look like commit messages. Does anyone know where they're hidden?

Also, I've seen the related questions here on Stack but most are talking about cygwin and command line git usage, not the integrated Team Explorer panel in VS.

Mike Devenney
  • 1,758
  • 1
  • 23
  • 42
  • A little [xy](http://xyproblem.info/) but why don't you have your CI trigger from commits on [protected branches](https://learn.microsoft.com/en-us/azure/devops/repos/git/branch-policies?view=azure-devops)? – Adam Mar 02 '20 at 17:25

2 Answers2

0

If recent Visual Studio does not use libgit2 anymore, then it should be using Git directly.

If you can, do a git config -l --show-origin (soon git config -l --show-origin --show-scope with git 2.26 to see all settings.

Look for a commit.xxx setting, like for instance commit.template.

If this is done by a CI, create a CI job which will do a git config -l --show-origin

That should show you the setting which allows said CI to use the right commit message.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thanks Von, tried this and only get 10 lines of config at c:\git. There are a few more that look specific to my use in VS in my user directory in the .gitconfig file but still nothing that looks like the commit.xxx setting you mentioned. – Mike Devenney Feb 28 '20 at 20:12
  • It did, but none of them seemed to be what I was looking for. In the end we just changed the settings on the build pipeline to batch changes while a build is running. It essentially accomplishes what we were aiming for. – Mike Devenney Mar 10 '20 at 16:31
  • @MikeDevenney Sounds good: you can document it here in your own answer (that you can then accept) – VonC Mar 10 '20 at 16:32
  • Thought about that but since my solution doesn't actually answer the question I had I didn't want to record a misleading answer. The answer would have helped me achieve what I was trying to do, but what I was trying to do isn't relevant in the context of this question. – Mike Devenney Mar 10 '20 at 16:36
0

This is a workaround

You can run bash or a PowerShell to check if the last commit contains a certain word. (I'm using bash here)

git log head -1 | grep -q 'Merge:'

Run it as a part of the pipeline, set a variable which can be used to validate as a part of a condition.

git log head -1 | grep -q 'Merge:' && _stop_pipeline=true

Use a condition for the stage or the step:

  • 1
    Wanted to thank you for your answer. I didn't award the bounty as none of the answers brought me to where we wanted to be. In the end we decided to queue builds while another is running and that seems to at least minimize the number of builds going on. – Mike Devenney Mar 10 '20 at 16:30