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