mirror of
https://gerrit.googlesource.com/git-repo
synced 2024-12-21 07:16:21 +00:00
Renamed 'repo_hooks' function to '_ProjectHooks'.
This renaming was done for two reasons: 1. The hooks are actually project-level hooks, not repo-level hooks. Since we are talking about adding repo-level hooks, It keeps things less confusing if we name the existing hooks to be "ProjectHooks" 2. The function is a private function in project.py and so should have capitalization to match. I also added a docstring describing this function. Change-Id: I1d30f5de08e8f9f99f78146e68c76f906782d97e
This commit is contained in:
parent
2536f80625
commit
8ced8641c8
25
project.py
25
project.py
@ -54,14 +54,25 @@ def not_rev(r):
|
|||||||
def sq(r):
|
def sq(r):
|
||||||
return "'" + r.replace("'", "'\''") + "'"
|
return "'" + r.replace("'", "'\''") + "'"
|
||||||
|
|
||||||
hook_list = None
|
_project_hook_list = None
|
||||||
def repo_hooks():
|
def _ProjectHooks():
|
||||||
global hook_list
|
"""List the hooks present in the 'hooks' directory.
|
||||||
if hook_list is None:
|
|
||||||
|
These hooks are project hooks and are copied to the '.git/hooks' directory
|
||||||
|
of all subprojects.
|
||||||
|
|
||||||
|
This function caches the list of hooks (based on the contents of the
|
||||||
|
'repo/hooks' directory) on the first call.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
A list of absolute paths to all of the files in the hooks directory.
|
||||||
|
"""
|
||||||
|
global _project_hook_list
|
||||||
|
if _project_hook_list is None:
|
||||||
d = os.path.abspath(os.path.dirname(__file__))
|
d = os.path.abspath(os.path.dirname(__file__))
|
||||||
d = os.path.join(d , 'hooks')
|
d = os.path.join(d , 'hooks')
|
||||||
hook_list = map(lambda x: os.path.join(d, x), os.listdir(d))
|
_project_hook_list = map(lambda x: os.path.join(d, x), os.listdir(d))
|
||||||
return hook_list
|
return _project_hook_list
|
||||||
|
|
||||||
def relpath(dst, src):
|
def relpath(dst, src):
|
||||||
src = os.path.dirname(src)
|
src = os.path.dirname(src)
|
||||||
@ -1192,7 +1203,7 @@ class Project(object):
|
|||||||
hooks = self._gitdir_path('hooks')
|
hooks = self._gitdir_path('hooks')
|
||||||
if not os.path.exists(hooks):
|
if not os.path.exists(hooks):
|
||||||
os.makedirs(hooks)
|
os.makedirs(hooks)
|
||||||
for stock_hook in repo_hooks():
|
for stock_hook in _ProjectHooks():
|
||||||
name = os.path.basename(stock_hook)
|
name = os.path.basename(stock_hook)
|
||||||
|
|
||||||
if name in ('commit-msg',) and not self.remote.review:
|
if name in ('commit-msg',) and not self.remote.review:
|
||||||
|
Loading…
Reference in New Issue
Block a user