【发布时间】:2015-09-24 11:17:34
【问题描述】:
标题几乎说明了一切。
在本地 repo 中,我有 .git 文件夹,其中包含我的钩子。我使用我的自定义 Lua 源将当前版本写入文件本身。然后在预提交钩子中我有:
#!/bin/sh
#
# An example hook script to verify what is about to be committed.
# Called by "git commit" with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit.
#
# To enable this hook, rename this file to "pre-commit".
echo "START" >> E:/Desktop/tmp.txt
exec $LUA_HOME\\lua.exe ${PWD}\\hooks\\pre-commit.lua "${PWD}/lua/autorun/trackassembly_init.lua" "Rev." > E:/Desktop/tmp.txt
我有两个文件。首先,我进行实际更改(源文件)。第二个我用来在(版本文件)中写入当前版本。
每当我使用 TortoiseGit 时:
1) Modify the source file
2) Repo Directory --> Right Click --> Git Commit "master"
在索引中添加了有关源文件的信息,但其中没有包含新版本的更改版本文件的痕迹。这会导致工作副本和版本文件之间存在差异,并且 TortoiseGit 会在目录上放置一个 (!)。
根据手册:
预提交钩子首先运行,甚至在您输入提交消息之前。它用于检查即将提交的快照、查看是否忘记了某些内容、确保测试运行或检查代码中需要检查的任何内容。从这个钩子中退出非零会中止提交
【问题讨论】:
标签: git github version-control pre-commit-hook