Commit 4dd5d9c8cce5c596a159277c464026cf0f50f1c4

Authored by Dmitriy Zaporozhets
1 parent c1c64d98

Issue #185 – Show branch name for commits on activities & dashboard pages

app/assets/stylesheets/projects.css.scss
@@ -344,4 +344,12 @@ body.project-page table .commit { @@ -344,4 +344,12 @@ body.project-page table .commit {
344 background: #2c5c66; 344 background: #2c5c66;
345 color:white; 345 color:white;
346 } 346 }
  347 + &.issue {
  348 + background: #D12F19;
  349 + color:white;
  350 + }
  351 + &.commit {
  352 + background: #2c5c66;
  353 + color:white;
  354 + }
347 } 355 }
app/models/repository.rb
@@ -73,7 +73,7 @@ class Repository @@ -73,7 +73,7 @@ class Repository
73 73
74 def fresh_commits(n = 10) 74 def fresh_commits(n = 10)
75 commits = heads.map do |h| 75 commits = heads.map do |h|
76 - repo.commits(h.name, n) 76 + repo.commits(h.name, n).each { |c| c.head = h }
77 end.flatten.uniq { |c| c.id } 77 end.flatten.uniq { |c| c.id }
78 78
79 commits.sort! do |x, y| 79 commits.sort! do |x, y|
@@ -85,7 +85,7 @@ class Repository @@ -85,7 +85,7 @@ class Repository
85 85
86 def commits_since(date) 86 def commits_since(date)
87 commits = heads.map do |h| 87 commits = heads.map do |h|
88 - repo.log(h.name, nil, :since => date) 88 + repo.log(h.name, nil, :since => date).each { |c| c.head = h }
89 end.flatten.uniq { |c| c.id } 89 end.flatten.uniq { |c| c.id }
90 90
91 commits.sort! do |x, y| 91 commits.sort! do |x, y|
app/views/dashboard/index.html.haml
@@ -27,6 +27,8 @@ @@ -27,6 +27,8 @@
27 %a.project-update{:href => dashboard_feed_path(project, update)} 27 %a.project-update{:href => dashboard_feed_path(project, update)}
28 = image_tag gravatar_icon(update.author_email), :class => "left", :width => 40 28 = image_tag gravatar_icon(update.author_email), :class => "left", :width => 40
29 %span.update-title 29 %span.update-title
  30 + - if update.kind_of?(Grit::Commit)
  31 + %span.tag.commit= update.head.name
30 = dashboard_feed_title(update) 32 = dashboard_feed_title(update)
31 %span.update-author 33 %span.update-author
32 %strong= update.author_name 34 %strong= update.author_name
app/views/layouts/project.html.haml
@@ -19,7 +19,7 @@ @@ -19,7 +19,7 @@
19 .git_url_wrapper 19 .git_url_wrapper
20 %input.git-url.text{:id => "", :name => "", :readonly => "", :type => "text", :value => @project.url_to_repo, :class => "one_click_select"} 20 %input.git-url.text{:id => "", :name => "", :readonly => "", :type => "text", :value => @project.url_to_repo, :class => "one_click_select"}
21 %aside 21 %aside
22 - = link_to "History", project_path(@project), :class => current_page?(:controller => "projects", :action => "show", :id => @project) ? "current" : nil 22 + = link_to "Activities", project_path(@project), :class => current_page?(:controller => "projects", :action => "show", :id => @project) ? "current" : nil
23 = link_to "Tree", tree_project_path(@project), :class => current_page?(:controller => "projects", :action => "tree", :id => @project) ? "current" : nil 23 = link_to "Tree", tree_project_path(@project), :class => current_page?(:controller => "projects", :action => "tree", :id => @project) ? "current" : nil
24 = link_to "Commits", project_commits_path(@project), :class => current_page?(:controller => "commits", :action => "index", :project_id => @project) ? "current" : nil 24 = link_to "Commits", project_commits_path(@project), :class => current_page?(:controller => "commits", :action => "index", :project_id => @project) ? "current" : nil
25 = link_to team_project_path(@project), :class => (current_page?(:controller => "projects", :action => "team", :id => @project) || controller.controller_name == "team_members") ? "current" : nil do 25 = link_to team_project_path(@project), :class => (current_page?(:controller => "projects", :action => "team", :id => @project) || controller.controller_name == "team_members") ? "current" : nil do
app/views/projects/_recent_commits.html.haml
@@ -22,7 +22,9 @@ @@ -22,7 +22,9 @@
22 - else 22 - else
23 = image_tag "no_avatar.png", :class => "left", :width => 40, :style => "padding-right:5px;" 23 = image_tag "no_avatar.png", :class => "left", :width => 40, :style => "padding-right:5px;"
24 .title 24 .title
25 - %p= link_to truncate(commit.safe_message, :length => 40), project_commit_path(@project, :id => commit.id) 25 + %p
  26 + %span.tag.commit= commit.head.name
  27 + = link_to truncate(commit.safe_message, :length => 40), project_commit_path(@project, :id => commit.id)
26 28
27 %span 29 %span
28 %span.author 30 %span.author
lib/commit_ext.rb
1 module CommitExt 1 module CommitExt
  2 + attr_accessor :head
  3 +
2 def safe_message 4 def safe_message
3 message.encode("UTF-8", 5 message.encode("UTF-8",
4 :invalid => :replace, 6 :invalid => :replace,
spec/requests/dashboard_spec.rb
@@ -22,6 +22,7 @@ describe "Dashboard" do @@ -22,6 +22,7 @@ describe "Dashboard" do
22 22
23 it "should have news feed" do 23 it "should have news feed" do
24 within "#news-feed" do 24 within "#news-feed" do
  25 + page.should have_content("master")
25 page.should have_content(@project.commit.author.name) 26 page.should have_content(@project.commit.author.name)
26 page.should have_content(@project.commit.safe_message) 27 page.should have_content(@project.commit.safe_message)
27 end 28 end
spec/requests/projects_spec.rb
@@ -72,10 +72,13 @@ describe "Projects" do @@ -72,10 +72,13 @@ describe "Projects" do
72 current_path.should == project_path(@project) 72 current_path.should == project_path(@project)
73 end 73 end
74 74
75 - it "should beahave like dashboard" do  
76 - page.should have_content("History") 75 + it "should beahave like activities page" do
  76 + within ".commit" do
  77 + page.should have_content("master")
  78 + page.should have_content(@project.commit.author.name)
  79 + page.should have_content(@project.commit.safe_message)
  80 + end
77 end 81 end
78 -  
79 end 82 end
80 83
81 describe "GET /projects/team" do 84 describe "GET /projects/team" do