Skip to content

Commit

Permalink
Update Repository model to use commit count for updates
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew committed Feb 7, 2024
1 parent 89c97e9 commit 9c332e7
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions app/models/repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def count_commits
counts = count_commits_internal(dir)
commit_hashes = fetch_commits_internal(repo)
Commit.upsert_all(commit_hashes) unless commit_hashes.empty?
update(updates)
update(counts)
end
rescue => e
# TODO record error in clone (likely missing repo but also maybe host downtime)
Expand Down Expand Up @@ -357,10 +357,14 @@ def fetch_commits
commits
end

def commits_count
commits.count
end

def fetch_commits_internal(repo)
commits = []
walker = Rugged::Walker.new(repo)
walker.hide(repo.lookup(last_synced_commit)) if last_synced_commit
walker.hide(repo.lookup(last_synced_commit)) if last_synced_commit && commits_count > 0
walker.sorting(Rugged::SORT_DATE)
walker.push(repo.head.target)
walker.each do |commit|
Expand Down

0 comments on commit 9c332e7

Please sign in to comment.