为什么有的 仓库 没有 hook commit-msg

1
repo forall -c 'a=$(file .git/hooks/commit-msg); echo $a=$REPO_PATH'

初步来看 和 xml 中的 remote 那里配置的review 有关系。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36


def _InitHooks(self):
hooks = platform_utils.realpath(self._gitdir_path('hooks'))
if not os.path.exists(hooks):
os.makedirs(hooks)
for stock_hook in _ProjectHooks():
name = os.path.basename(stock_hook)

if name in ('commit-msg',) and not self.remote.review \
and self is not self.manifest.manifestProject:
# 不符合条件的仓库 就不会做这个 commit-msg 的软连接了。
# 主要就是没有在 manifest xml中的remote 那里配置 reivew 地址的仓库。
continue

dst = os.path.join(hooks, name)
if platform_utils.islink(dst):
continue
if os.path.exists(dst):
if filecmp.cmp(stock_hook, dst, shallow=False):
platform_utils.remove(dst)
else:
_warn("%s: Not replacing locally modified %s hook",
self.relpath, name)
continue
try:
platform_utils.symlink(
os.path.relpath(stock_hook, os.path.dirname(dst)), dst)
except OSError as e:
if e.errno == errno.EPERM:
raise GitError(self._get_symlink_error_message())
else:
raise