Skip to content
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

Merged
merged 1 commit into from
Dec 20, 2024
Merged

[IMP] intergrate gh tool #63

merged 1 commit into from
Dec 20, 2024

Conversation

trisdoan
Copy link
Contributor

@trisdoan trisdoan commented Dec 11, 2024

No description provided.

@trisdoan trisdoan marked this pull request as draft December 11, 2024 04:26
@trisdoan trisdoan marked this pull request as ready for review December 16, 2024 06:17
@trisdoan trisdoan changed the title [WIP][IMP] intergrate gh tool [IMP] intergrate gh tool Dec 16, 2024
Copy link
Collaborator

@sebalix sebalix left a 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
Comment on lines 113 to 125
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
Copy link
Collaborator

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:

Suggested change
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

Copy link
Collaborator

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

@sebalix sebalix added this to the 0.18 milestone Dec 20, 2024
@sebalix
Copy link
Collaborator

sebalix commented Dec 20, 2024

@trisdoan ready to merge?

@sebalix
Copy link
Collaborator

sebalix commented Dec 20, 2024

Thank you for this contribution, really appreciated

@sebalix sebalix merged commit 5940f95 into OCA:main Dec 20, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants