26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/gifts/commit_table.rb', line 26
def add(git_repo, db_repo)
result = []
offset = 0
count = 100
processed_prev_commit = false
begin
commits = Grit::Commit.find_all(git_repo, nil, { all: true, date_order: true, max_count: count, skip: offset })
commits.each do |git_commit|
key = db_repo.id.to_s + ":" + git_commit.id
if key == db_repo.last_commit_key
processed_prev_commit = true
break
else
author = @db.users.add(git_commit.author.name)
committer = @db.users.add(git_commit.committer.name)
db_commit =
table[key] ||
table.add(
key,
author: author,
authored_date: git_commit.authored_date,
committer: committer,
committed_date: git_commit.committed_date,
message: git_commit.message,
repo: db_repo,
rev: git_commit.id,
status: StatusProcessing
)
db_diffs = @db.diffs.add(git_commit, db_commit)
result << db_commit
end
end
offset += count
end until commits.count == 0 || processed_prev_commit
result
end
|