summaryrefslogtreecommitdiffstats
path: root/project.py
diff options
context:
space:
mode:
authorShawn O. Pearce <sop@google.com>2009-08-22 18:17:46 -0700
committerShawn O. Pearce <sop@google.com>2010-03-06 19:21:00 -0800
commit9452e4ec0941fbee163e35ebdcd6ca6ee7df55cb (patch)
tree63730cd5665d1a6233c4e0d922a886cbd035cad3 /project.py
parent4c50deea28badb7007fa6b78c187de50eacdd07a (diff)
downloadgit-repo-9452e4ec0941fbee163e35ebdcd6ca6ee7df55cb.tar.gz
Automatically install Gerrit Code Review's commit-msg hookv1.6.9
Most users of repo are also using Gerrit Code Review, and will want the commit-msg hook to be automatically installed into their local projects so that Change-Ids are assigned when commits are created, not when they are first uploaded. (cherry picked from commit a949fa5d202f0a1f812d7630f3e5bf0f02ca4e98 but squashed with latest hook script from version 2.1.2) Change-Id: Ie68b2d60ac85d8c2285d2e1e6a4536eb76695547 Signed-off-by: Shawn O. Pearce <sop@google.com>
Diffstat (limited to 'project.py')
-rw-r--r--project.py22
1 files changed, 18 insertions, 4 deletions
diff --git a/project.py b/project.py
index 3d1783f8..ff896d01 100644
--- a/project.py
+++ b/project.py
@@ -1055,13 +1055,27 @@ class Project(object):
1055 if not os.path.exists(hooks): 1055 if not os.path.exists(hooks):
1056 os.makedirs(hooks) 1056 os.makedirs(hooks)
1057 for stock_hook in repo_hooks(): 1057 for stock_hook in repo_hooks():
1058 dst = os.path.join(hooks, os.path.basename(stock_hook)) 1058 name = os.path.basename(stock_hook)
1059
1060 if name in ('commit-msg') and not self.remote.review:
1061 # Don't install a Gerrit Code Review hook if this
1062 # project does not appear to use it for reviews.
1063 #
1064 continue
1065
1066 dst = os.path.join(hooks, name)
1067 if os.path.islink(dst):
1068 continue
1069 if os.path.exists(dst):
1070 if filecmp.cmp(stock_hook, dst, shallow=False):
1071 os.remove(dst)
1072 else:
1073 _error("%s: Not replacing %s hook", self.relpath, name)
1074 continue
1059 try: 1075 try:
1060 os.symlink(relpath(stock_hook, dst), dst) 1076 os.symlink(relpath(stock_hook, dst), dst)
1061 except OSError, e: 1077 except OSError, e:
1062 if e.errno == errno.EEXIST: 1078 if e.errno == errno.EPERM:
1063 pass
1064 elif e.errno == errno.EPERM:
1065 raise GitError('filesystem must support symlinks') 1079 raise GitError('filesystem must support symlinks')
1066 else: 1080 else:
1067 raise 1081 raise