module GitCli::Diff
Public Instance Methods
diff()
click to toggle source
# File lib/git_cli/diff.rb, line 22 def diff diff_branch("","") end
diff_branch(b1, b2, opts = { head_to_head: true })
click to toggle source
head_to_head = true == “git diff b1..b2” -> compare head-to-head of the given two branches
# File lib/git_cli/diff.rb, line 34 def diff_branch(b1, b2, opts = { head_to_head: true }) if not ((b1.nil? or b1.empty?) and (b2.nil? or b2.empty?)) diff_common({ args: "#{b1}..#{b2}", log_tag: "Diff against head of two branches" }) else diff_common({ args: "", log_tag: "Diff workspace with last commit" }) end end
diff_common(opts = { })
click to toggle source
# File lib/git_cli/diff.rb, line 58 def diff_common(opts = { }) check_vcs cmd = [] cmd << "cd" cmd << @wsPath cmd << "&&" cmd << @vcs.exe_path cmd << "diff" if not (opts[:args].nil? or opts[:args].empty?) cmd << opts[:args] end cmdln = cmd.join(" ") log_debug "#{opts[:log_tag]} : #{cmdln} " res = os_exec(cmdln) do |st, res| if st.success? [true, res.strip!] else [false, res] end end end
diff_file_with_last_commit(file)
click to toggle source
# File lib/git_cli/diff.rb, line 26 def diff_file_with_last_commit(file) diff_common({ args: "#{file}", log_tag: "Diff file compare with last commit" }) end
Also aliased as: diff_file
diff_index_with_last_commit()
click to toggle source
this show different for item already put inside 'git add'
# File lib/git_cli/diff.rb, line 52 def diff_index_with_last_commit diff_common({ args: "--cached", log_tag: "Diff index (file added with 'git add') with last commit" }) end
diff_working_with_last_commit()
click to toggle source
changes to push to repos if 'git commit -a' is run
# File lib/git_cli/diff.rb, line 45 def diff_working_with_last_commit diff_common({ args: "HEAD^ HEAD", log_tag: "Diff working with last commit" }) end