Module: Ace::Git

Defined in:
lib/ace/git.rb,
lib/ace/git/cli.rb,
lib/ace/git/version.rb,
lib/ace/git/cli/commands/pr.rb,
lib/ace/git/atoms/diff_parser.rb,
lib/ace/git/cli/commands/diff.rb,
lib/ace/git/atoms/file_grouper.rb,
lib/ace/git/models/diff_config.rb,
lib/ace/git/models/diff_result.rb,
lib/ace/git/models/repo_status.rb,
lib/ace/git/atoms/date_resolver.rb,
lib/ace/git/cli/commands/branch.rb,
lib/ace/git/cli/commands/status.rb,
lib/ace/git/atoms/pattern_filter.rb,
lib/ace/git/atoms/time_formatter.rb,
lib/ace/git/molecules/diff_filter.rb,
lib/ace/git/atoms/command_executor.rb,
lib/ace/git/atoms/git_scope_filter.rb,
lib/ace/git/atoms/status_formatter.rb,
lib/ace/git/molecules/branch_reader.rb,
lib/ace/git/molecules/config_loader.rb,
lib/ace/git/atoms/git_status_fetcher.rb,
lib/ace/git/atoms/repository_checker.rb,
lib/ace/git/atoms/stale_lock_cleaner.rb,
lib/ace/git/molecules/diff_generator.rb,
lib/ace/git/atoms/diff_numstat_parser.rb,
lib/ace/git/atoms/lock_error_detector.rb,
lib/ace/git/molecules/gh_cli_executor.rb,
lib/ace/git/atoms/pr_identifier_parser.rb,
lib/ace/git/molecules/github_issue_sync.rb,
lib/ace/git/organisms/diff_orchestrator.rb,
lib/ace/git/atoms/task_pattern_extractor.rb,
lib/ace/git/molecules/git_status_fetcher.rb,
lib/ace/git/organisms/repo_status_loader.rb,
lib/ace/git/atoms/grouped_stats_formatter.rb,
lib/ace/git/molecules/pr_metadata_fetcher.rb,
lib/ace/git/atoms/repository_state_detector.rb,
lib/ace/git/molecules/recent_commits_fetcher.rb

Defined Under Namespace

Modules: Atoms, CLI, Models, Molecules, Organisms Classes: ConfigError, Error, GhAuthenticationError, GhNotInstalledError, GitError, PrNotFoundError, TimeoutError

Constant Summary collapse

VERSION =
'0.22.0'

Class Method Summary collapse

Class Method Details

.commits_limitInteger

Number of recent commits to show in status output

Returns:

  • (Integer)

    Limit (default: 3)



181
182
183
# File 'lib/ace/git.rb', line 181

def self.commits_limit
  config.dig("status", "commits_limit") || 3
end

.configHash

Get configuration for ace-git Follows ADR-022: Configuration Default and Override Pattern Uses Ace::Support::Config.create() for configuration cascade resolution Thread-safe: uses mutex for initialization

Examples:

Get current configuration

config = Ace::Git.config
puts config["default_branch"]  # => "main"

Access nested diff config

exclude = Ace::Git.config["exclude_patterns"]

Returns:

  • (Hash)

    merged configuration hash



37
38
39
40
41
42
43
44
45
# File 'lib/ace/git.rb', line 37

def self.config
  # Fast path: return cached config if already initialized
  return @config if defined?(@config) && @config

  # Thread-safe initialization
  @config_mutex.synchronize do
    @config ||= load_config
  end
end

.extract_git_config(git_section) ⇒ Hash

Extract git configuration from YAML structure

BACKWARD COMPATIBILITY NOTE: This method flattens the nested ‘diff:` section to top-level keys. This is required because the original default_config structure used flat keys (e.g., `exclude_patterns`, `exclude_whitespace`) rather than nested `diff.exclude_patterns`. The YAML config uses `git.diff.exclude_patterns` for clarity, but internally we flatten to maintain compatibility with DiffConfig.from_hash and existing consumers.

Example transformation:

git:
  diff:
    exclude_patterns: ["*.log"]
becomes:
  { "exclude_patterns" => ["*.log"] }

Keys are kept as strings for consistency with YAML loading. Use config or config.key?(“key”) for access.

Parameters:

  • git_section (Hash)

    The git: section from YAML

Returns:

  • (Hash)

    Flattened configuration with string keys



118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# File 'lib/ace/git.rb', line 118

def self.extract_git_config(git_section)
  return {} if git_section.nil? || git_section.empty?

  config = {}

  # Normalize keys to strings for consistency
  normalized = normalize_keys(git_section)

  # Copy top-level settings
  %w[default_branch remote verbose timeout network_timeout].each do |key|
    config[key] = normalized[key] if normalized.key?(key)
  end

  # Flatten diff: section to top-level for backward compatibility (see note above)
  diff_section = normalized["diff"]
  if diff_section.is_a?(Hash)
    normalize_keys(diff_section).each do |key, value|
      config[key] = value
    end
  end

  # Copy other sections as-is (rebase, pr, squash, status, lock_retry, etc.)
  %w[rebase pr squash status lock_retry].each do |key|
    config[key] = normalized[key] if normalized.key?(key)
  end

  config
end

.git_timeoutInteger

Timeout for local git operations (diff, status, log)

Returns:

  • (Integer)

    Timeout in seconds (default: 30)



169
170
171
# File 'lib/ace/git.rb', line 169

def self.git_timeout
  config["timeout"] || 30
end

.merged_prs_limitInteger

Number of recently merged PRs to show in status output

Returns:

  • (Integer)

    Limit (default: 3)



187
188
189
# File 'lib/ace/git.rb', line 187

def self.merged_prs_limit
  config.dig("status", "merged_prs_limit") || 3
end

.network_timeoutInteger

Timeout for network operations (gh CLI, remote operations)

Returns:

  • (Integer)

    Timeout in seconds (default: 60)



175
176
177
# File 'lib/ace/git.rb', line 175

def self.network_timeout
  config["network_timeout"] || 60
end

.normalize_keys(hash) ⇒ Hash

Normalize hash keys to strings for consistent access

Parameters:

  • hash (Hash)

    Hash with potentially mixed string/symbol keys

Returns:

  • (Hash)

    Hash with string keys



150
151
152
153
154
# File 'lib/ace/git.rb', line 150

def self.normalize_keys(hash)
  return {} unless hash.is_a?(Hash)

  hash.transform_keys(&:to_s)
end

.open_prs_limitInteger

Number of open PRs to show in status output

Returns:

  • (Integer)

    Limit (default: 10)



193
194
195
# File 'lib/ace/git.rb', line 193

def self.open_prs_limit
  config.dig("status", "open_prs_limit") || 10
end

.reset_config!Object

Reset configuration cache (mainly for testing) Thread-safe: uses mutex to prevent race conditions



158
159
160
161
162
# File 'lib/ace/git.rb', line 158

def self.reset_config!
  @config_mutex.synchronize do
    @config = nil
  end
end