-
Notifications
You must be signed in to change notification settings - Fork 48
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
Replace duplicated IsEnterprise and IsTenancy functions in api pkg with auth pkg #173
Conversation
There were duplicated, unexported isEnterprise and isTenancy functions in the api package. The exported IsEnterprise and IsTenancy functions exist in the auth package. This removes the duplicated functions from api and replaces them with the exported packages from auth. It doesn't attempt to clean up any more logic than that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pkg/auth/auth.go
Outdated
// TenancyHost is the domain name of a tenancy GitHub instance. | ||
tenancyHost = "ghe.com" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at this I asked myself "Does VS Code really not try to fix the formatting on this one?" only to realize, no it doesn't.
Not the end of the world, but would rather the longer line with consistent formatting than shorter lines that are inconsistent. Not end of the world 🤷
// TenancyHost is the domain name of a tenancy GitHub instance. | |
tenancyHost = "ghe.com" | |
tenancyHost = "ghe.com" // TenancyHost is the domain name of a tenancy GitHub instance. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems reasonable to me as it also bothered me 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems reasonable to me. Maybe there was an original intention here to adhere to
A little copying is better than a little dependency (https://go-proverbs.github.io/)
But even if it was, I think that this has been a source of annoyance a number of times, so let's just do it!
Related to github/cli#577
Changes
In attempting to use
go-gh
incli/cli
forIsEnterprise
andIsTenancy
, I got bamboozled by the duplicate code, here. This removes the duplicated, unexportedisEnterprise
andisTenancy
functions from theapi
package and replaces them with the exportedIsEnterprise
andIsTenancy
packages fromauth
.Testing
Note, I've also tested these in cli/cli by running
go mod edit --replace=github.com/cli/go-gh=<localPath>/go-gh
and swapped these functions in. Everything there seems to be working as expected, too. I ran all the tests and did somegh auth
testing, just to be sure