Class: Git::ExecutionContext::Repository Private
- Inherits:
-
Git::ExecutionContext
- Object
- Git::ExecutionContext
- Git::ExecutionContext::Repository
- Defined in:
- lib/git/execution_context/repository.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Execution context for repository-bound git commands
Manages the git environment for commands that operate within an existing
repository — setting GIT_DIR, GIT_WORK_TREE, GIT_INDEX_FILE, and
GIT_SSH — and prepending --git-dir / --work-tree to every git
invocation via #global_opts.
Construction
Use Repository.from_hash to build from a configuration hash:
context = Git::ExecutionContext::Repository.from_hash(repository: '/repo/.git', ...)
Constant Summary
Constants inherited from Git::ExecutionContext
COMMAND_CAPTURING_ARG_DEFAULTS, COMMAND_STREAMING_ARG_DEFAULTS, STATIC_GLOBAL_OPTS
Instance Attribute Summary collapse
-
#git_dir ⇒ String?
readonly
private
Path to the
.gitdirectory. -
#git_index_file ⇒ String?
readonly
private
Path to the index file.
-
#git_work_dir ⇒ String?
readonly
private
Path to the working tree.
Attributes inherited from Git::ExecutionContext
Class Method Summary collapse
-
.from_hash(base_hash, logger: nil) ⇒ Git::ExecutionContext::Repository
private
Creates a Repository context from a Hash.
Instance Method Summary collapse
-
#dup_with(**overrides) ⇒ Git::ExecutionContext::Repository
private
Returns a new instance with the same configuration, applying
overrides. -
#initialize(git_dir:, git_work_dir: nil, git_index_file: nil, binary_path: :use_global_config, git_ssh: :use_global_config, logger: nil) ⇒ Repository
constructor
private
Creates a new repository execution context.
Methods inherited from Git::ExecutionContext
#binary_path, #command_capturing, #command_streaming, #env_overrides, #git_ssh, #git_version
Constructor Details
#initialize(git_dir:, git_work_dir: nil, git_index_file: nil, binary_path: :use_global_config, git_ssh: :use_global_config, logger: nil) ⇒ Repository
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.
Creates a new repository execution context
88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/git/execution_context/repository.rb', line 88 def initialize( # rubocop:disable Metrics/ParameterLists git_dir:, git_work_dir: nil, git_index_file: nil, binary_path: :use_global_config, git_ssh: :use_global_config, logger: nil ) super(binary_path: binary_path, git_ssh: git_ssh, logger: logger) @git_dir = git_dir @git_work_dir = git_work_dir @git_index_file = git_index_file end |
Instance Attribute Details
#git_dir ⇒ String? (readonly)
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.
Returns path to the .git directory.
103 104 105 |
# File 'lib/git/execution_context/repository.rb', line 103 def git_dir @git_dir end |
#git_index_file ⇒ String? (readonly)
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.
Returns path to the index file.
109 110 111 |
# File 'lib/git/execution_context/repository.rb', line 109 def git_index_file @git_index_file end |
#git_work_dir ⇒ String? (readonly)
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.
Returns path to the working tree.
106 107 108 |
# File 'lib/git/execution_context/repository.rb', line 106 def git_work_dir @git_work_dir end |
Class Method Details
.from_hash(base_hash, logger: nil) ⇒ Git::ExecutionContext::Repository
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.
Creates a Repository context from a Hash
Expected keys: :repository, :working_directory, :index, :git_ssh,
:binary_path
47 48 49 50 51 52 53 54 55 56 |
# File 'lib/git/execution_context/repository.rb', line 47 def self.from_hash(base_hash, logger: nil) new( git_dir: base_hash[:repository], git_index_file: base_hash[:index], git_work_dir: base_hash[:working_directory], git_ssh: base_hash.fetch(:git_ssh, :use_global_config), binary_path: base_hash.fetch(:binary_path, :use_global_config), logger: logger ) end |
Instance Method Details
#dup_with(**overrides) ⇒ Git::ExecutionContext::Repository
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.
Returns a new instance with the same configuration, applying overrides
Uses raw stored values for binary_path, git_ssh, and logger so
that :use_global_config sentinels are preserved across rebuilds and
future changes to Git.configure continue to take effect.
123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/git/execution_context/repository.rb', line 123 def dup_with(**overrides) self.class.new( git_dir: @git_dir, git_work_dir: @git_work_dir, git_index_file: @git_index_file, binary_path: @binary_path, git_ssh: @git_ssh, logger: @logger, **overrides ) end |