Commit 028244cc0c15bb963adc702f0bf03b8f744c8022

show last commit date in project overview repository listings

Commit diff

app/models/repository.rb

 
8181 end
8282 end
8383
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
8491 def create_new_repos_task
8592 Task.create!(:target_class => self.class.name,
8693 :command => parent ? "clone_git_repository" : "create_git_repository",
toggle raw diff

app/views/projects/show.html.erb

 
2727 <th>Name</th>
2828 <th>Owner</th>
2929 <th>Created</th>
30 <th>Last Commit</th>
3031 <th></th>
3132 </thead>
3233 <% @repositories.each do |repos| # fixme: need to graph the parent relation proper -%>
4242 <td>
4343 <%= repos.created_at.to_s(:short) -%>
4444 </td>
45 <td>
46 <%= repos.last_commit ? repos.last_commit.author.date.to_s(:short) : "<em>none</em>" -%>
47 </td>
4548 <td><%= link_to "browse", project_repository_browse_path(@project, repos) -%></td>
4649 </tr>
4750 <% else -%>
5858 <td>
5959 <%= repos.created_at.to_s(:short) -%>
6060 </td>
61 <td>
62 <%= repos.last_commit ? repos.last_commit.author.date.to_s(:short) : "<em>none</em>" -%>
63 </td>
6164 <td><%= link_to "browse", project_repository_browse_path(@project, repos) -%></td>
6265 </tr>
6366 <% end -%>
toggle raw diff

spec/models/repository_spec.rb

 
176176 task.arguments.first.should match(/#{@repository.gitdir}$/)
177177 end
178178
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
179190 describe "observers" do
180191 it "sends an email to the admin if there's a parent" do
181192 Mailer.should_receive(:deliver_new_repository_clone).with(@repository).and_return(true)
toggle raw diff