go-github icon indicating copy to clipboard operation
go-github copied to clipboard

Inconsistency in behavior of repo Private field when editing repo

Open murphyke opened this issue 2 years ago • 2 comments

Using github.com/google/go-github/v53 v53.2.0 against GitHub Enterprise Server 3.5.5, the following code was able to convert public repositories to private, but it did nothing in the case of internal repositories (there was no error, and the visibility level was unchanged):

	_, _, err := client.Repositories.Edit(ctx, *repo.Owner.Login, *repo.Name, &github.Repository{
		Private: github.Bool(true),
	})

In contrast, the alternative approach of setting the Visibility attribute to private worked for both public and internal repositories:

	_, _, err := client.Repositories.Edit(ctx, *repo.Owner.Login, *repo.Name, &github.Repository{
		Visibility: github.String("private"),
	})

go version go1.20.4 darwin/amd64

murphyke avatar Jul 06 '23 21:07 murphyke

Hmmm... you might prefer to contact GitHub v3 API technical support to report the inconsistency of behavior, as this is simply a client repo that makes it easier to make calls into the GitHub v3 API.

Please feel free to report back here what you find out from the official tech support team.

gmlewis avatar Jul 06 '23 21:07 gmlewis

OK, thanks, I kind of assumed that that sort of inconsistency would be unlikely to have persisted in the GitHub API, and I am too lazy to test the REST API directly.

murphyke avatar Jul 07 '23 13:07 murphyke