mirror of
https://github.com/powerline/powerline.git
synced 2025-07-29 08:45:15 +02:00
Merge branch 'feature/git-improve-detached-head' into develop
This commit is contained in:
commit
f00f1ace4d
@ -17,7 +17,7 @@ def branch_name_from_config_file(directory, config_file):
|
|||||||
m = _ref_pat.match(raw)
|
m = _ref_pat.match(raw)
|
||||||
if m is not None:
|
if m is not None:
|
||||||
return m.group(1).decode('utf-8', 'replace')
|
return m.group(1).decode('utf-8', 'replace')
|
||||||
return '[DETACHED HEAD]'
|
return raw[:7]
|
||||||
|
|
||||||
def get_branch_name(base_dir):
|
def get_branch_name(base_dir):
|
||||||
head = os.path.join(base_dir, '.git', 'HEAD')
|
head = os.path.join(base_dir, '.git', 'HEAD')
|
||||||
|
@ -5,6 +5,7 @@ from powerline.lib.vcs import guess
|
|||||||
from subprocess import call, PIPE
|
from subprocess import call, PIPE
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
import re
|
||||||
from functools import partial
|
from functools import partial
|
||||||
from tests import TestCase, SkipTest
|
from tests import TestCase, SkipTest
|
||||||
|
|
||||||
@ -130,10 +131,17 @@ class TestVCS(TestCase):
|
|||||||
while time.time() - st < 1:
|
while time.time() - st < 1:
|
||||||
# Give inotify time to deliver events
|
# Give inotify time to deliver events
|
||||||
ans = repo.branch()
|
ans = repo.branch()
|
||||||
if ans == q:
|
if hasattr(q, '__call__'):
|
||||||
break
|
if q(ans):
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
if ans == q:
|
||||||
|
break
|
||||||
time.sleep(0.01)
|
time.sleep(0.01)
|
||||||
self.assertEqual(ans, q)
|
if hasattr(q, '__call__'):
|
||||||
|
self.assertTrue(q(ans))
|
||||||
|
else:
|
||||||
|
self.assertEqual(ans, q)
|
||||||
|
|
||||||
def test_git(self):
|
def test_git(self):
|
||||||
repo = guess(path=GIT_REPO)
|
repo = guess(path=GIT_REPO)
|
||||||
@ -167,7 +175,7 @@ class TestVCS(TestCase):
|
|||||||
call(['git', 'checkout', '-q', 'branch2'], cwd=GIT_REPO)
|
call(['git', 'checkout', '-q', 'branch2'], cwd=GIT_REPO)
|
||||||
self.do_branch_rename_test(repo, 'branch2')
|
self.do_branch_rename_test(repo, 'branch2')
|
||||||
call(['git', 'checkout', '-q', '--detach', 'branch1'], cwd=GIT_REPO)
|
call(['git', 'checkout', '-q', '--detach', 'branch1'], cwd=GIT_REPO)
|
||||||
self.do_branch_rename_test(repo, '[DETACHED HEAD]')
|
self.do_branch_rename_test(repo, lambda b: re.match(r'^[a-f0-9]+$', b))
|
||||||
|
|
||||||
if use_mercurial:
|
if use_mercurial:
|
||||||
def test_mercurial(self):
|
def test_mercurial(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user