Method: Git::Base.init
- Defined in:
- lib/git/base.rb
.init(directory = '.', options = {}) ⇒ Git::Base
Create an empty Git repository or reinitialize an existing Git repository
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/git/base.rb', line 71 def self.init(directory = '.', = {}) normalize_paths(, default_working_directory: directory, default_repository: directory, bare: [:bare]) = { bare: [:bare], initial_branch: [:initial_branch] } directory = [:bare] ? [:repository] : [:working_directory] FileUtils.mkdir_p(directory) # TODO: this dance seems awkward: this creates a Git::Lib so we can call # init so we can create a new Git::Base which in turn (ultimately) # creates another/different Git::Lib. # # TODO: maybe refactor so this Git::Bare.init does this: # self.new(opts).init(init_opts) and move all/some of this code into # Git::Bare#init. This way the init method can be called on any # repository you have a Git::Base instance for. This would not # change the existing interface (other than adding to it). # Git::Lib.new().init() new() end |