summaryrefslogtreecommitdiffstats
path: root/project.py
diff options
context:
space:
mode:
Diffstat (limited to 'project.py')
-rw-r--r--project.py25
1 files changed, 18 insertions, 7 deletions
diff --git a/project.py b/project.py
index ca092b89..125fb48c 100644
--- a/project.py
+++ b/project.py
@@ -54,14 +54,25 @@ def not_rev(r):
54def sq(r): 54def sq(r):
55 return "'" + r.replace("'", "'\''") + "'" 55 return "'" + r.replace("'", "'\''") + "'"
56 56
57hook_list = None 57_project_hook_list = None
58def repo_hooks(): 58def _ProjectHooks():
59 global hook_list 59 """List the hooks present in the 'hooks' directory.
60 if hook_list is None: 60
61 These hooks are project hooks and are copied to the '.git/hooks' directory
62 of all subprojects.
63
64 This function caches the list of hooks (based on the contents of the
65 'repo/hooks' directory) on the first call.
66
67 Returns:
68 A list of absolute paths to all of the files in the hooks directory.
69 """
70 global _project_hook_list
71 if _project_hook_list is None:
61 d = os.path.abspath(os.path.dirname(__file__)) 72 d = os.path.abspath(os.path.dirname(__file__))
62 d = os.path.join(d , 'hooks') 73 d = os.path.join(d , 'hooks')
63 hook_list = map(lambda x: os.path.join(d, x), os.listdir(d)) 74 _project_hook_list = map(lambda x: os.path.join(d, x), os.listdir(d))
64 return hook_list 75 return _project_hook_list
65 76
66def relpath(dst, src): 77def relpath(dst, src):
67 src = os.path.dirname(src) 78 src = os.path.dirname(src)
@@ -1192,7 +1203,7 @@ class Project(object):
1192 hooks = self._gitdir_path('hooks') 1203 hooks = self._gitdir_path('hooks')
1193 if not os.path.exists(hooks): 1204 if not os.path.exists(hooks):
1194 os.makedirs(hooks) 1205 os.makedirs(hooks)
1195 for stock_hook in repo_hooks(): 1206 for stock_hook in _ProjectHooks():
1196 name = os.path.basename(stock_hook) 1207 name = os.path.basename(stock_hook)
1197 1208
1198 if name in ('commit-msg',) and not self.remote.review: 1209 if name in ('commit-msg',) and not self.remote.review: