@stas Ok, here is my attempt to fix the issue with the token!
Basically, I am just doing the following to communicate with GitHub without creds:
if args.auth == 'ssh':
args.prefix = 'git@github.com:'
else:
check_token()
args.token = os.environ[ENV_VAR]
args.prefix = f'https://{args.token}@github.com/'
And this, to run a curl command:
check_curl_is_available()
creds = user if args.auth == 'ssh' else f'{user}:{args.token}'
run(f"curl -u {creds} https://api.github.com/repos/{orig}/{repo}/forks -d ''")
Also, the notification is shown if GITHUB_TOKEN
env variable is not set and the execution is terminated. Could you please check if my changes make sense? I’ve tested locally, and it seems to work more or less smoothly. (Though I am going to check some additional edge cases as well). Please let me know if we need to fix something else here. I’ll have time next days so we can make iterations faster without waiting for weeks
In addition, as you’ve previously proposed, probably we can modify the argparse
CLI a bit to accept positional arguments with default values to make this tool more generic.
@Benudek I am not sure why the script wasn’t setting up the upstream. We have the following function in the snippet:
def set_upstream(branch):
print(f"\n\n*** Set this {branch}'s upstream to simplify push and alikes")
run(f'git push --set-upstream origin {branch}')
And when I was testing this, it has shown me the message:
*** Set this my-fancy-feature-branch's upstream to simplify push and alikes
running: git push --set-upstream origin my-fancy-feature-branch
Branch 'my-fancy-feature-branch' set up to track remote branch 'my-fancy-feature-branch' from 'origin'.
So it seems the --set-upstream
is somewhat working. However, probably I just can’t reproduce the error you had, or maybe we’re running the snippet on different OS’es?