I have a private git repository that I do all of my staging on before pushing it up to Github. I have the following template
/**
*
* @version ${commit}
* @since ${initial_commit}
*/
public class Foo {
}
What I want is to have the ${initial_commit}
to be replaced with the commit number when the file was added to the repo, and every time there is a change, change the ${commit}
to the resulting commit number. Is there some way to accomplish this? I saw another post about using a post-commit hook, but my thinking is that, the commit number (or value/hash) is calculated based on the changes, but by changing the values in the post-commit hook when committing to the public repo, it would have a different number. Or am I mistaken?
You are correct. The hash refelcts the content of the commit. This makes it impossible to have the hash number anywhere in the commited data.
You could wirte a script which replaces initial_commit
with a hash. This of course requires a new commit.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.