Module: GitCli::Repos

Included in:
Gvcs::Workspace
Defined in:
lib/git_cli/repos.rb

Instance Method Summary collapse

Instance Method Details

#add_remote(name, url) ⇒ Object

remote_config



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/git_cli/repos.rb', line 55

def add_remote(name, url)

  raise_if_empty(name, "Remote name cannot be empty to add", GitCliException)
  raise_if_empty(url, "Remote URL cannot be empty to add", GitCliException)

  check_vcs

  cmd = []
  cmd << "cd"
  cmd << @wsPath
  cmd << "&&"
  cmd << @vcs.exe_path
  cmd << "remote"
  cmd << "add"
  cmd << name
  cmd << url

  cmdln = cmd.join(" ")
  log_debug "Add remote config : #{cmdln}"
  res = os_exec(cmdln) do |st, res|
    
    if st.success?
      [true, res.strip]
    else
      [false, res.strip]
    end
  end


end

#remote_configObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/git_cli/repos.rb', line 22

def remote_config
  check_vcs

  cmd = []
  cmd << "cd"
  cmd << @wsPath
  cmd << "&&"
  cmd << @vcs.exe_path
  cmd << "remote -vv"

  cmdln = cmd.join(" ")
  log_debug "Remote config : #{cmdln}"
  res = os_exec(cmdln) do |st, res|
    
    if st.success?

      remotes = { }
      res.each_line do |l|
        ls = l.split("\t")
        lss = ls[1].split(" ")
        if not remotes.keys.include?(ls[0])
          remotes[ls[0]] = lss[0]
        end
      end

      [true, remotes]
    else
      [false, res]
    end
  end
  
end

#remove_remote(name) ⇒ Object

add_remote



86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/git_cli/repos.rb', line 86

def remove_remote(name)

  raise_if_empty(name, "Remote name cannot be empty to remove", GitCliException)

  check_vcs

  cmd = []
  cmd << "cd"
  cmd << @wsPath
  cmd << "&&"
  cmd << @vcs.exe_path
  cmd << "remote"
  cmd << "remove"
  cmd << name

  cmdln = cmd.join(" ")
  log_debug "Remove remote config : #{cmdln}"
  res = os_exec(cmdln) do |st, res|
    
    if st.success?
      [true, res.strip]
    else
      [false, res.strip]
    end
  end

end