Method: Gitgo::Git.init

Defined in:
lib/gitgo/git.rb

.init(path = Dir.pwd, options = {}) ⇒ Object

Creates a Git instance for path, initializing the repo if necessary.



148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# File 'lib/gitgo/git.rb', line 148

def init(path=Dir.pwd, options={})
  unless File.exists?(path)
    FileUtils.mkdir_p(path)
    
    Dir.chdir(path) do
      bare = options[:is_bare] ? true : false
      gitdir = bare || path =~ /\.git$/ ? path : File.join(path, ".git")
      
      Utils.with_env('GIT_DIR' => gitdir) do
        git = Grit::Git.new(gitdir)
        git.init({:bare => bare})
      end
    end
  end
  
  new(path, options)
end