Class: GDK::Project::GitWorktree
- Inherits:
-
Object
- Object
- GDK::Project::GitWorktree
- Defined in:
- lib/gdk/project/git_worktree.rb
Constant Summary collapse
- DEFAULT_RETRY_ATTEMPTS =
3
Instance Method Summary collapse
-
#initialize(worktree_path, default_branch, revision, auto_rebase: false) ⇒ GitWorktree
constructor
A new instance of GitWorktree.
- #update ⇒ Object
Constructor Details
#initialize(worktree_path, default_branch, revision, auto_rebase: false) ⇒ GitWorktree
Returns a new instance of GitWorktree.
8 9 10 11 12 13 |
# File 'lib/gdk/project/git_worktree.rb', line 8 def initialize(worktree_path, default_branch, revision, auto_rebase: false) @worktree_path = worktree_path @default_branch = default_branch @revision = revision @auto_rebase = auto_rebase end |
Instance Method Details
#update ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/gdk/project/git_worktree.rb', line 15 def update stashed = stash_save sh = execute_command(fetch_cmd) unless sh.success? GDK::Output.puts(sh.read_stderr, stderr: true) GDK::Output.error("Failed to fetch for '#{short_worktree_path}'", sh.read_stderr) return false end result = auto_rebase? ? execute_rebase : execute_checkout_and_pull ensure stashed ? stash_pop : result end |