Class: Worktree::Project

Inherits:
Object
  • Object
show all
Defined in:
lib/worktree/project.rb

Overview

:nodoc:

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key) ⇒ Project

Returns a new instance of Project.



12
13
14
# File 'lib/worktree/project.rb', line 12

def initialize(key)
  @key = key
end

Class Method Details

.resolve(branch, project_dir: nil) ⇒ Object



5
6
7
8
9
10
# File 'lib/worktree/project.rb', line 5

def self.resolve(branch, project_dir: nil)
  project_key = project_key_by_branch(branch)
  # try to find project key by dir (cherry-pick or open case)
  project_key = project_key_by_dir(project_dir) if project_key.nil? && project_dir
  new(project_key)
end

Instance Method Details

#copy_filesObject



16
17
18
19
20
21
22
# File 'lib/worktree/project.rb', line 16

def copy_files
  if @key
    Worktree::Config.config.dig('projects', @key, 'copy_files') || []
  else
    []
  end
end

#rootObject



24
25
26
27
28
29
30
# File 'lib/worktree/project.rb', line 24

def root
  if @key
    Worktree::Config.config.dig('projects', @key, 'root').chomp('/')
  else
    Dir.pwd
  end
end