Module: GitCli::Init

Included in:
Vcs
Defined in:
lib/git_cli/init.rb

Instance Method Summary collapse

Instance Method Details

#init(path, bare = false) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/git_cli/init.rb', line 26

def init(path, bare = false)
  # from Core module
  gpath = exe_path 

  cmd = []
  #cmd << "cd #{File.expand_path(path)}"
  #cmd << "&&"
  cmd << gpath
  cmd << "init"
  if bare
    cmd << "--bare"
  end
  cmd << File.expand_path(path)
 
  cmdln = cmd.join(" ")

  log_debug "Init : #{cmdln} " 

  os_exec(cmdln) do |st, res|
    [st.success?, res.strip]
  end
  
end

#reset(path) ⇒ Object

init



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/git_cli/init.rb', line 50

def reset(path)
  
  raise_if_empty(path, "Path should not be empty for reset operation", GitCliException)

  if File.exist?(path)
    Dir.entries(path).each do |f|
      if f == ".git"
        log_debug ".git directory found."
        FileUtils.rm_rf(f)
        log_debug ".git directory deleted"
        break
      end
    end
  end 

end