1
0
mirror of https://github.com/nvbn/thefuck.git synced 2025-01-18 12:06:04 +00:00

Change: rules_git_checkout handling branch names with slashes & Remote HEAD. (#944)

* Add: Test for branch names with slashes & Remote HEAD.

* - Add: Handling for removing remote HEAD.
- Change: Improved handling for branches with slash in their names.
This commit is contained in:
ik1ne 2019-09-03 02:16:40 +09:00 committed by Vladimir Iakovlev
parent 1683f45e94
commit 84c16fb69a
2 changed files with 9 additions and 2 deletions

View File

@ -39,6 +39,11 @@ def test_not_match(command):
(b'', []),
(b'* master', ['master']),
(b' remotes/origin/master', ['master']),
(b' remotes/origin/test/1', ['test/1']),
(b' remotes/origin/test/1/2/3', ['test/1/2/3']),
(b' test/1', ['test/1']),
(b' test/1/2/3', ['test/1/2/3']),
(b' remotes/origin/HEAD -> origin/master', []),
(b' just-another-branch', ['just-another-branch']),
(b'* master\n just-another-branch', ['master', 'just-another-branch']),
(b'* master\n remotes/origin/master\n just-another-branch',

View File

@ -18,10 +18,12 @@ def get_branches():
stdout=subprocess.PIPE)
for line in proc.stdout.readlines():
line = line.decode('utf-8')
if '->' in line: # Remote HEAD like b' remotes/origin/HEAD -> origin/master'
continue
if line.startswith('*'):
line = line.split(' ')[1]
if '/' in line:
line = line.split('/')[-1]
if line.strip().startswith('remotes/'):
line = '/'.join(line.split('/')[2:])
yield line.strip()