Class: Overapp::Git

Inherits:
Object show all
Defined in:
lib/overapp/util/git.rb

Class Method Summary collapse

Class Method Details

.commit(output_path, message, &b) ⇒ Object



18
19
20
21
# File 'lib/overapp/util/git.rb', line 18

def commit(output_path,message,&b)
  init = !FileTest.exist?("#{output_path}/.git")
  commit_inner(output_path,message,init,&b)
end

.commit_inner(output_path, message, init, &b) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/overapp/util/git.rb', line 4

def commit_inner(output_path,message,init,&b)
  res = nil
  res = yield if block_given?
  if init
    `rm -rf #{output_path}/.git`
    ec "cd #{output_path} && git init && git config user.email [email protected] && git config user.name 'John Smith'", :silent => true
  end

  begin
    ec "cd #{output_path} && git add . && git commit -m '#{message}'", :silent => true
  rescue; end
  
  res
end

.repo?(path) ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/overapp/util/git.rb', line 23

def repo?(path)
  path =~ /\.git/ || path =~ /file:\/\// || path =~ /git:\/\//
end