Skip to content

Commit 896a692

Browse files
feat: per repo combine (#232)
1 parent 7bb2ff7 commit 896a692

File tree

4 files changed

+19
-8
lines changed

4 files changed

+19
-8
lines changed

src/main/kotlin/app/hashers/RepoHasher.kt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ class RepoHasher(private val api: Api,
4040
val (rehashes, authors, commitsCount) =
4141
CommitCrawler.fetchRehashesAndAuthors(git)
4242
localRepo.parseGitConfig(git.repository.config)
43-
val serverRepo = initServerRepo(localRepo, rehashes.last)
43+
val serverRepo = initServerRepo(localRepo, rehashes.last,
44+
processEntryId)
4445

4546
// Get repo setup (commits, emails to hash) from server.
4647
postRepoFromServer(serverRepo)
@@ -148,11 +149,13 @@ class RepoHasher(private val api: Api,
148149
}
149150

150151
private fun initServerRepo(localRepo: LocalRepo,
151-
initCommitRehash: String): Repo {
152+
initCommitRehash: String,
153+
processEntryId: Int?): Repo {
152154
val rehash = RepoHelper.calculateRepoRehash(initCommitRehash, localRepo)
153155
val repo = Repo(initialCommitRehash = initCommitRehash,
154156
rehash = rehash,
155-
meta = localRepo.meta)
157+
meta = localRepo.meta,
158+
processEntryId = processEntryId ?: 0)
156159
Logger.debug { "Local repo path: ${localRepo.path}" }
157160
Logger.debug { "Repo remote: ${localRepo.remoteOrigin}" }
158161
Logger.debug { "Repo rehash: $rehash" }

src/main/kotlin/app/model/ProcessEntry.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ data class ProcessEntry(
2626

2727
fun getProto(): Protos.ProcessEntry {
2828
return Protos.ProcessEntry.newBuilder()
29-
.setId(id)
30-
.setStatus(status)
31-
.setErrorCode(errorCode)
32-
.build()
29+
.setId(id)
30+
.setStatus(status)
31+
.setErrorCode(errorCode)
32+
.build()
3333
}
3434

3535
fun serialize(): ByteArray {

src/main/kotlin/app/model/Repo.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,18 @@ data class Repo(
2323
var commits: List<Commit> = listOf(),
2424

2525
// Meta info about repo. Is not used for a locally run app.
26-
var meta: RepoMeta = RepoMeta()
26+
var meta: RepoMeta = RepoMeta(),
27+
28+
// Processing session id, used to check the processing status.
29+
var processEntryId: Int = 0
2730
) {
2831
@Throws(InvalidParameterException::class)
2932
constructor(proto: Protos.Repo) : this() {
3033
rehash = proto.rehash
3134
initialCommitRehash = proto.initialCommitRehash
3235
emails = proto.emailsList
3336
commits = proto.commitsList.map { Commit(it) }
37+
processEntryId = proto.processEntryId
3438
}
3539

3640
@Throws(InvalidProtocolBufferException::class)
@@ -45,6 +49,7 @@ data class Repo(
4549
.addAllEmails(emails)
4650
.addAllCommits(commits.map { it.getProto() })
4751
.setMeta(meta.getProto())
52+
.setProcessEntryId(processEntryId)
4853
.build()
4954
}
5055

src/main/proto/sourcerer.proto

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,9 @@ message Repo {
117117

118118
// Meta info about repo. Is not used for a locally run app.
119119
RepoMeta meta = 6;
120+
121+
// Processing session id, used to check the processing status.
122+
uint32 process_entry_id = 7;
120123
}
121124

122125
// Meta info about repo. Is not used for a locally run app.

0 commit comments

Comments
 (0)