spec/support/git_spec_helpers.rb
# Creates an empty git repository, allowing you to execute a block where
# the current working directory is set to that repository's root directory.
#
# @param options [Hash]
# @return [String] path of the repository
Creates an empty git repository, allowing you to execute a block where
the current working directory is set to that repository's root directory.
Creates an empty git repository allowing you to execute a block where the current working directory is set to that repository ' s root directory .
def repo(options = {})
    directory('some-repo') do
      create_cmd = %w[git init]
      create_cmd += ['--template', options[:template_dir]] if options[:template_dir]
      create_cmd += ['--separate-git-dir', options[:git_dir]] if options[:git_dir]
      result = Overcommit::Utils.execute(create_cmd)
      raise "Unable to create repo: #{result.stderr}" unless result.success?
      `git config --local user.name "Overcommit Tester"`
      `git config --local user.email "overcommit@example.com"`
      `git config --local rerere.enabled 0` 
      `git config --local commit.gpgsign false`
      yield if block_given?
    end
  end
def repo ( options = { } ) directory ( 'some-repo' ) do create_cmd = %w[ git init ] create_cmd += [ '--template' , options [ :template_dir ] ] if options [ :template_dir ] create_cmd += [ '--separate-git-dir' , options [ :git_dir ] ] if options [ :git_dir ] result = Overcommit :: Utils . execute ( create_cmd ) raise "Unable to create repo: #{result.stderr}" unless result . success? ` git config --local user.name "Overcommit Tester" ` ` git config --local user.email "overcommit@example.com" ` ` git config --local rerere.enabled 0 ` ` git config --local commit.gpgsign false ` yield if block_given? end end
Creates an empty git repository, allowing you to execute a block where
the current working directory is set to that repository's root directory.
Creates an empty git repository allowing you to execute a block where the current working directory is set to that repository ' s root directory .
# Need to define user info since some CI contexts don't have defaults set # Don't record resolutions in tests
path of the repository
path of the repository
String
options
<not_specific>
<not_specific>
None