-
-
Notifications
You must be signed in to change notification settings - Fork 22
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
[IMP] intergrate gh tool #63
Conversation
167ddf7
to
aad9cce
Compare
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.
Thank you for this contribution. I did a comment
oca_port/app.py
Outdated
token = False | ||
if os.environ.get("GITHUB_TOKEN"): | ||
token = os.environ["GITHUB_TOKEN"] | ||
else: | ||
token = self.github_token | ||
if not token: | ||
try: | ||
# get from gh | ||
token = subprocess.check_output( | ||
["gh", "auth", "token"], text=True | ||
).strip() | ||
except subprocess.SubprocessError: | ||
pass |
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 code doesn't match the explanation in README: it takes in priority the token from env, then from the parameter, and from gh
. I propose the following to give the priority to the parameter first, then env, and gh
:
token = False | |
if os.environ.get("GITHUB_TOKEN"): | |
token = os.environ["GITHUB_TOKEN"] | |
else: | |
token = self.github_token | |
if not token: | |
try: | |
# get from gh | |
token = subprocess.check_output( | |
["gh", "auth", "token"], text=True | |
).strip() | |
except subprocess.SubprocessError: | |
pass | |
token = self.github_token | |
if not token: | |
token = os.environ.get("GITHUB_TOKEN") | |
if not token: | |
try: | |
# get from gh | |
token = subprocess.check_output( | |
["gh", "auth", "token"], text=True | |
).strip() | |
except subprocess.SubprocessError: | |
pass |
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.
We could even consolidate this token resolution in a dedicated method
aad9cce
to
92dd5c4
Compare
92dd5c4
to
45b117c
Compare
45b117c
to
64c5ea7
Compare
@trisdoan ready to merge? |
Thank you for this contribution, really appreciated |
No description provided.