Chromium Code Reviews| Index: git_cl.py |
| =================================================================== |
| --- git_cl.py (revision 121208) |
| +++ git_cl.py (working copy) |
| @@ -11,9 +11,11 @@ |
| import optparse |
| import os |
| import re |
| +import stat |
| import sys |
| import textwrap |
| import urlparse |
| +import urllib |
| import urllib2 |
| try: |
| @@ -734,11 +736,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 +745,25 @@ |
| keyvals['ORIGIN_URL_CONFIG']]) |
| +def DownloadHooks(): |
|
M-A Ruel
2012/02/10 15:50:05
Add force argument
ukai
2012/02/13 02:57:43
Done.
|
| + """downloads hooks""" |
| + if settings.GetIsGerrit(): |
|
M-A Ruel
2012/02/10 15:50:05
if not settings.GetIsGerrit():
return
reduces i
ukai
2012/02/13 02:57:43
Done.
|
| + server_url = settings.GetDefaultServerUrl() |
| + src = '%s/tools/hooks/commit-msg' % server_url |
| + dst = os.path.join(settings.GetRoot(), '.git', 'hooks', 'commit-msg') |
| + if not os.access(dst, os.X_OK): |
| + if os.path.exists(dst): |
|
M-A Ruel
2012/02/10 15:50:05
if os.path.exists(dst):
if not force:
return
ukai
2012/02/13 02:57:43
Done.
|
| + os.remove(dst) |
| + try: |
| + urllib.urlretrieve(src, dst) |
| + os.chmod(dst, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR) |
| + except Exception, e: |
| + print e |
| + if os.path.exists(dst): |
| + os.remove(dst) |
| + DieWithError('\nFailed to download hooks from %s' % src) |
| + |
| + |
| @usage('[repo root containing codereview.settings]') |
| def CMDconfig(parser, args): |
| """edit configuration for this tree""" |
| @@ -755,6 +771,7 @@ |
| _, args = parser.parse_args(args) |
| if len(args) == 0: |
| GetCodereviewSettingsInteractively() |
| + DownloadHooks() |
|
M-A Ruel
2012/02/10 15:50:05
True
ukai
2012/02/13 02:57:43
Done.
|
| return 0 |
| url = args[0] |
| @@ -763,6 +780,7 @@ |
| # Load code review settings and download hooks (if available). |
| LoadCodereviewSettingsFromFile(urllib2.urlopen(url)) |
| + DownloadHooks() |
|
M-A Ruel
2012/02/10 15:50:05
True
ukai
2012/02/13 02:57:43
Done.
|
| return 0 |