|
48 | 48 | DEFAULT_SERVER = 'https://codereview.appspot.com'
|
49 | 49 | POSTUPSTREAM_HOOK_PATTERN = '.git/hooks/post-cl-%s'
|
50 | 50 | DESCRIPTION_BACKUP_FILE = '~/.git_cl_description_backup'
|
| 51 | +GIT_INSTRUCTIONS_URL = 'http://code.google.com/p/chromium/wiki/UsingNewGit' |
51 | 52 |
|
52 | 53 |
|
53 | 54 | # Initialized in main()
|
@@ -308,6 +309,7 @@ def __init__(self, branchref=None):
|
308 | 309 | self._rpc_server = None
|
309 | 310 | self.cc = None
|
310 | 311 | self.watchers = ()
|
| 312 | + self._remote = None |
311 | 313 |
|
312 | 314 | def GetCCList(self):
|
313 | 315 | """Return the users cc'd on this CL.
|
@@ -386,14 +388,36 @@ def GetUpstreamBranch(self):
|
386 | 388 | self.upstream_branch = upstream_branch
|
387 | 389 | return self.upstream_branch
|
388 | 390 |
|
| 391 | + def GetRemote(self): |
| 392 | + if not self._remote: |
| 393 | + self._remote = self.FetchUpstreamTuple()[0] |
| 394 | + if self._remote == '.': |
| 395 | + |
| 396 | + remotes = RunGit(['remote'], error_ok=True).split() |
| 397 | + if len(remotes) == 1: |
| 398 | + self._remote, = remotes |
| 399 | + elif 'origin' in remotes: |
| 400 | + self._remote = 'origin' |
| 401 | + logging.warning('Could not determine which remote this change is ' |
| 402 | + 'associated with, so defaulting to "%s". This may ' |
| 403 | + 'not be what you want. You may prevent this message ' |
| 404 | + 'by running "git svn info" as documented here: %s', |
| 405 | + self._remote, |
| 406 | + GIT_INSTRUCTIONS_URL) |
| 407 | + else: |
| 408 | + logging.warn('Could not determine which remote this change is ' |
| 409 | + 'associated with. You may prevent this message by ' |
| 410 | + 'running "git svn info" as documented here: %s', |
| 411 | + GIT_INSTRUCTIONS_URL) |
| 412 | + return self._remote |
| 413 | + |
| 414 | + |
389 | 415 | def GetRemoteUrl(self):
|
390 | 416 | """Return the configured remote URL, e.g. 'git://example.org/foo.git/'.
|
391 | 417 |
|
392 | 418 | Returns None if there is no remote.
|
393 | 419 | """
|
394 |
| - remote = self.FetchUpstreamTuple()[0] |
395 |
| - if remote == '.': |
396 |
| - return None |
| 420 | + remote = self.GetRemote() |
397 | 421 | return RunGit(['config', 'remote.%s.url' % remote], error_ok=True).strip()
|
398 | 422 |
|
399 | 423 | def GetIssue(self):
|
|
0 commit comments