diff --git a/cherry_picker/cherry_picker/cherry_picker.py b/cherry_picker/cherry_picker/cherry_picker.py index abf37b7..0d15662 100755 --- a/cherry_picker/cherry_picker/cherry_picker.py +++ b/cherry_picker/cherry_picker/cherry_picker.py @@ -422,7 +422,7 @@ def get_base_branch(cherry_pick_branch): """ return '2.7' from 'backport-sha-2.7' """ - prefix, sep, base_branch = cherry_pick_branch.rpartition('-') + prefix, sha, base_branch = cherry_pick_branch.split('-', 2) return base_branch diff --git a/cherry_picker/cherry_picker/test.py b/cherry_picker/cherry_picker/test.py index c5d8615..2fcfd57 100644 --- a/cherry_picker/cherry_picker/test.py +++ b/cherry_picker/cherry_picker/test.py @@ -33,15 +33,16 @@ def changedir(d): def test_get_base_branch(): + # The format of cherry-pick branches we create are "backport-{SHA}-{base_branch}" cherry_pick_branch = 'backport-afc23f4-2.7' result = get_base_branch(cherry_pick_branch) assert result == '2.7' -def test_get_base_branch_without_dash(): - cherry_pick_branch ='master' +def test_get_base_branch_which_has_dashes(): + cherry_pick_branch ='backport-afc23f4-baseprefix-2.7-basesuffix' result = get_base_branch(cherry_pick_branch) - assert result == 'master' + assert result == 'baseprefix-2.7-basesuffix' @mock.patch('subprocess.check_output')
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: