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

fix: handle if ORGANIZATION not provided #32

Merged

Conversation

jmeridth
Copy link
Member

@jmeridth jmeridth commented Mar 13, 2024

Fixes #27

Pull Request

Proposed Changes

Use each repo's org from REPOSITORY list if ORGANIZTION not provided

This makes sense because the repositories in REPOSITORY could have different organizations

  • utilize repo's owner/org when ORGANIZTION not provided
  • show the prefixed org is set when parsing REPOSITORY env var
  • update make lint to include black
    • add black to requirements-test.txt

We might want additional testing, up to @zkoppert.

Readiness Checklist

Author/Contributor

  • If documentation is needed for this change, has that been included in this pull request
  • run make lint and fix any issues that you have introduced
  • run make test and ensure you have test coverage for the lines you are introducing

Reviewer

  • Label as either bug, documentation, enhancement, infrastructure, or breaking

Fixes github#27

Use each repo's org from REPOSITORY list if ORGANIZTION not provided

This makes sense because the repositories in REPOSITORY could have
different organizations

- [x] utilize repo's owner/org  when ORGANIZTION not provided
- [x] show the prefixed org is set when parsing REPOSITORY env var
- [ ] additional testing

Signed-off-by: jmeridth <jmeridth@gmail.com>
@jmeridth jmeridth requested a review from zkoppert as a code owner March 13, 2024 09:48
@zkoppert zkoppert added the bug Something isn't working label Mar 13, 2024
`black` linting

Signed-off-by: jmeridth <jmeridth@gmail.com>
cleanowners.py Outdated Show resolved Hide resolved
when the user provides the org in the org/repo comman
delimited list of REPOSITORY env var, we still need
to validate that the org is an org and not a user

Signed-off-by: jmeridth <jmeridth@gmail.com>
Signed-off-by: jmeridth <jmeridth@gmail.com>
@jmeridth
Copy link
Member Author

image

Copy link
Member

@zkoppert zkoppert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

cleanowners.py Outdated
Comment on lines 46 to 48
if not gh_org:
print(f"Organization {organization} not found")
return
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me know if I'm reading this incorrectly, but wouldn't this if statement end the program if organization is not set and therefor gh_org returns null?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although the test that passes in only a repository list and a organization=None passes so maybe that means I'm wrong here. 🤷🏻

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll double check it. Thank you for asking.

Copy link
Member Author

@jmeridth jmeridth Mar 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zkoppert yes, it would. I was being presumptuous.

The combinatorics on this based on the code:

  • (ORGANIZATION and REPOSITORY provided) or (ORGANIZATION not provided and REPOSITORY provided)

    • the repository list from REPOSITORY is used
  • ORGANIZATION provided and REPOSITORY not provided

    • we use repositories related to the ORAGANIZATION if the organization is valid
    • if organization invalid throw error and exit
  • ORGANIZATION not provided and REPOSITORY not provided

    • throw error telling user, handled in environment variable parsing.

In situation 2, if the ORGANIZATION proves to not be an actual ORGANIZATION, we should exit the app, correct?

working on a coding change. Great catch @zkoppert

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pushed up new change to do better checking (I hope). Added new test for the get_org function, when org invalid. Also added black linter to make lint 😄

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, Your summary above makes sense and is how we want it to work. I'll take a peek at the code now.

Signed-off-by: jmeridth <jmeridth@gmail.com>
- [x] check if org valid and if REPOSITORY set instead
- [x] update `make lint` to include black
  - [x] add black to requirements-test.txt

Signed-off-by: jmeridth <jmeridth@gmail.com>
Makefile Show resolved Hide resolved
Signed-off-by: jmeridth <jmeridth@gmail.com>
Copy link
Member

@zkoppert zkoppert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@zkoppert zkoppert merged commit 211ccef into github:main Mar 15, 2024
4 checks passed
@jmeridth jmeridth deleted the jm-handle-organization-env-var-requirement branch March 15, 2024 17:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ORGANIZATION is always required
2 participants