Commit e5bbefc98025b1b9f67b8635807d43f60be55c30
1 parent
1b85cbc6
Exists in
master
and in
4 other branches
change find_or_first to work with default branch
Showing
2 changed files
with
3 additions
and
3 deletions
Show diff stats
app/models/commit.rb
| @@ -23,11 +23,11 @@ class Commit | @@ -23,11 +23,11 @@ class Commit | ||
| 23 | 23 | ||
| 24 | 24 | ||
| 25 | class << self | 25 | class << self |
| 26 | - def find_or_first(repo, commit_id = nil) | 26 | + def find_or_first(repo, commit_id = nil, root_ref) |
| 27 | commit = if commit_id | 27 | commit = if commit_id |
| 28 | repo.commit(commit_id) | 28 | repo.commit(commit_id) |
| 29 | else | 29 | else |
| 30 | - repo.commits.first | 30 | + repo.commits(root_ref).first |
| 31 | end | 31 | end |
| 32 | Commit.new(commit) if commit | 32 | Commit.new(commit) if commit |
| 33 | end | 33 | end |
app/models/project/repository_trait.rb
| @@ -8,7 +8,7 @@ module Project::RepositoryTrait | @@ -8,7 +8,7 @@ module Project::RepositoryTrait | ||
| 8 | end | 8 | end |
| 9 | 9 | ||
| 10 | def commit(commit_id = nil) | 10 | def commit(commit_id = nil) |
| 11 | - Commit.find_or_first(repo, commit_id) | 11 | + Commit.find_or_first(repo, commit_id, root_ref) |
| 12 | end | 12 | end |
| 13 | 13 | ||
| 14 | def fresh_commits(n = 10) | 14 | def fresh_commits(n = 10) |