Commit 028244cc0c15bb963adc702f0bf03b8f744c8022
- Date: Sun Jan 20 16:57:00 +0000 2008
- Committer: Johan Sørensen (johan@johansorensen.com)
- Author: Johan Sørensen (johan@johansorensen.com)
- Commit SHA1: 028244cc0c15bb963adc702f0bf03b8f744c8022
- Tree SHA1: d0913ed8dc0a6d1039d43028783fc2a22757e427
show last commit date in project overview repository listings
Commit diff
| |   |
| 81 | 81 | end |
| 82 | 82 | end |
| 83 | 83 | |
| 84 | def last_commit |
| 85 | if has_commits? |
| 86 | @last_commit ||= Git.bare(full_repository_path).log(1).first |
| 87 | end |
| 88 | @last_commit |
| 89 | end |
| 90 | |
| 84 | 91 | def create_new_repos_task |
| 85 | 92 | Task.create!(:target_class => self.class.name, |
| 86 | 93 | :command => parent ? "clone_git_repository" : "create_git_repository", |
| toggle raw diff |
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -81,6 +81,13 @@ class Repository < ActiveRecord::Base
end
end
+ def last_commit
+ if has_commits?
+ @last_commit ||= Git.bare(full_repository_path).log(1).first
+ end
+ @last_commit
+ end
+
def create_new_repos_task
Task.create!(:target_class => self.class.name,
:command => parent ? "clone_git_repository" : "create_git_repository", |
| |   |
| 27 | 27 | <th>Name</th> |
| 28 | 28 | <th>Owner</th> |
| 29 | 29 | <th>Created</th> |
| 30 | <th>Last Commit</th> |
| 30 | 31 | <th></th> |
| 31 | 32 | </thead> |
| 32 | 33 | <% @repositories.each do |repos| # fixme: need to graph the parent relation proper -%> |
| … | … | |
| 42 | 42 | <td> |
| 43 | 43 | <%= repos.created_at.to_s(:short) -%> |
| 44 | 44 | </td> |
| 45 | <td> |
| 46 | <%= repos.last_commit ? repos.last_commit.author.date.to_s(:short) : "<em>none</em>" -%> |
| 47 | </td> |
| 45 | 48 | <td><%= link_to "browse", project_repository_browse_path(@project, repos) -%></td> |
| 46 | 49 | </tr> |
| 47 | 50 | <% else -%> |
| … | … | |
| 58 | 58 | <td> |
| 59 | 59 | <%= repos.created_at.to_s(:short) -%> |
| 60 | 60 | </td> |
| 61 | <td> |
| 62 | <%= repos.last_commit ? repos.last_commit.author.date.to_s(:short) : "<em>none</em>" -%> |
| 63 | </td> |
| 61 | 64 | <td><%= link_to "browse", project_repository_browse_path(@project, repos) -%></td> |
| 62 | 65 | </tr> |
| 63 | 66 | <% end -%> |
| toggle raw diff |
--- a/app/views/projects/show.html.erb
+++ b/app/views/projects/show.html.erb
@@ -27,6 +27,7 @@
<th>Name</th>
<th>Owner</th>
<th>Created</th>
+ <th>Last Commit</th>
<th></th>
</thead>
<% @repositories.each do |repos| # fixme: need to graph the parent relation proper -%>
@@ -41,6 +42,9 @@
<td>
<%= repos.created_at.to_s(:short) -%>
</td>
+ <td>
+ <%= repos.last_commit ? repos.last_commit.author.date.to_s(:short) : "<em>none</em>" -%>
+ </td>
<td><%= link_to "browse", project_repository_browse_path(@project, repos) -%></td>
</tr>
<% else -%>
@@ -54,6 +58,9 @@
<td>
<%= repos.created_at.to_s(:short) -%>
</td>
+ <td>
+ <%= repos.last_commit ? repos.last_commit.author.date.to_s(:short) : "<em>none</em>" -%>
+ </td>
<td><%= link_to "browse", project_repository_browse_path(@project, repos) -%></td>
</tr>
<% end -%> |
| |   |
| 176 | 176 | task.arguments.first.should match(/#{@repository.gitdir}$/) |
| 177 | 177 | end |
| 178 | 178 | |
| 179 | it "has one recent commit" do |
| 180 | @repository.save! |
| 181 | repos_mock = mock("Git mock") |
| 182 | commit_mock = mock("Git::Commit mock") |
| 183 | repos_mock.should_receive(:log).with(1).and_return(commit_mock) |
| 184 | commit_mock.should_receive(:first).and_return(commit_mock) |
| 185 | Git.should_receive(:bare).with(@repository.full_repository_path).and_return(repos_mock) |
| 186 | @repository.stub!(:has_commits?).and_return(true) |
| 187 | @repository.last_commit.should == commit_mock |
| 188 | end |
| 189 | |
| 179 | 190 | describe "observers" do |
| 180 | 191 | it "sends an email to the admin if there's a parent" do |
| 181 | 192 | Mailer.should_receive(:deliver_new_repository_clone).with(@repository).and_return(true) |
| toggle raw diff |
--- a/spec/models/repository_spec.rb
+++ b/spec/models/repository_spec.rb
@@ -176,6 +176,17 @@ describe Repository do
task.arguments.first.should match(/#{@repository.gitdir}$/)
end
+ it "has one recent commit" do
+ @repository.save!
+ repos_mock = mock("Git mock")
+ commit_mock = mock("Git::Commit mock")
+ repos_mock.should_receive(:log).with(1).and_return(commit_mock)
+ commit_mock.should_receive(:first).and_return(commit_mock)
+ Git.should_receive(:bare).with(@repository.full_repository_path).and_return(repos_mock)
+ @repository.stub!(:has_commits?).and_return(true)
+ @repository.last_commit.should == commit_mock
+ end
+
describe "observers" do
it "sends an email to the admin if there's a parent" do
Mailer.should_receive(:deliver_new_repository_clone).with(@repository).and_return(true) |