Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 5ffb9e7

Browse filesBrowse files
committed
Validate that the branch name sha is present as a commit hash
1 parent b42b8a9 commit 5ffb9e7
Copy full SHA for 5ffb9e7

File tree

Expand file treeCollapse file tree

1 file changed

+9
-1
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+9
-1
lines changed

‎cherry_picker/cherry_picker/cherry_picker.py

Copy file name to clipboardExpand all lines: cherry_picker/cherry_picker/cherry_picker.py
+9-1Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,8 +421,16 @@ def get_base_branch(cherry_pick_branch):
421421

422422
if prefix != 'backport':
423423
raise ValueError('branch name is not prefixed with "backport-". Is this a cherry_picker branch?')
424+
424425
if not re.match('[0-9a-f]{7,40}', sha):
425-
raise ValueError('branch name has an invalid sha')
426+
raise ValueError(f'branch name has an invalid sha: {sha}')
427+
428+
cmd = ['git', 'log', '-r', sha]
429+
try:
430+
subprocess.check_output(cmd, stderr=subprocess.STDOUT)
431+
except subprocess.SubprocessError:
432+
raise ValueError(f'The sha listed in the branch name, {sha}, is not present in the repository')
433+
426434
# Subject the parsed base_branch to the same tests as when we generated it
427435
# This throws a ValueError if the base_branch doesn't need our requirements
428436
version_from_branch(base_branch)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.