Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Update patchcheck upstream remote verification behavior #135806

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 22, 2025

Conversation

kattni
Copy link
Contributor

@kattni kattni commented Jun 22, 2025

Currently, if you run patchcheck without a remote named upstream or origin, it fails with the following error:

TypeError: can only concatenate str (not "NoneType") to str

I ran into this during my first contribution, and it required viewing the source code for patchcheck to figure out what the issue was.

To avoid this for others in the future, I have updated the patchcheck get_git_upstream_remote() method to be more robust. The following changes have been implemented:

  • It now checks git remote -v.
  • It looks for remote URLs that include python/cpython and (fetch).
  • In the event that only one is found, it returns the name of that remote, regardless of the name.
  • In the event that multiple options are found, it looks for upstream, origin, and python, in that order, and returns the first one it finds.
  • In the event that none are found, it returns an informative error, including a link to the section of the Dev Guide relevant to creating an upstream remote, and lists the available fetch remotes.

Discussed with @ncoghlan prior to submitting this PR.

@ncoghlan ncoghlan self-assigned this Jun 22, 2025
@ncoghlan ncoghlan added type-bug An unexpected behavior, bug, or error skip issue skip news triaged The issue has been accepted as valid by a triager. needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes labels Jun 22, 2025
Copy link
Contributor

@ncoghlan ncoghlan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@ncoghlan
Copy link
Contributor

Running make patchcheck locally reminded me to update Misc/ACKS (@kattni I used "Kattni" based on your GH profile and website About page, so please let me know if you'd prefer a different entry)

@ncoghlan ncoghlan enabled auto-merge (squash) June 22, 2025 04:32
@kattni
Copy link
Contributor Author

kattni commented Jun 22, 2025

@ncoghlan Kattni is fine, thank you.

@ncoghlan ncoghlan merged commit ac9d37c into python:main Jun 22, 2025
40 checks passed
@miss-islington-app
Copy link

Thanks @kattni for the PR, and @ncoghlan for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jun 22, 2025
* find defined "(fetch)" remotes with "python/cpython" in their URL
* if there is exactly one, use that remote name
* if there is one named "upstream", "origin", or "python",
  use that remote (in that precedence order)
* otherwise report an error listing the defined remotes
(cherry picked from commit ac9d37c)

Co-authored-by: Kattni <[email protected]>
@bedevere-app
Copy link

bedevere-app bot commented Jun 22, 2025

GH-135808 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.14 bugs and security fixes label Jun 22, 2025
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jun 22, 2025
* find defined "(fetch)" remotes with "python/cpython" in their URL
* if there is exactly one, use that remote name
* if there is one named "upstream", "origin", or "python",
  use that remote (in that precedence order)
* otherwise report an error listing the defined remotes
(cherry picked from commit ac9d37c)

Co-authored-by: Kattni <[email protected]>
@bedevere-app
Copy link

bedevere-app bot commented Jun 22, 2025

GH-135809 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.13 bugs and security fixes label Jun 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip issue skip news triaged The issue has been accepted as valid by a triager. type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants