Class: Ace::GitCommit::Atoms::GitExecutor

Inherits:
Object
  • Object
show all
Defined in:
lib/ace/git_commit/atoms/git_executor.rb

Overview

GitExecutor handles low-level git command execution Delegates to ace-git for command execution

Instance Method Summary collapse

Instance Method Details

#execute(*args, capture_stderr: false) ⇒ String

Execute a git command and return output

Raises:



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/ace/git_commit/atoms/git_executor.rb', line 16

def execute(*args, capture_stderr: false)
  cmd = ["git"] + args
  result = Ace::Git::Atoms::CommandExecutor.execute(*cmd)

  unless result[:success]
    error_msg = "Git command failed: #{cmd.join(" ")}"
    error_msg += "\nError: #{result[:error]}" if result[:error] && !result[:error].empty?
    raise GitError, error_msg
  end

  # Combine output and error if capture_stderr is true
  if capture_stderr && result[:error] && !result[:error].empty?
    result[:output] + result[:error]
  else
    result[:output]
  end
end

#has_changes?Boolean

Check if there are any changes



48
49
50
51
52
# File 'lib/ace/git_commit/atoms/git_executor.rb', line 48

def has_changes?
  Ace::Git::Atoms::CommandExecutor.has_unstaged_changes? ||
    Ace::Git::Atoms::CommandExecutor.has_staged_changes? ||
    Ace::Git::Atoms::CommandExecutor.has_untracked_changes?
end

#has_staged_changes?Boolean

Check if there are staged changes



56
57
58
# File 'lib/ace/git_commit/atoms/git_executor.rb', line 56

def has_staged_changes?
  Ace::Git::Atoms::CommandExecutor.has_staged_changes?
end

#in_repository?Boolean

Check if we’re in a git repository



36
37
38
# File 'lib/ace/git_commit/atoms/git_executor.rb', line 36

def in_repository?
  Ace::Git::Atoms::CommandExecutor.in_git_repo?
end

#repository_rootString

Get repository root



42
43
44
# File 'lib/ace/git_commit/atoms/git_executor.rb', line 42

def repository_root
  Ace::Git::Atoms::CommandExecutor.repo_root
end