-
Notifications
You must be signed in to change notification settings - Fork 44
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
fix: accept tokenless value from branch instead of env var #475
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,15 +53,21 @@ def send_commit_data( | |
enterprise_url, | ||
args, | ||
): | ||
# this is how the CLI receives the username of the user to whom the fork belongs | ||
# to and the branch name from the action | ||
tokenless = os.environ.get("TOKENLESS") | ||
if tokenless: | ||
headers = None # type: ignore | ||
branch = tokenless # type: ignore | ||
logger.info("The PR is happening in a forked repo. Using tokenless upload.") | ||
# Old versions of the GHA use this env var instead of the regular branch | ||
# argument to provide an unprotected branch name | ||
if tokenless := os.environ.get("TOKENLESS"): | ||
branch = tokenless | ||
|
||
if branch and ":" in branch: | ||
logger.info(f"Creating a commit for an unprotected branch: {branch}") | ||
elif token is None: | ||
logger.warning( | ||
f"Branch `{branch}` is protected but no token was provided\nFor information on Codecov upload tokens, see https://docs.codecov.com/docs/codecov-tokens" | ||
) | ||
else: | ||
headers = get_token_header(token) | ||
logger.info("Using token to create a commit for protected branch `{branch}`") | ||
|
||
headers = get_token_header(token) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. apparently the GHA pulls the latest so i guess we should still read from the env var, and i think logs would be valuable if they get printed to the user so they can see hints that maybe their branch name is not what they expected
|
||
|
||
data = { | ||
"branch": branch, | ||
|
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.
branch = os.environ.get("TOKENLESS", None) could have worked too
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.
that would clobber whatever was already in
branch
. we want that value, unless there is a value in$TOKENLESS
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.
@matt-codecov ahhh that's a good point