Changeset - fa0a18dc0fd5
[Not reviewed]
default
0 1 0
Mads Kiilerich (mads) - 5 years ago 2020-11-01 23:54:39
mads@kiilerich.com
Grafted from: 46f103c36d21
vcs: fix str utils import - vcs should be self-contained
1 file changed with 1 insertions and 1 deletions:
0 comments (0 inline, 0 general)
kallithea/lib/vcs/backends/git/workdir.py
Show inline comments
 
import re
 

	
 
from kallithea.lib.utils2 import ascii_str, safe_str
 
from kallithea.lib.vcs.backends.base import BaseWorkdir
 
from kallithea.lib.vcs.exceptions import BranchDoesNotExistError, RepositoryError
 
from kallithea.lib.vcs.utils import ascii_str, safe_str
 

	
 

	
 
class GitWorkdir(BaseWorkdir):
 

	
 
    def get_branch(self):
 
        headpath = self.repository._repo.refs.refpath(b'HEAD')
 
        try:
 
            content = safe_str(open(headpath, 'rb').read())
 
            match = re.match(r'^ref: refs/heads/(?P<branch>.+)\n$', content)
 
            if match:
 
                return match.groupdict()['branch']
 
            else:
0 comments (0 inline, 0 general)