štvrtok 5. decembra 2019

Hooking git to update blob ID ($Id$) on every commit automatically

Git does not update $Id$ placeholder in working copies automatically out-of-box. One way to achieved that, is described in this blog post. Lets assume, that your git-versioned project folder is your current working directory.

Set .gitattributes

First, ensure, that files, wich needs to have $Id$ populated with their current blob ID, have set ident attribute in .gitattributes file, e.g.:

*       ident whitespace export-subs

More information about .gitattributes.

Create post-commit hook

Create .git/hooks/post-commit file with this content:

#!/bin/bash
# change all files temporarily, to checkout them back, but with updated $Id$ (only that, which were changed before commit)
echo | tee --append *
git checkout *

Make this file executable, e.g.:

chmod 755 .git/hooks/post-commit

After this, each $Id$ occurence should be replaced with $Id: <blob_ID> $ in each file, whose file name matched pattern in .gitattributes with ident.

Maybe post-commit file exists, when applying this, and is serving some purpose already. In such case, you'll need to somehow integrate the script above into existing post-commit script.

Checking all $Id$ occurences in versioned files

grep '\$Id' *

More information about git post-commit hook. This "hack" was inspired by this post.

1 komentár:

  1. Xforce 5.7.2 Crack is an excellent program to activate AutoCAD software. AutoCAD is a simple graphics software that allows users to create .
    X Force Keygen Software Free Download

    OdpovedaťOdstrániť