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

Add repository.ParseWithHost #41

Merged
merged 1 commit into from May 17, 2022
Merged

Add repository.ParseWithHost #41

merged 1 commit into from May 17, 2022

Conversation

samcoe
Copy link
Contributor

@samcoe samcoe commented May 16, 2022

This PR adds a repository.ParseWithHost function that is necessary for gh to use go-gh for parsing repository strings. Additionally, it changes repository.Parse to now look at the config file for a viable host instead of just looking at GH_HOST before defaulting to github.com. This new behavior also matches the current functionality in gh.

cc cli/cli#5560
corresponds to cli/cli#5655

@samcoe samcoe self-assigned this May 16, 2022
@samcoe samcoe marked this pull request as ready for review May 16, 2022 14:57
Copy link
Contributor

@mislav mislav left a comment

Choose a reason for hiding this comment

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

🚀

if host == "" {
host = "github.com"
host := "github.com"
cfg, err := config.Load()
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems correct for now, but ultimately I find it surprising that Parse() implicitly loads config. I think an ideal API might be one where a repository "parser" is derived from a config object, so that their relationship is denoted explicitly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I agree it is a bit odd. go-gh is also targeting extension authors, I would think that they don't necessarily want to concern themselves with loading up the config and determining the correct host. We also do this when initializing the various API clients. As long as there are alternatives for advanced users, that don't want automatic resolution such as repository.ParseWithHost, I am okay with having these easy to use alternatives.

@samcoe samcoe merged commit 7ad1d2c into trunk May 17, 2022
@samcoe samcoe deleted the repo-integration branch May 17, 2022 19:30
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.

None yet

2 participants