Class: GemContribute::Operations::Branch

Inherits:
Object
  • Object
show all
Defined in:
lib/gem_contribute/operations/branch.rb

Overview

Bootstrap step 3: create the per-issue working branch in the fork clone. The branch name is ‘gem-contribute/issue-<N>`. Output-free per ADR-0012.

Note: ‘git checkout -b` fails if the branch already exists, which surfaces as `Failure([:adapter_error, …])` here. That preserves the pre-extraction behaviour where re-running `fix` on an issue whose branch already exists locally errored out — see [#10] for the friendlier-message follow-up.

Defined Under Namespace

Classes: Result

Constant Summary collapse

PREFIX =
"gem-contribute/issue-"

Instance Method Summary collapse

Constructor Details

#initialize(git: Git.new) ⇒ Branch

Returns a new instance of Branch.



22
23
24
# File 'lib/gem_contribute/operations/branch.rb', line 22

def initialize(git: Git.new)
  @git = git
end

Instance Method Details

#call(path:, issue:) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/gem_contribute/operations/branch.rb', line 26

def call(path:, issue:)
  name = "#{PREFIX}#{issue}"
  @git.checkout_branch(path, name)
  Success(Result.new(name: name))
rescue GemContribute::AdapterError => e
  Failure([:adapter_error, e.message])
end