summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJannis Leidel <jannis@leidel.info>2009-10-04 14:42:37 +0200
committerJannis Leidel <jannis@leidel.info>2009-10-04 14:42:37 +0200
commitcbb4b19e00448764dc1ea8868b8a73050dc05207 (patch)
tree53bc588eba4637e98ea44a995352a3f96e60642e
parent452c8a719d8321e086ca0054586e4d39a75b4ea4 (diff)
downloadpip-cbb4b19e00448764dc1ea8868b8a73050dc05207.tar.gz
Looks for the correct remote name before freezing or switching a Git editable
-rw-r--r--pip.py23
1 files changed, 19 insertions, 4 deletions
diff --git a/pip.py b/pip.py
index 409881df8..818ff8e3a 100644
--- a/pip.py
+++ b/pip.py
@@ -3135,8 +3135,9 @@ class Git(VersionControl):
return [rev]
def switch(self, dest, url, rev_options):
+ remote_name = self.get_remote_name(location)
call_subprocess(
- [GIT_CMD, 'config', 'remote.origin.url', url], cwd=dest)
+ [GIT_CMD, 'config', 'remote.%s.url' % remote_name, url], cwd=dest)
call_subprocess(
[GIT_CMD, 'checkout', '-q'] + rev_options, cwd=dest)
@@ -3161,9 +3162,22 @@ class Git(VersionControl):
call_subprocess(
[GIT_CMD, 'checkout', '-q'] + rev_options, cwd=dest)
+ def get_remote_name(self, location):
+ """First gets the name of the current HEAD, e.g. master. Then returns
+ the name of the remote which the head is tracking."""
+ head_ref = call_subprocess(
+ [GIT_CMD, 'symbolic-ref', '-q', 'HEAD'],
+ show_stdout=False, cwd=location).strip()
+ head_ref = head_ref.split('refs/heads/', 1)[-1]
+ remote_name = call_subprocess(
+ [GIT_CMD, 'config', 'branch.%s.remote' % head_ref],
+ show_stdout=False, cwd=location).strip()
+ return remote_name
+
def get_url(self, location):
+ remote_name = self.get_remote_name(location)
url = call_subprocess(
- [GIT_CMD, 'config', 'remote.origin.url'],
+ [GIT_CMD, 'config', 'remote.%s.url' % remote_name],
show_stdout=False, cwd=location)
return url.strip()
@@ -3207,15 +3221,16 @@ class Git(VersionControl):
current_rev = self.get_revision(location)
tag_revs = self.get_tag_revs(location)
branch_revs = self.get_branch_revs(location)
+ remote_name = self.get_remote_name(location)
if current_rev in tag_revs:
# It's a tag
full_egg_name = '%s-%s' % (egg_project_name, tag_revs[current_rev])
elif (current_rev in branch_revs and
- branch_revs[current_rev] != 'origin/master'):
+ branch_revs[current_rev] != '%s/master' % remote_name):
# It's the head of a branch
full_egg_name = '%s-%s' % (dist.egg_name(),
- branch_revs[current_rev].replace('origin/', ''))
+ branch_revs[current_rev].replace('%s/' % remote_name, ''))
else:
full_egg_name = '%s-dev' % dist.egg_name()