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

Allow mirroring private org repositories #19

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

simonhammes
Copy link

The /users/{username}/repos endpoint does not return private org repositories.
The /search/repositories endpoint has to be used instead.

Related: https://github.com/orgs/community/discussions/24382

The /users/{username}/repos endpoint does not return private org repositories.
The /search/repositories endpoint has to be used instead.

Related: https://github.com/orgs/community/discussions/24382
@christophdb
Copy link

It is important to mention, that a new env variable is used: "GITHUB_ORG" instead of "GITHUB_USERNAME".
Works like a charm.

@jdevera
Copy link
Contributor

jdevera commented Jul 31, 2024

(not a maintainer, just a lurker)
This is cool! Why are the user and org settings mutually exclusive, though?

@jaedle
Copy link
Owner

jaedle commented Aug 18, 2024

Hey 👋

First of all thank your very much for your contribution!
Nice catch, never noticed that (not working with private repos on orgs).

Is there any specific reason we could not use the current environment variable and determine if the configured username is an org or user?

A call to the user lookup by id should reveal whether the configured user is an organisation or a regular github user, so we could use this to adjust the behavior.

@jaedle jaedle self-assigned this Aug 18, 2024
@simonhammes simonhammes force-pushed the allow-mirroring-org-repositories branch from bd59105 to bec14fb Compare September 9, 2024 10:44
@simonhammes
Copy link
Author

Is there any specific reason we could not use the current environment variable and determine if the configured username is an org or user?

A call to the user lookup by id should reveal whether the configured user is an organisation or a regular github user, so we could use this to adjust the behavior.

Thanks for the hint, I just pushed some changes to use this approach.

The code now also supports MIRROR_PRIVATE_REPOSITORIES and modifies the query based on its value.

PS: Hide whitespace makes reviewing a bit easier

@jaedle
Copy link
Owner

jaedle commented Sep 24, 2024

Thanks for your contribution 🙏
I will review this ASAP

@jaedle
Copy link
Owner

jaedle commented Sep 24, 2024

I just had a look at he proposed changes. They look perfectly fine. Sadly the complexity of the method to get the repositories in addition with current pending changes seem to increase radically.

Due to that, I would love to do a refactoring and add tests for this particular part of the tool. Otherwise future requirements are likely to break existing functionality and I know that some people are using that in production.

If you are fine with that, I would love to use your proposed changes as blueprint to build the functionality test-driven after the refactoring.

Does that sound fine to you?

@simonhammes
Copy link
Author

Due to that, I would love to do a refactoring and add tests for this particular part of the tool. Otherwise future requirements are likely to break existing functionality and I know that some people are using that in production.

That makes sense

Does that sound fine to you?

Sure, go ahead 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants