diff --git a/lib/views/status.erb b/lib/views/status.erb index 2cfa141..a19a08c 100644 --- a/lib/views/status.erb +++ b/lib/views/status.erb @@ -289,29 +289,7 @@ <% end%> - <% @graph_branches.each do |branch_hash| %> -

<%= branch_hash[:branch] %>

- - <% branch_hash[:log].reverse.each do |commit| %> -
- - - - — <%= commit[:date].strftime("%a, %d %b %Y, %H:%M %z") %> (<%= commit[:formatted_date] %> ago) - <% heads = "(#{commit[:heads].join(", ")})" if !commit[:heads].empty? %> - <% if commit[:heads].include? @current_branch %> - <%= heads.gsub(@current_branch, 'HEAD --> ' + @current_branch) %> - <% else %> - <%= heads %> - <% end %> -
-   | <%= commit[:message] + " - " + commit[:author] %> -
-
- <% end %> -
-
- <% end %> +
<%= @cli_graph_interactive %>
diff --git a/lib/web_git.rb b/lib/web_git.rb index 4fbc2b9..2fb3e74 100644 --- a/lib/web_git.rb +++ b/lib/web_git.rb @@ -70,6 +70,7 @@ class Server < Sinatra::Base graph = WebGit::Graph.new(git) @graph_hash = graph.to_hash + @cli_graph_interactive = graph.cli_graph @graph_branches = @graph_hash.sort do |branch_a, branch_b| branch_b[:log].last[:date] <=> branch_a[:log].last[:date] end diff --git a/lib/web_git/graph.rb b/lib/web_git/graph.rb index d0b0b84..cabb182 100644 --- a/lib/web_git/graph.rb +++ b/lib/web_git/graph.rb @@ -28,6 +28,31 @@ def to_hash @full_list end + def self.project_root + if defined?(Rails) + return Rails.root + end + + if defined?(Bundler) + return Bundler.root + end + + Dir.pwd + end + + def cli_graph + Dir.chdir(Graph.project_root) do + @cli_graph = `git log --oneline --decorate --graph --all` + all_commits = `git log --all --format=format:%H`.split("\n").map{|a| a.slice(0,7)} + + all_commits.each do |sha| + sha_button = "" + @cli_graph.gsub!(sha, sha_button) + end + end + @cli_graph + end + def has_untracked_changes? @git.diff.size > 0 end