Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Fix ``make patchcheck`` not finding the upstream remote in a partial clone,
where ``git remote -v`` appends the object filter (for example
``[blob:none]``) after ``(fetch)``.
14 changes: 9 additions & 5 deletions Tools/patchcheck/patchcheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,20 +68,24 @@ def get_git_upstream_remote():
cwd=SRCDIR,
encoding="UTF-8"
)
# Keep the "(fetch)" lines only. A partial clone lists its filter after
# the URL type, e.g. "upstream\thttps://github.com/python/cpython (fetch)
# [blob:none]", so "(fetch)" is not necessarily at the end of the line.
fetch_remotes = [
remote for remote in output.split('\n') if "(fetch)" in remote
]
# Filter to desired remotes, accounting for potential uppercasing
filtered_remotes = {
remote.split("\t")[0].lower() for remote in output.split('\n')
if "python/cpython" in remote.lower() and remote.endswith("(fetch)")
remote.split("\t")[0].lower() for remote in fetch_remotes
if "python/cpython" in remote.lower()
}
if len(filtered_remotes) == 1:
[remote] = filtered_remotes
return remote
for remote_name in ["upstream", "origin", "python"]:
if remote_name in filtered_remotes:
return remote_name
remotes_found = "\n".join(
{remote for remote in output.split('\n') if remote.endswith("(fetch)")}
)
remotes_found = "\n".join(fetch_remotes)
raise ValueError(
f"Patchcheck was unable to find an unambiguous upstream remote, "
f"with URL matching 'https://github.com/python/cpython'. "
Expand Down
Loading