Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions lib/ruby_git.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,17 @@ class << self
# @see https://git-scm.com/docs/git-init git-init
#
# @example
# worktree = Worktree.init(worktree_path)
# worktree = Worktree.init(worktree_path, initial_branch: 'main')
#
# @param [String] worktree_path the root path of a worktree
# @param worktree_path [String] the root path of a worktree
# @param initial_branch [String] the initial branch in the newly created repository
#
# @raise [RubyGit::Error] if worktree_path is not a directory
#
# @return [RubyGit::Worktree] the worktree whose root is at `path`
#
def self.init(worktree_path)
RubyGit::Worktree.init(worktree_path)
def self.init(worktree_path, initial_branch:)
RubyGit::Worktree.init(worktree_path, initial_branch:)
end

# Open an existing Git working tree that contains worktree_path
Expand Down
2 changes: 1 addition & 1 deletion lib/ruby_git/worktree.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Worktree
# @see https://git-scm.com/docs/git-init git-init
#
# @example
# worktree = Worktree.init(worktree_path)
# worktree = Worktree.init(worktree_path, initial_branch: 'main')
#
# @param worktree_path [String] the root path of a Git working tree
# @param initial_branch [String] the initial branch in the newly created repository
Expand Down
5 changes: 3 additions & 2 deletions spec/lib/ruby_git_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,13 @@
end

describe '.init' do
subject { RubyGit.init(worktree_path, initial_branch:) }
let(:worktree_path) { '/Users/jsmith/my_project' }
subject { RubyGit.init(worktree_path) }
let(:initial_branch) { 'xxx' }
it 'should call RubyGit::Worktree.init with the same arguments' do
worktree_class = class_double('RubyGit::Worktree')
stub_const('RubyGit::Worktree', worktree_class)
expect(worktree_class).to receive(:init).with(worktree_path)
expect(worktree_class).to receive(:init).with(worktree_path, initial_branch:)
subject
end
end
Expand Down