Module: GitCli::Log

Included in:
Workspace
Defined in:
lib/git_cli/log.rb

Constant Summary collapse

SIMPLE_LOG_DEFAULT_CONF =
{
  args: nil,          # args shall override ALL elements
  limit: "50",
  since: nil,         # log since/after this value
  until: nil,         # log until/before this value
  committed_by: nil,  # author of the commit. If given array shall be multiple
  format: "--oneline --pretty=format:\"%H | %ad | %an,%ce | %s | %b | %N\"",
}

Instance Method Summary collapse

Instance Method Details

#logs(opts = { }) ⇒ Object Also known as: log



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
60
61
62
63
64
65
66
# File 'lib/git_cli/log.rb', line 31

def logs(opts = { })

  check_vcs

  vopts = SIMPLE_LOG_DEFAULT_CONF.merge(opts)

  cmd = []
  cmd << "cd"
  cmd << @wsPath
  cmd << "&&"
  cmd << @vcs.exe_path
  cmd << "log"

  if not (vopts[:args].nil? or vopts[:args].empty?)
    cmd << vopts[:args]
  else
    cmd << "-n #{vopts[:limit]}" if not_empty?(vopts[:limit])
    cmd << "--since=#{vopts[:since]}" if not_empty?(vopts[:since])
    cmd << "--until=#{vopts[:until]}" if not_empty?(vopts[:until])
    cmd << "--committer=#{vopts[:committed_by]}" if not_empty?(vopts[:committed_by])
    cmd << vopts[:format] if not_empty?(vopts[:format])
  end

  cmdln = cmd.join(" ")
  log_debug "Logs : #{cmdln} "

  res = os_exec(cmdln) do |st, res|
    
    if st.success?
      [true, res.strip!]
    else
      [false, res]
    end
  end
   
end

#show_log(cid) ⇒ Object



69
70
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/log.rb', line 69

def show_log(cid)
  
  check_vcs

  raise_if_empty(cid, "Commit ID must be present for detail log discovery", GitCliException)
  cmd = []
  cmd << "cd"
  cmd << @wsPath
  cmd << "&&"
  cmd << @vcs.exe_path
  cmd << "show"
  cmd << cid

  cmdln = cmd.join(" ")
  log_debug "Show : #{cmdln}"

  res = os_exec(cmdln) do |st, res|
    
    if st.success?
      [true, res.strip!]
    else
      [false, res]
    end
  end

end