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

Make github usernames optional #73

Merged
merged 2 commits into from
Sep 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions github_resolver/send_pull_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def make_commit(repo_dir: str, issue: GithubIssue) -> None:
def send_pull_request(
github_issue: GithubIssue,
github_token: str,
github_username: str,
github_username: str | None,
patch_dir: str,
pr_type: str,
fork_owner: str | None = None,
Expand Down Expand Up @@ -163,9 +163,10 @@ def send_pull_request(
push_owner = fork_owner if fork_owner else github_issue.owner
push_repo = github_issue.repo

username_and_token = f"{github_username}:{github_token}" if github_username else github_token
push_command = (
f"git -C {patch_dir} push "
f"https://{github_username}:{github_token}@github.com/"
f"https://{username_and_token}@github.com/"
f"{push_owner}/{push_repo}.git {branch_name}"
)
result = subprocess.run(push_command, shell=True, capture_output=True, text=True)
Expand Down Expand Up @@ -315,11 +316,7 @@ def process_all_successful_issues(
if my_args.github_username
else os.getenv("GITHUB_USERNAME")
)
if not github_username:
raise ValueError(
"Github username is not set, set via --github-username or GITHUB_USERNAME environment variable."
)


if not os.path.exists(my_args.output_dir):
raise ValueError(f"Output directory {my_args.output_dir} does not exist.")

Expand Down