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 344 background: #2c5c66;
345 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 73  
74 74 def fresh_commits(n = 10)
75 75 commits = heads.map do |h|
76   - repo.commits(h.name, n)
  76 + repo.commits(h.name, n).each { |c| c.head = h }
77 77 end.flatten.uniq { |c| c.id }
78 78  
79 79 commits.sort! do |x, y|
... ... @@ -85,7 +85,7 @@ class Repository
85 85  
86 86 def commits_since(date)
87 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 89 end.flatten.uniq { |c| c.id }
90 90  
91 91 commits.sort! do |x, y|
... ...
app/views/dashboard/index.html.haml
... ... @@ -27,6 +27,8 @@
27 27 %a.project-update{:href => dashboard_feed_path(project, update)}
28 28 = image_tag gravatar_icon(update.author_email), :class => "left", :width => 40
29 29 %span.update-title
  30 + - if update.kind_of?(Grit::Commit)
  31 + %span.tag.commit= update.head.name
30 32 = dashboard_feed_title(update)
31 33 %span.update-author
32 34 %strong= update.author_name
... ...
app/views/layouts/project.html.haml
... ... @@ -19,7 +19,7 @@
19 19 .git_url_wrapper
20 20 %input.git-url.text{:id => "", :name => "", :readonly => "", :type => "text", :value => @project.url_to_repo, :class => "one_click_select"}
21 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 23 = link_to "Tree", tree_project_path(@project), :class => current_page?(:controller => "projects", :action => "tree", :id => @project) ? "current" : nil
24 24 = link_to "Commits", project_commits_path(@project), :class => current_page?(:controller => "commits", :action => "index", :project_id => @project) ? "current" : nil
25 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 22 - else
23 23 = image_tag "no_avatar.png", :class => "left", :width => 40, :style => "padding-right:5px;"
24 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 29 %span
28 30 %span.author
... ...
lib/commit_ext.rb
1 1 module CommitExt
  2 + attr_accessor :head
  3 +
2 4 def safe_message
3 5 message.encode("UTF-8",
4 6 :invalid => :replace,
... ...
spec/requests/dashboard_spec.rb
... ... @@ -22,6 +22,7 @@ describe "Dashboard" do
22 22  
23 23 it "should have news feed" do
24 24 within "#news-feed" do
  25 + page.should have_content("master")
25 26 page.should have_content(@project.commit.author.name)
26 27 page.should have_content(@project.commit.safe_message)
27 28 end
... ...
spec/requests/projects_spec.rb
... ... @@ -72,10 +72,13 @@ describe "Projects" do
72 72 current_path.should == project_path(@project)
73 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 81 end
78   -
79 82 end
80 83  
81 84 describe "GET /projects/team" do
... ...