Module: Git::Repository::Maintenance Private

Included in:
Git::Repository
Defined in:
lib/git/repository/maintenance.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Facade methods for repository maintenance and optimization operations

These methods pack objects, compress history, prune unreachable objects, and otherwise keep the repository in good health.

Included by Git::Repository.

API:

  • private

Instance Method Summary collapse

Instance Method Details

#gcString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Run garbage collection to optimize and clean up the repository

Runs git gc to perform housekeeping tasks including object compression, pruning of unreachable objects, and ref packing. This is equivalent to running git gc --prune --aggressive --auto.

This method uses the fixed options prune: true, aggressive: true, auto: true (matching the 4.x behavior). No additional options are exposed.

Examples:

Run garbage collection

repo.gc

Raises:

  • when git exits with a non-zero exit status

Returns:

  • the stdout from git gc. Git writes all progress and summary output to stderr, so the returned string is typically empty. Returns String to match the 4.x public contract (Git::Lib#command returned result.stdout).

API:

  • private



60
61
62
# File 'lib/git/repository/maintenance.rb', line 60

def gc
  Git::Commands::Gc.new(@execution_context).call(prune: true, aggressive: true, auto: true).stdout
end

#repackString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Repack loose objects into pack files

Packs all unpacked objects and removes redundant pack files. This is equivalent to running git repack -a -d, which packs all objects into a single pack and deletes any packs that become redundant.

This method uses the fixed options a: true, d: true (matching the 4.x behavior). No additional options are exposed.

Examples:

Repack the repository

repo.repack

Raises:

  • when git exits with a non-zero exit status

Returns:

  • the stdout from git repack. Git writes all progress and summary output to stderr, so the returned string is typically empty. Returns String to match the 4.x public contract (Git::Lib#command returned result.stdout).

API:

  • private



37
38
39
# File 'lib/git/repository/maintenance.rb', line 37

def repack
  Git::Commands::Repack.new(@execution_context).call(a: true, d: true).stdout
end