-
-
Notifications
You must be signed in to change notification settings - Fork 60
Automatically create backport PR if oauth token is set #175
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
Conversation
- Provide instructions on how to generate the personal access token, and how to set it as an environment variable. - Add gidgethub and requests as dependencies.
python/cpython#3224 was created via this method, using my own personal access token. |
I have read the readme, but it is not clear to me what 'create automatically' means -- what will happen, when and where -- and what a token on my machine has to do with it. |
Thanks @terryjreedy. The idea is instead of opening a web browser where we have to click the 'Create pull request button', cherry picker will create the PR. So no web browser will be opened at all. The token is needed by GitHub API as a way to authenticate your GitHub account. |
Thanks for explaining. Since I like to have the PR open in my browser, and clicking the button is an easy way to get that, I will probably pass. |
No prob :) It's backward compatible, so the previous way still works as is. Potentially we can use this for the cherry-picking bot, where the backport will happen automatically after we merge the PR on |
cherry_picker/readme.rst
Outdated
Personal Access Token (optional) | ||
-------------------------------- | ||
|
||
``cherry_picker`` can automatically create the PR, if the ``GH_AUTH`` token is set |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this considered safe and best practice for storing an auth token like this? I honestly don't know, which is why I'm asking. 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really know 😅
This is really so I can use it for the cherry picker bot later.
Maybe I should keep this as hidden and secret functionality, and not mention it at all in the readme?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, either don't document it or be clear that one should be careful about how that environment variable is stored.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok I'm going with "not documenting it" since it's easier to do than coming up with warning messages 😅
I didn't expect the Spanish Inquisition! |
@@ -6,9 +6,13 @@ | |||
import subprocess | |||
import webbrowser | |||
import sys | |||
import requests | |||
|
|||
from gidgethub.sansio import create_headers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not important, but you shifted from importing modules to importing objects with this import line.
else: | ||
self.open_pr(self.get_pr_url(https://github.com/base_branch,%20head_branch)) | ||
|
||
def create_gh_pr(self, base_branch, head_branch, commit_message): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you're already checking for the envvar above, would it make sense to make it a required argument and just pass it in explicitly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I made the token a required argument.
@@ -8,7 +8,7 @@ | |||
import sys | |||
import requests | |||
|
|||
from gidgethub.sansio import create_headers | |||
import gidgethub |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should either be import gidgethub.sansio
or from gidgethub import sansio
; the fact that the package has an import is undocumented.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed tofrom gidgethub import sansio
else: | ||
self.open_pr(self.get_pr_url(https://github.com/base_branch,%20head_branch)) | ||
|
||
def create_gh_pr(self, base_branch, head_branch, commit_message): | ||
request_headers = create_headers(self.username, oauth_token=os.getenv("GH_AUTH")) | ||
def create_gh_pr(self, base_branch, head_branch, commit_message, gh_auth): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any worry the order of these arguments will be non-obvious? I.e. should any of them be keyword-only arguments?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, ok I made commit_message and gh_auth as keyword only arguments.
made commit_message and gh_auth keyword only args in create_gh_pr
gidgethub
andrequests
as dependencies.Closes #100