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

Replace duplicated IsEnterprise and IsTenancy functions in api pkg with auth pkg #173

Merged
merged 4 commits into from
Oct 14, 2024

Conversation

jtmcg
Copy link
Contributor

@jtmcg jtmcg commented Oct 10, 2024

Related to github/cli#577

Changes

In attempting to use go-gh in cli/cli for IsEnterprise and IsTenancy, I got bamboozled by the duplicate code, here. This removes the duplicated, unexported isEnterprise and isTenancy functions from the api package and replaces them with the exported IsEnterprise and IsTenancy packages from auth.

Testing

  1. Pull down branch
  2. Run tests

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 some gh auth testing, just to be sure

@jtmcg jtmcg changed the title Export IsEnterprise and IsTenancy functions [WIP] Export IsEnterprise and IsTenancy functions Oct 10, 2024
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.
@jtmcg jtmcg changed the title [WIP] Export IsEnterprise and IsTenancy functions Replace duplicated IsEnterprise and IsTenancy functions in api pkg with auth pkg Oct 11, 2024
Copy link
Contributor

@andyfeller andyfeller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shipit-squirrel-thumbsup

pkg/auth/auth.go Outdated
Comment on lines 29 to 30
// TenancyHost is the domain name of a tenancy GitHub instance.
tenancyHost = "ghe.com"
Copy link
Contributor

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 🤷

Suggested change
// 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.

Copy link
Contributor Author

@jtmcg jtmcg Oct 14, 2024

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 😅

Copy link
Member

@williammartin williammartin left a 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!

@jtmcg jtmcg merged commit 7177035 into trunk Oct 14, 2024
10 checks passed
@jtmcg jtmcg deleted the jtmcg/577 branch October 14, 2024 20:39
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

Successfully merging this pull request may close these issues.

3 participants