Files
@ 7e5f8c12a3fc
Branch filter:
Location: kallithea/rhodecode/lib/vcs/backends/git/workdir.py - annotation
7e5f8c12a3fc
1.1 KiB
text/x-python
First step in two-part process to rename directories to kallithea.
This first step is to change all references in the files where they refer
to the old directory name.
This first step is to change all references in the files where they refer
to the old directory name.
324ac367a4da 7e5f8c12a3fc 7e5f8c12a3fc 7e5f8c12a3fc 324ac367a4da 324ac367a4da 324ac367a4da 324ac367a4da 324ac367a4da 324ac367a4da 324ac367a4da 324ac367a4da 324ac367a4da 324ac367a4da 324ac367a4da 324ac367a4da 324ac367a4da 324ac367a4da 324ac367a4da 324ac367a4da 324ac367a4da 324ac367a4da 2b5f94fc3b7a 2b5f94fc3b7a 324ac367a4da 324ac367a4da 324ac367a4da 324ac367a4da 324ac367a4da 324ac367a4da 324ac367a4da | import re
from kallithea.lib.vcs.backends.base import BaseWorkdir
from kallithea.lib.vcs.exceptions import RepositoryError
from kallithea.lib.vcs.exceptions import BranchDoesNotExistError
class GitWorkdir(BaseWorkdir):
def get_branch(self):
headpath = self.repository._repo.refs.refpath('HEAD')
try:
content = open(headpath).read()
match = re.match(r'^ref: refs/heads/(?P<branch>.+)\n$', content)
if match:
return match.groupdict()['branch']
else:
raise RepositoryError("Couldn't compute workdir's branch")
except IOError:
# Try naive way...
raise RepositoryError("Couldn't compute workdir's branch")
def get_changeset(self):
wk_dir_id = self.repository._repo.refs.as_dict().get('HEAD')
return self.repository.get_changeset(wk_dir_id)
def checkout_branch(self, branch=None):
if branch is None:
branch = self.repository.DEFAULT_BRANCH_NAME
if branch not in self.repository.branches:
raise BranchDoesNotExistError
self.repository.run_git_command(['checkout', branch])
|