diff options
author | Doug Anderson <dianders@google.com> | 2011-01-10 14:16:30 -0800 |
---|---|---|
committer | Shawn O. Pearce <sop@google.com> | 2011-02-01 09:57:29 -0800 |
commit | 8ced8641c88d37891a46d42ac1805e380ef6c377 (patch) | |
tree | bb32899a9865ae64a269576598bcc801b69bbcf7 | |
parent | 2536f806258ce2038eea73269290559906cab99a (diff) | |
download | git-repo-8ced8641c88d37891a46d42ac1805e380ef6c377.tar.gz |
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
-rw-r--r-- | project.py | 25 |
1 files changed, 18 insertions, 7 deletions
@@ -54,14 +54,25 @@ def not_rev(r): | |||
54 | def sq(r): | 54 | def sq(r): |
55 | return "'" + r.replace("'", "'\''") + "'" | 55 | return "'" + r.replace("'", "'\''") + "'" |
56 | 56 | ||
57 | hook_list = None | 57 | _project_hook_list = None |
58 | def repo_hooks(): | 58 | def _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 | ||
66 | def relpath(dst, src): | 77 | def 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: |