Index: git_cl.py |
=================================================================== |
--- git_cl.py (revision 121208) |
+++ git_cl.py (working copy) |
@@ -11,6 +11,7 @@ |
import optparse |
import os |
import re |
+import stat |
import sys |
import textwrap |
import urlparse |
@@ -734,11 +735,6 @@ |
if 'GERRIT_HOST' in keyvals and 'GERRIT_PORT' in keyvals: |
RunGit(['config', 'gerrit.host', keyvals['GERRIT_HOST']]) |
RunGit(['config', 'gerrit.port', keyvals['GERRIT_PORT']]) |
- # Install the standard commit-msg hook. |
- RunCommand(['scp', '-p', '-P', keyvals['GERRIT_PORT'], |
- '%s:hooks/commit-msg' % keyvals['GERRIT_HOST'], |
- os.path.join(settings.GetRoot(), |
- '.git', 'hooks', 'commit-msg')]) |
if 'PUSH_URL_CONFIG' in keyvals and 'ORIGIN_URL_CONFIG' in keyvals: |
#should be of the form |
@@ -748,6 +744,20 @@ |
keyvals['ORIGIN_URL_CONFIG']]) |
+def DownloadHooks(): |
+ """downloads hooks""" |
+ if settings.GetIsGerrit(): |
+ server_url = settings.GetDefaultServerUrl() |
+ src = '%s/tools/hooks/commit-msg' % server_url |
+ dst = os.path.join(settings.GetRoot(), '.git', 'hooks', 'commit-msg') |
+ fileobj = urllib2.urlopen(src) |
+ commit_msg = open(dst, 'w') |
+ commit_msg.write(fileobj.read()) |
+ fileobj.close() |
+ commit_msg.close() |
+ os.chmod(dst, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR) |
+ |
+ |
@usage('[repo root containing codereview.settings]') |
def CMDconfig(parser, args): |
"""edit configuration for this tree""" |
@@ -755,6 +765,7 @@ |
_, args = parser.parse_args(args) |
if len(args) == 0: |
GetCodereviewSettingsInteractively() |
+ DownloadHooks() |
return 0 |
url = args[0] |
@@ -763,6 +774,7 @@ |
# Load code review settings and download hooks (if available). |
LoadCodereviewSettingsFromFile(urllib2.urlopen(url)) |
+ DownloadHooks() |
return 0 |