Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7658713
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:14:15+00:00 2026-05-31T13:14:15+00:00

I use git as my version control system and have set up a Gerrit

  • 0

I use git as my version control system and have set up a Gerrit site to do the code review. I would like to create a hook to do the following:

  • When the admin clicks the Submit button, a file (called version.txt)
    should be modified.
  • Script should open the file.
  • Find the following text (where the ID may change)

    #version Change-Id: Ie1411d50f6beb885bc3d3b7d8c587635e1446c18

  • Replace the Change-Id with the Change-Id of the new patch.

  • So, if the patch being merged has the Change-Id: I1c25f7b967084008b69a6a8aefa6e3bb32967b82 then the version.txt file
    should contain the following string after the script is run:

    #version Change-Id: I1c25f7b967084008b69a6a8aefa6e3bb32967b82

  • Then the hook should create a new commit (since now there has been a change in one of the files) and push this last commit to master.

I feel this would be possible using a change-merged hook. Am I right?

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T13:14:15+00:00Added an answer on May 31, 2026 at 1:14 pm

    Something like this:

    #!/bin/sh
    
    # See link below for actual command line format
    # you may need to make the argument parsing more robust
    CHANGE_ID=$2
    
    git clone ${GIT_DIR} /tmp/repo-${CHANGE_ID}
    echo "#version Change-Id: ${CHANGE_ID}" > /tmp/repo-${CHANGE_ID}/version.txt
    GIT_DIR=/tmp/repo-${CHANGE_ID}/
    cd /tmp/repo-${CHANGE_ID}/
    git add /tmp/repo-${CHANGE_ID}/version.txt
    git commit -m'Auto-updated version'
    git push origin master
    rm -rf /tmp/repo-${CHANGE_ID}/
    

    http://gerrit-documentation.googlecode.com/svn/Documentation/2.2.2/config-hooks.html#_change_merged

    On principle, I’m not a fan of this approach, and I think it should be better done on the way out (e.g., a “install.sh” script, which can use git commands to extract the revision hash, and generate a version.txt file from there). But something like this should put you in the right direction. This is untested, but it should work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use git as my primary version control system, and have recently started using
I am trying to use git and MobileMe as a version control system for
I'm currently starting to use git for my version control system, however I do
I write my code in Netbeans and use Git as my versioning control system.
Which version control system should I use for a Rails app: Git or SVN?
We currently use subversion as our version control system, we have decided that we
I'm trying to use git behind a proxy and i have set up the
I use phpstorm as my IDE, it has git version control integration built in
I am going to use Git version control by IntelliJ Community Edition in order
We're working on quite big project and decided use GIT for version control. I've

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.