diff options
Diffstat (limited to 'project.py')
-rw-r--r-- | project.py | 22 |
1 files changed, 18 insertions, 4 deletions
@@ -1056,13 +1056,27 @@ class Project(object): | |||
1056 | if not os.path.exists(hooks): | 1056 | if not os.path.exists(hooks): |
1057 | os.makedirs(hooks) | 1057 | os.makedirs(hooks) |
1058 | for stock_hook in repo_hooks(): | 1058 | for stock_hook in repo_hooks(): |
1059 | dst = os.path.join(hooks, os.path.basename(stock_hook)) | 1059 | name = os.path.basename(stock_hook) |
1060 | |||
1061 | if name in ('commit-msg') and not self.remote.review: | ||
1062 | # Don't install a Gerrit Code Review hook if this | ||
1063 | # project does not appear to use it for reviews. | ||
1064 | # | ||
1065 | continue | ||
1066 | |||
1067 | dst = os.path.join(hooks, name) | ||
1068 | if os.path.islink(dst): | ||
1069 | continue | ||
1070 | if os.path.exists(dst): | ||
1071 | if filecmp.cmp(stock_hook, dst, shallow=False): | ||
1072 | os.remove(dst) | ||
1073 | else: | ||
1074 | _error("%s: Not replacing %s hook", self.relpath, name) | ||
1075 | continue | ||
1060 | try: | 1076 | try: |
1061 | os.symlink(relpath(stock_hook, dst), dst) | 1077 | os.symlink(relpath(stock_hook, dst), dst) |
1062 | except OSError, e: | 1078 | except OSError, e: |
1063 | if e.errno == errno.EEXIST: | 1079 | if e.errno == errno.EPERM: |
1064 | pass | ||
1065 | elif e.errno == errno.EPERM: | ||
1066 | raise GitError('filesystem must support symlinks') | 1080 | raise GitError('filesystem must support symlinks') |
1067 | else: | 1081 | else: |
1068 | raise | 1082 | raise |