Class: Worktrees::Models::Repository

Inherits:
Object
  • Object
show all
Defined in:
lib/worktrees/models/repository.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(root_path) ⇒ Repository

Returns a new instance of Repository.



8
9
10
11
# File 'lib/worktrees/models/repository.rb', line 8

def initialize(root_path)
  @root_path = File.expand_path(root_path)
  validate_git_repository!
end

Instance Attribute Details

#root_pathObject (readonly)

Returns the value of attribute root_path.



6
7
8
# File 'lib/worktrees/models/repository.rb', line 6

def root_path
  @root_path
end

Instance Method Details

#branch_exists?(branch_name) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/worktrees/models/repository.rb', line 17

def branch_exists?(branch_name)
  git_branch_exists?(branch_name)
end

#configObject



29
30
31
# File 'lib/worktrees/models/repository.rb', line 29

def config
  @config ||= WorktreeConfig.load
end

#default_branchObject



13
14
15
# File 'lib/worktrees/models/repository.rb', line 13

def default_branch
  git_default_branch
end

#remote_urlObject



21
22
23
# File 'lib/worktrees/models/repository.rb', line 21

def remote_url
  git_remote_url
end

#worktrees_pathObject



25
26
27
# File 'lib/worktrees/models/repository.rb', line 25

def worktrees_path
  config.expand_worktrees_root
end