Search code examples
visual-studio-codegerrit

How to add the Gerrit Change-ID in Visual Studio Code commit


In our project Change-id is mandatory for commits, but I did not found how to add it in Visual Studio Code.

I downloaded the "Gerrit" plug-in, but even so I did not fond a way to add the Change-ID

Any idea?


Solution

  • You need to install the "commit-msg" hook in the ".git" directory of your local repository.

    See more details in the Gerrit documentation here.

    Basically you need to go (cd) to your local repository and execute the following command:

    gitdir=$(git rev-parse --git-dir); curl --create-dirs -Lo ${gitdir}/hooks/commit-msg https://GERRIT-SERVER/tools/hooks/commit-msg; chmod u+x ${gitdir}/hooks/commit-msg
    

    After that, every time you create a new commit or change (--amend) an old one, the Change-Id will be automatically added.