Skip to content

Get-GitHubRepository doesnt show private repository. #178

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

Closed
Alex-0293 opened this issue May 25, 2020 · 8 comments · Fixed by #179
Closed

Get-GitHubRepository doesnt show private repository. #178

Alex-0293 opened this issue May 25, 2020 · 8 comments · Fixed by #179
Labels
bug This relates to a bug in the existing module. support User support questions

Comments

@Alex-0293
Copy link

Alex-0293 commented May 25, 2020

Hello,
I want to get all my repository.
Get-GitHubRepository -Visibility All -Type All -OwnerName "Alex-0293"
This show only public repository, instead of all.
But i can see my private repository with
Get-GitHubRepository -Visibility All -Type All -OwnerName "Alex-0293" -RepositoryName "GitProjectClone".

@HowardWolosky
Copy link
Member

You want to call:

Get-GitHubRepository -Visibility All

(without OwnerName). Per the API documentation, the only API where you can specify Visibility is for the current authenticated user (thus, you don't specify UserName). Additionally, if you use that API, you can't specify both Visibility and Type in the same request. Doing so will result in a 422.

Looks like Get-GitHubRepository needs to be cleaned up a bit (either with better ParameterSets or internal error checking) to prevent usage like yours above.

Thanks for calling attention to this.

@HowardWolosky HowardWolosky added the bug This relates to a bug in the existing module. label May 25, 2020
@HowardWolosky
Copy link
Member

To be clear, when you called the API like this: Get-GitHubRepository -Visibility All -Type All -OwnerName "Alex-0293", you were actually calling this API which can only display public repositories. You can verify this for yourself by either looking at your PowerShellForGitHub.log file, or by calling it again and specifying -Verbose as part of the request.

@Alex-0293
Copy link
Author

Alex-0293 commented May 25, 2020

Thank you for answer.
May be i dont understand, but i have the same results.
Get-GitHubRepository -Visibility All -verbose

VERBOSE: [0.13.1] Executing: Get-GitHubRepository -Visibility "All" -Verbose:$true
VERBOSE: Getting repos for Alex-0293
VERBOSE: Accessing [Get] https://api.github.com/users/Alex-0293/repos?visibility=all [Timeout = 0)]
VERBOSE: Telemetry has been disabled via configuration. Skipping reporting event [Get-GitHubRepository].

Get-GitHubRepository -Visibility All -OwnerName "Alex-0293" -verbose

VERBOSE: [0.13.1] Executing: Get-GitHubRepository -Visibility "All" -OwnerName "Alex-0293" -Verbose:$true
VERBOSE: Getting repos for Alex-0293
VERBOSE: Accessing [Get] https://api.github.com/users/Alex-0293/repos?visibility=all [Timeout = 0)]
VERBOSE: Telemetry has been disabled via configuration. Skipping reporting event [Get-GitHubRepository].

@HowardWolosky
Copy link
Member

My guess is you configured a default owner name.
What does this return:
Get-GitHubConfiguration -Name DefaultOwnerName?
If you configured that, then it's pre-filling in OwnerName, and thus it has the same result.

@Alex-0293
Copy link
Author

Thank you!
You are absolutely right.
Now its work as expected.

@HowardWolosky
Copy link
Member

Leaving this open, because the function should not have permitted that combination of parameters without an error. Should have a fix out soon.

@HowardWolosky HowardWolosky reopened this May 25, 2020
@HowardWolosky HowardWolosky added the support User support questions label May 25, 2020
HowardWolosky added a commit to HowardWolosky/PowerShellForGitHub that referenced this issue May 25, 2020
There were a few problems with this function:
* -GetAllPublicRepositories didn't actually work.  That's now been fixed,
  and support for the optional Since paramater has been added as well.
* Fixed the ParameterSet handling for all of the parameters to make sure
  that users can only specify parameters relevant with the appropriate
  parameter set given that there are five different use cases for this
  method:
     * Getting repos for the current authenticated user
     * Getting repos for any GitHub user
     * Getting repos for an organization
     * Getting all public repos)
     * Getting a specific GitHub repo

Resolves microsoft#178
HowardWolosky added a commit to HowardWolosky/PowerShellForGitHub that referenced this issue May 25, 2020
There were a few problems with this function:
* -GetAllPublicRepositories didn't actually work.  That's now been fixed,
  and support for the optional Since paramater has been added as well.
* Fixed the ParameterSet handling for all of the parameters to make sure
  that users can only specify parameters relevant with the appropriate
  parameter set given that there are five different use cases for this
  method:
     * Getting repos for the current authenticated user
     * Getting repos for any GitHub user
     * Getting repos for an organization
     * Getting all public repos)
     * Getting a specific GitHub repo

Resolves microsoft#178
HowardWolosky added a commit that referenced this issue May 25, 2020
There were a few problems with this function:
* -GetAllPublicRepositories didn't actually work.  That's now been fixed,
  and support for the optional Since paramater has been added as well.
* Fixed the ParameterSet handling for all of the parameters to make sure
  that users can only specify parameters relevant with the appropriate
  parameter set given that there are five different use cases for this
  method:
     * Getting repos for the current authenticated user
     * Getting repos for any GitHub user
     * Getting repos for an organization
     * Getting all public repos)
     * Getting a specific GitHub repo

Resolves #178
@HowardWolosky
Copy link
Member

@jbostoen - You posted an additional comment to this Issue this morning, reporting that the problem wasn't resolved for you, but then you deleted the comment. Presumably you figured out the problem. However, it would be helpful to keep that in here in case others come across the same problem and want to know what the solution was.

This was your original comment:

Using v15.0.1 of this module; calling
Get-GitHubRepository -Visibility All
Still only shows my public repositories and not the private ones.
What am I missing? Is configuration required?
I tried adding default owner name; which seems to be correct if I try Get-GitHubConfiguration -Name DefaultOwnerName

Configuration is not required. In fact, even if you were to specify a default owner name, it would not be used.
You can't query for private repositories of other users. By the very nature of them being private, you can only query for them if they are yours. That's why the Visibility parameter for Get-GitHubRepository doesn't work when a UserName has been specified... It's a parameter that only works against the current authenticated user account.

So, while configuration isn't required, authentication is. If it wasn't working for you, it's most likely because you had not yet authenticated with GitHub via Set-GitHubAuthentication.

@jbostoen
Copy link

jbostoen commented Oct 27, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This relates to a bug in the existing module. support User support questions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants