blu*_*e13 8 git latex githooks gitlab
我已经定义了一个提交后钩子,.git/hooks
它也想在服务器端执行(本例中为Gitlab.com)。
背景:我使用gitinfo2以及LaTeX项目中的post-commit钩子来引用pdf中最新git标签的信息。这在我的计算机上可以正常工作,但是在将存储库推送到Gitlab时失败。
它不会引起错误,但是会给出以下警告,这基本上意味着git hook从未执行。
Package gitinfo2 Warning: I can't find the file '.git/gitHeadInfo.gin'.
(gitinfo2) All git metadata has been set to '(None)'.
Run Code Online (Sandbox Code Playgroud)
根据到目前为止的在线阅读,客户端git钩子无法在服务器上执行-但是为什么不呢?在这种情况下,我希望挂钩在客户端和服务器上都执行。
因此,基本上,我希望事件的顺序如下:
gitHeadInfo.gin
在该.git
文件夹中创建一个称为创建的文件。gitinfo
软件包可帮助从中提取git版本信息gitHeadInfo.gin
。除第3步外,我一切正常。因此,当前的解决方法是在计算机上也生成pdf并提交,而不是依赖于Gitlab CI。
git钩子的内容:
#!/bin/sh
# Copyright 2015 Brent Longborough
# Part of gitinfo2 package Version 2
# Release 2.0.7 2015-11-22
# Please read gitinfo2.pdf for licencing and other details
# -----------------------------------------------------
# Post-{commit,checkout,merge} hook for the gitinfo2 package
#
# Get the first tag found in the history from the current HEAD
FIRSTTAG=$(git describe --tags --always --dirty='-*' 2>/dev/null)
# Get the first tag in history that looks like a Release
RELTAG=$(git describe --tags --long --always --dirty='-*' --match '[0-9]*.*' 2>/dev/null)
# Hoover up the metadata
git --no-pager log -1 --date=short --decorate=short \
--pretty=format:"\usepackage[%
shash={%h},
lhash={%H},
authname={%an},
authemail={%ae},
authsdate={%ad},
authidate={%ai},
authudate={%at},
commname={%cn},
commemail={%ce},
commsdate={%cd},
commidate={%ci},
commudate={%ct},
refnames={%d},
firsttagdescribe={$FIRSTTAG},
reltag={$RELTAG}
]{gitexinfo}" HEAD > .git/gitHeadInfo.gin
Run Code Online (Sandbox Code Playgroud)
客户端git钩子不在服务器上执行-但是为什么不呢?
通常,您要推送到裸仓库(没有工作树的仓库,在该仓库中不能直接执行任何提交),
因此服务器端提交更多是关于执行策略,而不是创建新的提交。
如果您确实需要在服务器端创建新内容(尤其是您无法直接控制的内容,例如GitLab.com),则需要:
归档时间: |
|
查看次数: |
137 次 |
最近记录: |