示例#1
0
def current_branch():
    """Return the current branch"""
    decode = core.decode
    head = git.git_path('HEAD')
    try:
        key = os.stat(head).st_mtime
        if _current_branch.key == key:
            return _current_branch.value
    except OSError:
        pass
    status, data = git.rev_parse('HEAD',
                                 symbolic_full_name=True,
                                 with_status=True)
    if status != 0:
        # git init -- read .git/HEAD.  We could do this unconditionally...
        data = _read_git_head(head)

    for refs_prefix in ('refs/heads/', 'refs/remotes/', 'refs/tags/'):
        if data.startswith(refs_prefix):
            value = decode(data[len(refs_prefix):])
            _current_branch.key = key
            _current_branch.value = value
            return value
    # Detached head
    return data
示例#2
0
文件: gitcmds.py 项目: mwh/git-cola
def current_branch():
    """Return the current branch"""
    decode = core.decode
    head = git.git_path('HEAD')
    try:
        key = os.stat(head).st_mtime
        if _current_branch.key == key:
            return _current_branch.value
    except OSError:
        pass
    data = git.rev_parse('HEAD', with_stderr=True, symbolic_full_name=True)
    if data.startswith('fatal:'):
        # git init -- read .git/HEAD.  We could do this unconditionally
        # and avoid the subprocess call.  It's probably time to start
        # using dulwich.
        data = _read_git_head(head)

    for refs_prefix in ('refs/heads/', 'refs/remotes/'):
        if data.startswith(refs_prefix):
            value = decode(data[len(refs_prefix):])
            _current_branch.key = key
            _current_branch.value = value
            return value
    # Detached head
    return data
示例#3
0
def current_branch():
    """Return the current branch"""
    head = git.git_path("HEAD")
    try:
        key = core.stat(head).st_mtime
        if _current_branch.key == key:
            return _current_branch.value
    except OSError:
        pass
    status, data, err = git.rev_parse("HEAD", symbolic_full_name=True)
    if status != 0:
        # git init -- read .git/HEAD.  We could do this unconditionally...
        data = _read_git_head(head)

    for refs_prefix in ("refs/heads/", "refs/remotes/", "refs/tags/"):
        if data.startswith(refs_prefix):
            value = data[len(refs_prefix) :]
            _current_branch.key = key
            _current_branch.value = value
            return value
    # Detached head
    return data
示例#4
0
def current_branch():
    """Return the current branch"""
    decode = core.decode
    head = git.git_path('HEAD')
    try:
        key = os.stat(head).st_mtime
        if _current_branch.key == key:
            return _current_branch.value
    except OSError:
        pass
    status, data = git.rev_parse('HEAD', symbolic_full_name=True, with_status=True)
    if status != 0:
        # git init -- read .git/HEAD.  We could do this unconditionally...
        data = _read_git_head(head)

    for refs_prefix in ('refs/heads/', 'refs/remotes/', 'refs/tags/'):
        if data.startswith(refs_prefix):
            value = decode(data[len(refs_prefix):])
            _current_branch.key = key
            _current_branch.value = value
            return value
    # Detached head
    return data
示例#5
0
 def save_archive(self):
     ref = git.rev_parse('HEAD')[STDOUT]
     shortref = ref[:7]
     GitArchiveDialog.save_hashed_objects(ref, shortref, self)
示例#6
0
 def save_archive(self):
     ref = git.rev_parse('HEAD')[STDOUT]
     shortref = ref[:7]
     GitArchiveDialog.save_hashed_objects(ref, shortref, self)
示例#7
0
文件: view.py 项目: yjpark/git-cola
 def save_archive(self):
     ref = git.rev_parse('HEAD')
     shortref = ref[:7]
     GitArchiveDialog.save(ref, shortref, self)
示例#8
0
文件: view.py 项目: moreati/git-cola
 def save_archive(self):
     ref = git.rev_parse('HEAD')
     shortref = ref[:7]
     GitArchiveDialog.save(ref, shortref, self)
示例#9
0
文件: main.py 项目: pwr/git-cola
 def save_archive(self):
     ref = git.rev_parse("HEAD")[STDOUT]
     shortref = ref[:7]
     GitArchiveDialog.save(ref, shortref, self)