Class: Worktree::Command::Add
- Inherits:
-
Object
- Object
- Worktree::Command::Add
- Defined in:
- lib/worktree/command/add.rb
Overview
:nodoc:
Instance Method Summary collapse
- #do! ⇒ Object
-
#initialize(branch, from:, project_dir:, launcher_vars: {}, clone_db: false, fetch_remote: true) ⇒ Add
constructor
A new instance of Add.
Constructor Details
#initialize(branch, from:, project_dir:, launcher_vars: {}, clone_db: false, fetch_remote: true) ⇒ Add
Returns a new instance of Add.
6 7 8 9 10 11 12 13 |
# File 'lib/worktree/command/add.rb', line 6 def initialize(branch, from:, project_dir:, launcher_vars: {}, clone_db: false, fetch_remote: true) @branch = branch @from = from @project_dir = File. project_dir || Project.resolve(branch).root @launcher_vars = launcher_vars @clone_db = clone_db @fetch_remote = fetch_remote end |
Instance Method Details
#do! ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/worktree/command/add.rb', line 15 def do! # fetch git remote if allowed git.fetch(remote, prune: true) if @fetch_remote # create new git worktree Worktree.run_command "git worktree add -b #{@branch} ../#{@branch} #{@from}", chdir: git.dir # copy files specified in configuration into new folder Feature::CopyFiles.new(project_dir: @project_dir, branch: @branch).run! # clone PG database Feature::CloneDbs.new(project_dir: @project_dir, branch: @branch).run! if @clone_db # launch in editor Launcher.new(project_dir: @project_dir, branch: @branch, extra_vars: @launcher_vars).launch! end |