Module: Git::Repository::Factories Private
- Included in:
- Git
- Defined in:
- lib/git/repository/factories.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.
Implementation of the Git module factory entry points
Provides .open, .init, .clone, and .bare — the four methods that
construct a Git::Repository. Extended onto the Git module so that
Git.open(...), Git.init(...), etc. resolve here.
Instance Method Summary collapse
-
#bare(git_dir, options = {}) ⇒ Git::Repository
Open an existing bare repository at
git_dir. -
#clone(repository_url, directory = nil, options = {}) ⇒ Git::Repository
Clone a repository into a new directory.
-
#init(directory = '.', options = {}) ⇒ Git::Repository
Create an empty Git repository or reinitialize an existing one.
-
#open(working_dir, options = {}) ⇒ Git::Repository
Open a working copy at an existing path.
Instance Method Details
#bare(git_dir, options = {}) ⇒ Git::Repository
Open an existing bare repository at git_dir
333 334 335 336 337 |
# File 'lib/git/repository/factories.rb', line 333 def (git_dir, = {}) paths = PathResolver.resolve_paths(repository: git_dir, bare: true) from_paths(, paths) end |
#clone(repository_url, directory = nil, options = {}) ⇒ Git::Repository
Clone a repository into a new directory
178 179 180 181 182 183 184 |
# File 'lib/git/repository/factories.rb', line 178 def clone(repository_url, directory = nil, = {}) opts, context_opts = () clone_result = run_clone_command(repository_url, directory, opts, context_opts) paths = resolve_paths_from_clone_result(clone_result, opts, context_opts) from_paths((context_opts), paths) end |
#init(directory = '.', options = {}) ⇒ Git::Repository
Create an empty Git repository or reinitialize an existing one
239 240 241 242 243 244 245 246 247 |
# File 'lib/git/repository/factories.rb', line 239 def init(directory = '.', = {}) = .dup if .key?(:separate_git_dir) && [:repository].nil? [:repository] = .delete(:separate_git_dir) end run_init_command(directory, ) open_after_init(directory, ) end |
#open(working_dir, options = {}) ⇒ Git::Repository
This method opens working copies only. To open a bare repository, use
Git.bare.
Open a working copy at an existing path
292 293 294 295 296 297 298 299 300 301 302 303 304 |
# File 'lib/git/repository/factories.rb', line 292 def open(working_dir, = {}) raise ArgumentError, "'#{working_dir}' is not a directory" unless Dir.exist?(working_dir) working_dir = resolve_open_working_dir(working_dir, ) unless [:repository] paths = PathResolver.resolve_paths( working_directory: working_dir, repository: [:repository], index: [:index] ) from_paths(, paths) end |