Class: GemContribute::CLI::Fork
- Inherits:
-
Object
- Object
- GemContribute::CLI::Fork
- Extended by:
- Dry::Initializer
- Includes:
- Workflow
- Defined in:
- lib/gem_contribute/cli/fork.rb
Overview
‘gem-contribute fork <gem|owner/repo> [-e] [-a]`. Resolve the target, bootstrap a fork+clone via `Operations::Fork` + `Operations::Clone`, print a summary, run post-clone hooks. The CLI verb is a thin composition; the host-API ceremony lives in the adapter and the filesystem policy lives in Operations (ADR-0011). Operations are output-free per ADR-0012; this verb does the printing.
Constant Summary collapse
- DEFAULT_CLONE_ROOT =
File.("~/code/oss")
Instance Method Summary collapse
-
#bootstrap(adapter, project) ⇒ Object
The bootstrap primitive Fix shares: fork (or reuse) → clone (or reuse) → upstream remote.
- #run(argv) ⇒ Object
Instance Method Details
#bootstrap(adapter, project) ⇒ Object
The bootstrap primitive Fix shares: fork (or reuse) → clone (or reuse) → upstream remote. Returns ‘Success([local_path, fork_info])` on the happy path; `Failure(reason)` propagated from Operations otherwise.
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/gem_contribute/cli/fork.rb', line 56 def bootstrap(adapter, project) @output.progress("Forking #{project.owner}/#{project.repo}...") fork_result = @fork_op.call(adapter: adapter, project: project) return fork_result if fork_result.failure? fork_info = fork_result.value! @output.info(fork_status_line(fork_info, project)) clone_result = @clone_op.call(adapter: adapter, project: project, fork_clone_url: fork_info.clone_url, root: @clone_root) return clone_result if clone_result.failure? clone_info = clone_result.value! @output.info(clone_status_line(clone_info)) Success([clone_info.path, fork_info]) end |
#run(argv) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/gem_contribute/cli/fork.rb', line 34 def run(argv) return missing_clone_root if @clone_root.nil? target, flags = parse_argv(argv) return print_usage_error if target.nil? case build_adapter in Success(adapter) project = resolve_target(target, verb: "fork", allow_owner_repo: true) return 1 if project.nil? execute(adapter, project, flags) in Failure(:unauthenticated) @output.error("Not authenticated. Run `gem-contribute auth login` first.") 1 end end |