【问题标题】:Automatic Version Update with Vim; without SVN, I use Git使用 Vim 自动更新版本;没有 SVN,我使用 Git
【发布时间】:2011-03-12 18:14:12
【问题描述】:

我知道我可以配置 SVN 以自动更新每个文件头中的版本。但我使用Git,这不支持它。 Vim 是否有任何插件或其他东西可以为我做到这一点?

或者在保存的文件的注释标题中“上次修改”之后是否有更新时间戳?

感谢您回答我的问题,抱歉我的英语不好

【问题讨论】:

  • 本题与php无关。

标签: git vim


【解决方案1】:

你为什么要 Vim 这样做?这就是预提交挂钩,请参阅man githooks

更新:看起来 gitattributes 是更好的选择:

cd /path/to/repo
echo "*.php filter=lastmodified" >> .gitattributes
cat >> .git/config << EOF
[filter "lastmodified"]
    clean = "sed -r -e 's/(.{,10}Last Modified:).*/echo \"\\1 `date +%F`\"/e'"
EOF

【讨论】:

    【解决方案2】:

    在最近的一个项目中,我使用了一个小脚本,该脚本基于git describe --tags 生成了一个版本文件,以包含在构建过​​程中。如果你不需要编译你的东西,你也可以在 git post-commit 脚本中更新一个文件(并将这个文件放在 .gitignore 中)。

    【讨论】:

      猜你喜欢
      • 2018-01-06
      • 1970-01-01
      • 2016-05-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-07-14
      • 2022-06-11
      • 1970-01-01
      相关资源
      最近更新 更多