Module: Ace::Git

Defined in:
lib/ace/git.rb,
lib/ace/git/cli.rb,
lib/ace/git/errors.rb,
lib/ace/git/version.rb,
lib/ace/git/providers.rb,
lib/ace/git/providers/base.rb,
lib/ace/git/resolved_server.rb,
lib/ace/git/server_registry.rb,
lib/ace/git/atoms/server_url.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/providers/evidence.rb,
lib/ace/git/atoms/date_resolver.rb,
lib/ace/git/atoms/pr_identifier.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/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/atoms/repository_state_detector.rb,
lib/ace/git/molecules/recent_commits_fetcher.rb

Defined Under Namespace

Modules: Atoms, CLI, Models, Molecules, Organisms, Providers Classes: AmbiguousRemoteError, ConfigError, DuplicateServerNameError, Error, GitError, MultipleDefaultServersError, NoDefaultServerConfiguredError, ProviderAuthenticationError, ProviderCheck, ProviderCliMissingError, ProviderIssue, ProviderMalformedOutputError, ProviderObjectNotFoundError, ProviderPullRequest, ProviderRepository, ProviderUnreachableError, ResolvedServer, ServerRegistry, TimeoutError, UnknownProviderError, UnknownServerNameError

Constant Summary collapse

VERSION =
"0.24.0"

Class Method Summary collapse

Class Method Details

.commits_limit ⇒ Integer

Number of recent commits to show in status output

Returns:

  • (Integer) —

    Limit (default: 3)



177
178
179
# File 'lib/ace/git.rb', line 177

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

.config ⇒ Hash

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



33
34
35
36
37
38
39
40
41
# File 'lib/ace/git.rb', line 33

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



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

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 servers].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_timeout ⇒ Integer

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

Returns:

  • (Integer) —

    Timeout in seconds (default: 30)



165
166
167
# File 'lib/ace/git.rb', line 165

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

.merged_prs_limit ⇒ Integer

Number of recently merged PRs to show in status output

Returns:

  • (Integer) —

    Limit (default: 3)



183
184
185
# File 'lib/ace/git.rb', line 183

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

.network_timeout ⇒ Integer

Timeout for network operations (provider CLIs, remote operations)

Returns:

  • (Integer) —

    Timeout in seconds (default: 60)



171
172
173
# File 'lib/ace/git.rb', line 171

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



146
147
148
149
150
# File 'lib/ace/git.rb', line 146

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

  hash.transform_keys(&:to_s)
end

.open_prs_limit ⇒ Integer

Number of open PRs to show in status output

Returns:

  • (Integer) —

    Limit (default: 10)



189
190
191
# File 'lib/ace/git.rb', line 189

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



154
155
156
157
158
# File 'lib/ace/git.rb', line 154

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