Module: GitCli::Repos
- Included in:
- Workspace
- Defined in:
- lib/git_cli/repos.rb
Defined Under Namespace
Classes: ReposError
Instance Method Summary collapse
-
#add_remote(name, url) ⇒ Object
remote_config.
- #remote_config ⇒ Object
-
#remove_remote(name) ⇒ Object
(also: #remove_del)
add_remote.
Instance Method Details
#add_remote(name, url) ⇒ Object
remote_config
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/git_cli/repos.rb', line 61 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] res.strip else raise ReposError, res.strip #[false, res.strip] end end end |
#remote_config ⇒ Object
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 54 55 56 57 58 59 |
# File 'lib/git_cli/repos.rb', line 23 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(" ") remotes[ls[0]] = { } if is_empty?(remotes[ls[0]]) rem = remotes[ls[0]] type = lss[-1] type.gsub!("(","").gsub!(")","") rem[type] = lss[0] end #[true, remotes] remotes else raise ReposError, res.strip #[false, res] end end end |
#remove_remote(name) ⇒ Object Also known as: remove_del
add_remote
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/git_cli/repos.rb', line 94 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] res.strip else raise ReposError, res.strip #[false, res.strip] end end end |