feat(cli): add gem-contribute open <gem>#67
Merged
Conversation
Adds a small `open` verb that resolves a gem the same way `issues` and `fix` do, then opens the resulting repo's GitHub URL in the user's default browser. The URL is always printed on stdout so the command is useful in non-interactive contexts and degrades cleanly when the platform-specific opener fails. The browser opener is injected at construction (matching `auth login` and `submit`) so specs never shell out. Closes cdhagmann#3
- Style/Semicolon: convert browser_opener inline lambda to multi-line. - RSpec/MessageSpies: switch `expect(..).not_to receive` to the spy-style `allow + have_received` for the self-resolve case.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
gem-contribute open <gem>, a small CLI verb that resolves a gemthe same way
issuesandfixdo and opens the resulting GitHub repoURL in the default browser. The URL is always printed on stdout so the
command degrades cleanly when the platform opener fails or the user is
in a non-interactive shell.
The browser opener is injected at construction (matching
auth loginand
submit), so specs never shell out.Linked issue / ADR
Closes #3.
No ADR — this is a new CLI verb that fits inside the existing v1 CLI
shape (ADR-0015) and reuses the patterns already chosen for resolving
targets and opening URLs. ADR-0007 keeps
openfrom drifting toward a"summarize the project" verb; the only thing this command does is open
the repo URL.
Working agreement
that make it reachable.
bin/rubocopandbin/rspecnot run locally (no Ruby 3.2+installed on this machine; the project's CI runs both via
Docker).
ruby -cclean on all three new/changed files.browser-opener fallback, non-github.com host, and the
gem-contributeself-resolve.openis a synchronous shell-out happening once,via the shared
default_browser_openeralready used elsewhere.Test plan
spec/gem_contribute/cli/open_spec.rbcovers the five acceptancecriteria from the issue:
openwith no args exits 2 and prints the usage line on stderropen <gem>resolves through the injected resolver, openshttps://github.com/<owner>/<repo>, and printsOpened browser to:followed by the URL
browser_openerreturns false, the verb stillprints the URL on its own line, prefixed with
Open this URL in your browser:(the fallback wording matchessubmit)only github.com is supported at v0.1message asfixandforkand exits 1gem-contributeis self-resolved throughSELF_PROJECTwithouthitting the resolver
ruby -con the three new/changed files is clean. I couldn't runbin/rspecorbin/rubocoplocally — system Ruby is 2.6 and theGemfile.lock requires Bundler 4 / Ruby 3.2+ — but the implementation
follows the same dependency-injection patterns used by
auth.rb,submit.rb, andissues.rb, so the file should pass CI withoutadjustment. Happy to amend if anything trips.
Notes for reviewer
workshop-friendly tour-of-the-codebase scope and the existing
default_browser_openeris already platform-aware, so there'snothing to thread through.
submit.rb's pattern of always printing the URL on aseparate line (so the "Opening..." message is short and the URL is
greppable in shell history). The issue's example had the URL inline
in the "Opening..." line; I'm easy on either, happy to adjust if you
prefer the inline form.
openis wired into the dispatcher betweenforkandfixbecauseit pairs naturally with those verbs in the workflow (fork the repo,
open the repo, fix the issue) — the alphabetical order would have
put it after
init. Easy to move if you'd rather keep the tablealphabetical.