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

GHRespository.getTemplateRepository() should call populate() if null #2007

Open
kkroner8451 opened this issue Jan 14, 2025 · 0 comments
Open

Comments

@kkroner8451
Copy link

Describe the bug
A clear and concise description of what the bug is.

When calling the GitHub API to get a list of repositories the template_repository field is not included in the response. Thus if using this library to get a list of repositories (i.e. GHOrganization.listRepositories()) that field will always be null when mapped onto the GHRepository object constructed as introduced in PR#1817. Under a different proposal I saw PR#1579 it had a check

 if this.template_repository == null 
  populate()

This has its own performance concerns as there is no flag that populate() isn't called more than once which would happen if this was not a child of a template repository and the getTemplateRepository() method was called multiple times. All works as expected when getting a single repository via GitHub.getRepository() as the GitHub API includes the template_repository field in that case.

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error
GHRepositories[] repos = gitHub.getOrganization("SAMPLE").listRepositories(10);
for (GHRepository repo : repos){
  if (repo.getTemplateRepository() != null) {
   // BUG: This will never hit as underlying template_repository field isn't ever populated when using list vs single get methods
  doSomethingWithTemplate();
  }
}

Expected behavior
A clear and concise description of what you expected to happen.

I expect the GHRepository.getTemplateRepository() to return the value assuming the repo is a child of a template regardless of if it was originally constructed by a method to get the single repo (working) versus getting a list of repositories (not working) and believe making the delayed load populate() call as seen in other places is an established behavior that would be expected.

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

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

1 participant