Which git hooks to install for automatic version numbering

时间:2017-01-19 15:24:12

标签: git versioning githooks

I have a script writing/updating a file with versioning info for my software. It is based on git describe and basically just counts commits since the last tag. Is there any best-practice in which git hooks to run this script in so that all developers always have up-to-date versioning info before compilation independent of the specific workflow they updated their working copy with? I'm especially thinking about the very typical ones:

  • committing/pushing
  • pulling
  • merging
  • initially cloning

and I'm sure I'm missing some. Is there a single hook which can cover all of these cases or do I have to install multiple ones? Is there any natural best choice? Does it make sense to put the generated versioning file under version control or not?

1 个答案:

答案 0 :(得分:0)

我建议不要使用钩子,因为每个开发人员必须在克隆后手动设置这些钩子,或者至少触发一些安装它们的安装脚本。您无法集中控制开发人员存储库中的挂钩。

相反,我建议让你的构建过程从Git信息更新这个文件,因为你肯定有一些正在使用的构建工具。