Module: GitCli::AddCommit
- Included in:
- Gvcs::Workspace
- Defined in:
- lib/git_cli/add_commit.rb
Instance Method Summary collapse
- #add_to_staging(paths) ⇒ Object (also: #add, #add_staging)
-
#commit(message, opts = { }) ⇒ Object
remove_from_vcs.
-
#commit_all(msg) ⇒ Object
commit.
- #remove_from_staging(paths) ⇒ Object (also: #remove_staging)
- #remove_from_vcs(paths) ⇒ Object
Instance Method Details
#add_to_staging(paths) ⇒ Object Also known as: add, add_staging
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/git_cli/add_commit.rb', line 21 def add_to_staging(paths) check_vcs raise_if_empty(paths, "Given path to add is empty", GitCliException) paths = [paths] if not paths.is_a?(Array) cmd = [] cmd << "cd" cmd << @wsPath cmd << "&&" cmd << @vcs.exe_path cmd << "add" cmd.append(paths) cmdln = cmd.join " " log_debug "Add : #{cmdln}" os_exec(cmdln) do |st, res| [st.success?, res.strip] end end |
#commit(message, opts = { }) ⇒ Object
remove_from_vcs
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 123 124 |
# File 'lib/git_cli/add_commit.rb', line 96 def commit(, opts = { }) check_vcs files = opts[:files] || [] [files] if not files.is_a?(Array) # have to escape the message for command line purposes msg = .gsub("\"","\\\"").gsub("\\","\\\\") cmd = [] cmd << "cd" cmd << @wsPath cmd << "&&" cmd << @vcs.exe_path cmd << "commit" if not_empty?(files) cmd << files.join(" ") end cmd << "-m" cmd << "\"#{msg}\"" cmdln = cmd.join " " log_debug "Commit : #{cmdln}" os_exec(cmdln) do |st, res| [st.success?, res.strip] end end |
#commit_all(msg) ⇒ Object
commit
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/git_cli/add_commit.rb', line 126 def commit_all(msg) check_vcs # have to escape the message for command line purposes msg = .gsub("\"","\\\"").gsub("\\","\\\\") cmd = [] cmd << "cd" cmd << @wsPath cmd << "&&" cmd << @vcs.exe_path cmd << "commit" cmd << "-am" cmd << msg cmdln = cmd.join " " log_debug "Commit All : #{cmdln}" os_exec(cmdln) do |st, res| [st.success?, res.strip] end end |
#remove_from_staging(paths) ⇒ Object Also known as: remove_staging
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/git_cli/add_commit.rb', line 46 def remove_from_staging(paths) check_vcs raise_if_empty(paths, "Given path to reset is empty", GitCliException) paths = [paths] if not paths.is_a?(Array) cmd = [] cmd << "cd" cmd << @wsPath cmd << "&&" cmd << @vcs.exe_path cmd << "reset" cmd.append(paths) cmdln = cmd.join " " log_debug "reset : #{cmdln}" os_exec(cmdln) do |st, res| [st.success?, res.strip] end end |
#remove_from_vcs(paths) ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/git_cli/add_commit.rb', line 71 def remove_from_vcs(paths) check_vcs raise_if_empty(paths, "Given path to remove from VCS is empty", GitCliException) paths = [paths] if not paths.is_a?(Array) cmd = [] cmd << "cd" cmd << @wsPath cmd << "&&" cmd << @vcs.exe_path cmd << "rm --cached" cmd.append(paths) cmdln = cmd.join " " log_debug "Remove from git version control : #{cmdln}" os_exec(cmdln) do |st, res| [st.success?, res.strip] end end |