Module: Git::Repository::PathResolver Private
- Defined in:
- lib/git/repository/path_resolver.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.
Resolves and normalizes the filesystem paths that locate a Git repository
PathResolver is the single home for the path-resolution logic used by the
Git::Repository factory class methods (open and
bare). It computes the absolute working-directory,
repository (.git), and index paths from the caller-supplied values,
following the same rules Git itself uses (including gitdir-pointer files for
submodules and linked worktrees).
Class Method Summary collapse
-
.resolve_paths(working_directory: nil, repository: nil, index: nil, bare: false) ⇒ Hash{Symbol => (String, nil)}
private
Resolve and normalize the paths that locate a Git repository.
-
.root_of_worktree(working_dir, binary_path: :use_global_config, git_ssh: :use_global_config) ⇒ String
private
Find the root of the working tree that contains
working_dir.
Class Method Details
.resolve_paths(working_directory: nil, repository: nil, index: nil, bare: false) ⇒ Hash{Symbol => (String, nil)}
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.
Resolve and normalize the paths that locate a Git repository
Returns a new hash containing the resolved absolute paths for:
:working_directory— the working tree root (nilfor bare repos):repository— the.gitdirectory:index— the index file
This method does not mutate any inputs.
47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/git/repository/path_resolver.rb', line 47 def resolve_paths(working_directory: nil, repository: nil, index: nil, bare: false) working_dir = resolve_working_directory(working_directory, bare: ) # For bare repos, use working_directory as the default repository location repo_path = resolve_repository(repository, working_dir, bare: , bare_default: working_directory) index_path = resolve_index(index, repo_path) { working_directory: working_dir, repository: repo_path, index: index_path } end |
.root_of_worktree(working_dir, binary_path: :use_global_config, git_ssh: :use_global_config) ⇒ String
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.
Find the root of the working tree that contains working_dir
Runs git rev-parse --show-toplevel from working_dir to locate the
top-level directory of the working tree.
86 87 88 89 90 |
# File 'lib/git/repository/path_resolver.rb', line 86 def root_of_worktree(working_dir, binary_path: :use_global_config, git_ssh: :use_global_config) raise ArgumentError, "'#{working_dir}' does not exist or is not a directory" unless Dir.exist?(working_dir) execute_rev_parse_toplevel(working_dir, binary_path: binary_path, git_ssh: git_ssh) end |