diff --git a/.pick_status.json b/.pick_status.json index d2e8d6a1162..53006df44ff 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -58,7 +58,7 @@ "description": "commit_in_branch.py: add support for checking staging branches", "nominated": true, "nomination_type": 0, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": null }, diff --git a/bin/commit_in_branch.py b/bin/commit_in_branch.py index e4e2edb50ab..36ee7a9795e 100755 --- a/bin/commit_in_branch.py +++ b/bin/commit_in_branch.py @@ -62,7 +62,7 @@ def branch_has_backport_of_commit(upstream: str, branch: str, commit: str) -> st or an empty string if is hasn't """ out = subprocess.check_output(['git', 'log', '--format=%H', - branch + '-branchpoint..' + upstream + '/' + branch, + upstream + '..' + upstream + '/' + branch, '--grep', 'cherry picked from commit ' + commit], stderr=subprocess.DEVNULL) return out.decode().strip() @@ -89,7 +89,7 @@ def validate_branch(branch: str) -> str: out = subprocess.check_output(['git', 'remote', '--verbose'], stderr=subprocess.DEVNULL) remotes = out.decode().splitlines() - (upstream, _) = branch.split('/') + upstream, _ = branch.split('/', 1) valid_remote = False for line in remotes: if line.startswith(upstream + '\t'): @@ -125,7 +125,7 @@ if __name__ == "__main__": help='colorize output (default: true if stdout is a terminal)') args = parser.parse_args() - (upstream, branch) = args.branch.split('/') + upstream, branch = args.branch.split('/', 1) if branch_has_commit(upstream, branch, args.commit): print_(args, True, 'Commit ' + args.commit + ' is in branch ' + branch) diff --git a/bin/commit_in_branch_test.py b/bin/commit_in_branch_test.py index d6033ec8e9d..52be960165c 100644 --- a/bin/commit_in_branch_test.py +++ b/bin/commit_in_branch_test.py @@ -46,6 +46,7 @@ def test_canonicalize_commit(commit: str, expected: bool) -> None: 'commit, expected', [ (get_upstream() + '/20.1', True), + (get_upstream() + '/staging/20.1', True), (get_upstream() + '/main', True), ('20.1', False), ('main', False), @@ -73,6 +74,7 @@ def test_validate_branch(commit: str, expected: bool) -> None: ('20.1-branchpoint', True), ('20.1', False), (get_upstream() + '/20.1', True), + (get_upstream() + '/staging/20.1', True), ('e58a10af640ba58b6001f5c5ad750b782547da76', True), ('d043d24654c851f0be57dbbf48274b5373dea42b', True), ('dd2bd68fa69124c86cd008b256d06f44fab8e6cd', True), @@ -91,6 +93,7 @@ def test_is_commit_valid(commit: str, expected: bool) -> None: ('20.1', 'main', False), ('20.1', 'e58a10af640ba58b6001f5c5ad750b782547da76', True), ('20.1', 'd043d24654c851f0be57dbbf48274b5373dea42b', True), + ('staging/20.1', 'd043d24654c851f0be57dbbf48274b5373dea42b', True), ('20.1', 'dd2bd68fa69124c86cd008b256d06f44fab8e6cd', False), ('main', 'dd2bd68fa69124c86cd008b256d06f44fab8e6cd', True), ('20.0', 'd043d24654c851f0be57dbbf48274b5373dea42b', False), @@ -104,6 +107,7 @@ def test_branch_has_commit(branch: str, commit: str, expected: bool) -> None: 'branch, commit, expected', [ ('20.1', 'dd2bd68fa69124c86cd008b256d06f44fab8e6cd', 'd043d24654c851f0be57dbbf48274b5373dea42b'), + ('staging/20.1', 'dd2bd68fa69124c86cd008b256d06f44fab8e6cd', 'd043d24654c851f0be57dbbf48274b5373dea42b'), ('20.1', '20.1-branchpoint', ''), ('20.1', '20.0', ''), ('20.1', '20.2', ''),