diff --git a/cherry_picker/cherry_picker/cherry_picker.py b/cherry_picker/cherry_picker/cherry_picker.py index 91166fe..c37b300 100755 --- a/cherry_picker/cherry_picker/cherry_picker.py +++ b/cherry_picker/cherry_picker/cherry_picker.py @@ -390,9 +390,9 @@ def get_current_branch(): def get_full_sha_from_short(short_sha): - cmd = f"git show --format=raw {short_sha}" + cmd = f"git log -1 --format='%H' {short_sha}" output = subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT) - full_sha = output.strip().decode('utf-8').split('\n')[0].split()[1] + full_sha = output.strip().decode('utf-8') return full_sha diff --git a/cherry_picker/cherry_picker/test.py b/cherry_picker/cherry_picker/test.py index 33f241d..ee56569 100644 --- a/cherry_picker/cherry_picker/test.py +++ b/cherry_picker/cherry_picker/test.py @@ -28,19 +28,7 @@ def test_get_current_branch(subprocess_check_output): @mock.patch('subprocess.check_output') def test_get_full_sha_from_short(subprocess_check_output): - mock_output = b"""commit 22a594a0047d7706537ff2ac676cdc0f1dcb329c -tree 14ab2ea85e7a28adb9d40f185006308d87a67f47 -parent 5908300e4b0891fc5ab8bd24fba8fac72012eaa7 -author Armin Rigo 1492106895 +0200 -committer Mariatta 1492106895 -0700 - - bpo-29694: race condition in pathlib mkdir with flags parents=True (GH-1089) - -diff --git a/Lib/pathlib.py b/Lib/pathlib.py -index fc7ce5e..1914229 100644 ---- a/Lib/pathlib.py -+++ b/Lib/pathlib.py -""" + mock_output = b"""22a594a0047d7706537ff2ac676cdc0f1dcb329c""" subprocess_check_output.return_value = mock_output assert get_full_sha_from_short('22a594a') == '22a594a0047d7706537ff2ac676cdc0f1dcb329c'