Refresh text in file if installed in git

Let's say I have a file like:

/** * A Test class * @version 2011.11.24 */ public class Test { } 

I want the date stamp to be updated automatically every time it is bound to git , and there will be changes in the file. Is it possible?

+4
source share
2 answers

You can write a clean filter. This will really happen if you add files to the staging area, which can be even better (because you can see the result without committing it).

Cleanup and blur filters are described here: https://git-scm.com/book/en/v2/Customizing-Git-Git-Attributes#_keyword_expansion . This page also provides an example keyword extension for $Date$ using a small ruby ​​script.

+1
source

You can write a simple script to automatically check all source files and update dates, and then run them before each commit using the pre-commit hook. More information on git hooks can be found here.

0
source

Source: https://habr.com/ru/post/1382919/


All Articles