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

PRs not created after successful message #2

Open
benlee0423 opened this issue Jan 6, 2025 · 5 comments
Open

PRs not created after successful message #2

benlee0423 opened this issue Jan 6, 2025 · 5 comments
Assignees

Comments

@benlee0423
Copy link

Short description explaining the high-level reason for the new issue.

Current behavior

Commands run

python3 -m venv .venv
source .venv/
source .venv/bin/activate
python3 -m pip install PyGithub
python3 -m repository_management_bot CIROH-UA CIROH-open-source-project-template NGIAB-HPCInfra

Messages below after the last command.

Changes made:
 - Added [.gitattributes](https://github.com/CIROH-UA/NGIAB-HPCInfra/tree/repository_management_bot/template_compliance/.gitattributes)
 - Added [ISSUE_TEMPLATE.md](https://github.com/CIROH-UA/NGIAB-HPCInfra/tree/repository_management_bot/template_compliance/.github/ISSUE_TEMPLATE.md)
 - Added [PULL_REQUEST_TEMPLATE.md](https://github.com/CIROH-UA/NGIAB-HPCInfra/tree/repository_management_bot/template_compliance/.github/PULL_REQUEST_TEMPLATE.md)
 - Added [.gitignore](https://github.com/CIROH-UA/NGIAB-HPCInfra/tree/repository_management_bot/template_compliance/.gitignore)
 - Added [CHANGELOG.md](https://github.com/CIROH-UA/NGIAB-HPCInfra/tree/repository_management_bot/template_compliance/CHANGELOG.md)
 - Added [CONTRIBUTING.md](https://github.com/CIROH-UA/NGIAB-HPCInfra/tree/repository_management_bot/template_compliance/CONTRIBUTING.md)
 - Added [INSTALL.md](https://github.com/CIROH-UA/NGIAB-HPCInfra/tree/repository_management_bot/template_compliance/INSTALL.md)
 - Added [LICENSE](https://github.com/CIROH-UA/NGIAB-HPCInfra/tree/repository_management_bot/template_compliance/LICENSE)
 - Added [SECURITY.md](https://github.com/CIROH-UA/NGIAB-HPCInfra/tree/repository_management_bot/template_compliance/SECURITY.md)
 - Added [TERMS.md](https://github.com/CIROH-UA/NGIAB-HPCInfra/tree/repository_management_bot/template_compliance/TERMS.md)
 - Added [open_source_template.sh](https://github.com/CIROH-UA/NGIAB-HPCInfra/tree/repository_management_bot/template_compliance/open_source_template.sh)
 - Added [opensource-checklist.md](https://github.com/CIROH-UA/NGIAB-HPCInfra/tree/repository_management_bot/template_compliance/opensource-checklist.md)

This PR was automatically generated by the [Repository Management Bot](https://github.com/chp2001/repository-management-bot).
--------------------------------------------------------------------------------
Create PR? (y/N): y
PRs created for 1 repos
[Repository(full_name="CIROH-UA/NGIAB-HPCInfra")]

Expected behavior

Steps to replicate behavior (include URLs)

Explained in the behavior

Screenshots

Screenshot 2025-01-05 at 9 23 12 PM
@chp2001
Copy link
Owner

chp2001 commented Jan 6, 2025

Behavior is unexpected, but not exactly incorrect or erroneous?

Here is the relevant line for when it would retrieve a branch created by someone else, but with the desired name:

branch = target_loc.get_branch(branch_name)

Here is the relevant line for when it would retrieve a PR created by someone else:

My test PR on the same repository is likely being retrieved due to the name being the same as the one the program was going to create.

@chp2001 chp2001 self-assigned this Jan 6, 2025
@chp2001
Copy link
Owner

chp2001 commented Jan 6, 2025

Now, the question is going to be: How do we want this to be solved?

We likely don't want potentially hundreds of duplicate branches and PRs being created when the program is run on different accounts, but we also want to be able to test it without creating or involving more repositories.

I can add a clause to the PR if statement that checks if the user is the author:

# get the current session user
user = get_user()
for pr in prs:
    if pr.head.ref == PR_branch.name and pr.user.login == user.login:
        print(f"PR already exists: {pr.html_url}")
        pr.edit(title=PR_title, body=PR_body)
        return pr

However, given the potential duplication issue, we can use a command line argument to have this behavior be adjustable, like so:

# get the current session user
user = get_user()
for pr in prs:
    if pr.head.ref == PR_branch.name:
        if GLOBAL_FLAGS["require-distinct"] and not pr.user.login == user.login:
            continue
        print(f"PR already exists: {pr.html_url}")
        pr.edit(title=PR_title, body=PR_body)
        return pr

The default value for the flag would likely be false, and require someone to specifically include the --require-distinct argument in running the program.

Additionally, assuming we want distinct branches and PRs, we could take the route of changing the naming scheme:

branch_name = "repository_management_bot/template_compliance"

->

user = get_user()
branch_name = f"repository_management_bot/{user.login}/template_compliance"

(This, or some other method to differentiate the name, would likely be required to facilitate distinct branches, forks, and PRs)

What are your thoughts/requirements? @benlee0423

@chp2001
Copy link
Owner

chp2001 commented Jan 6, 2025

Regardless of the route we take, I believe we need to include print statements in the decision tree, so the user is aware of when steps are skipped.

Before anything else, I will handle that, so we have the option of verifying that my understanding of the problem is correct.

@chp2001
Copy link
Owner

chp2001 commented Jan 6, 2025

Problems with logging and some edge cases mitigated with commit cccdee7.

@benlee0423
Copy link
Author

@chp2001
These are my assumptions.

  1. PR name really does not matter, because it is tracked by PR number.
  2. This bot should be running only from internally, no need to worry about being created so many same PRs.

The issue here is it said PRs created for 1 repos, but no PRs is created on the target repository and no error message on that. https://github.com/CIROH-UA/NGIAB-HPCInfra/pulls

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

No branches or pull requests

2 participants