mirror of
https://gerrit.googlesource.com/git-repo
synced 2025-01-08 16:14:26 +00:00
project: replace GetHeadPath with new git helper
Change-Id: I79931cb484508c78f6a8b8413d05b85ed8bc6d98 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/256533 Reviewed-by: David Pursehouse <dpursehouse@collab.net> Tested-by: Mike Frysinger <vapier@google.com>
This commit is contained in:
parent
4b0eb5a441
commit
9f91c4395a
17
project.py
17
project.py
@ -1952,18 +1952,6 @@ class Project(object):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
# Branch Management ##
|
# Branch Management ##
|
||||||
def GetHeadPath(self):
|
|
||||||
"""Return the full path to the HEAD ref."""
|
|
||||||
dotgit = os.path.join(self.worktree, '.git')
|
|
||||||
if os.path.isfile(dotgit):
|
|
||||||
# Git worktrees use a "gitdir:" syntax to point to the scratch space.
|
|
||||||
with open(dotgit) as fp:
|
|
||||||
setting = fp.read()
|
|
||||||
assert setting.startswith('gitdir:')
|
|
||||||
gitdir = setting.split(':', 1)[1].strip()
|
|
||||||
dotgit = os.path.join(self.worktree, gitdir)
|
|
||||||
return os.path.join(dotgit, HEAD)
|
|
||||||
|
|
||||||
def StartBranch(self, name, branch_merge='', revision=None):
|
def StartBranch(self, name, branch_merge='', revision=None):
|
||||||
"""Create a new branch off the manifest's revision.
|
"""Create a new branch off the manifest's revision.
|
||||||
"""
|
"""
|
||||||
@ -2046,7 +2034,8 @@ class Project(object):
|
|||||||
# Same revision; just update HEAD to point to the new
|
# Same revision; just update HEAD to point to the new
|
||||||
# target branch, but otherwise take no other action.
|
# target branch, but otherwise take no other action.
|
||||||
#
|
#
|
||||||
_lwrite(self.GetHeadPath(), 'ref: %s%s\n' % (R_HEADS, name))
|
_lwrite(self.work_git.GetDotgitPath(subpath=HEAD),
|
||||||
|
'ref: %s%s\n' % (R_HEADS, name))
|
||||||
return True
|
return True
|
||||||
|
|
||||||
return GitCommand(self,
|
return GitCommand(self,
|
||||||
@ -2079,7 +2068,7 @@ class Project(object):
|
|||||||
|
|
||||||
revid = self.GetRevisionId(all_refs)
|
revid = self.GetRevisionId(all_refs)
|
||||||
if head == revid:
|
if head == revid:
|
||||||
_lwrite(self.GetHeadPath(), '%s\n' % revid)
|
_lwrite(self.work_git.GetDotgitPath(subpath=HEAD), '%s\n' % revid)
|
||||||
else:
|
else:
|
||||||
self._Checkout(revid, quiet=True)
|
self._Checkout(revid, quiet=True)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user