diff options
Diffstat (limited to 'project.py')
-rw-r--r-- | project.py | 22 |
1 files changed, 18 insertions, 4 deletions
@@ -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 |