module GitCli::AddCommit

Public Instance Methods

add(paths)
Alias for: add_to_staging
add_staging(paths)
Alias for: add_to_staging
add_to_staging(paths) click to toggle source
# 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
Also aliased as: add, add_staging
commit(message, opts = { }) click to toggle source
# File lib/git_cli/add_commit.rb, line 96
def commit(message, opts = { })
  check_vcs

  files = opts[:files] || []
  [files] if not files.is_a?(Array)
  # have to escape the message for command line purposes
  msg = message.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) click to toggle source
# 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 = message.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) click to toggle source
# 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
Also aliased as: remove_staging
remove_from_vcs(paths) click to toggle source
# 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
remove_staging(paths)
Alias for: remove_from_staging