From ae8b295d0f272f4c94ebd7c3205d141e56586cb4 Mon Sep 17 00:00:00 2001 From: Robin Shen Date: Tue, 24 Sep 2024 12:38:53 +0800 Subject: [PATCH] chore: Add more info for missing object id in commit indexer --- .../server/xodus/DefaultCommitInfoManager.java | 14 +++++++++----- .../plugin/report/clover/CloverReportParser.java | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/server-core/src/main/java/io/onedev/server/xodus/DefaultCommitInfoManager.java b/server-core/src/main/java/io/onedev/server/xodus/DefaultCommitInfoManager.java index 91ab4af263..60098f365d 100644 --- a/server-core/src/main/java/io/onedev/server/xodus/DefaultCommitInfoManager.java +++ b/server-core/src/main/java/io/onedev/server/xodus/DefaultCommitInfoManager.java @@ -4,10 +4,7 @@ import com.google.common.base.Splitter; import com.google.common.collect.Sets; import io.onedev.commons.loader.ManagedSerializedForm; -import io.onedev.commons.utils.FileUtils; -import io.onedev.commons.utils.PathUtils; -import io.onedev.commons.utils.StringUtils; -import io.onedev.commons.utils.TarUtils; +import io.onedev.commons.utils.*; import io.onedev.k8shelper.KubernetesHelper; import io.onedev.server.OneDev; import io.onedev.server.cluster.ClusterManager; @@ -46,6 +43,7 @@ import jetbrains.exodus.env.Transaction; import jetbrains.exodus.env.TransactionalComputable; import org.apache.commons.lang3.SerializationUtils; +import org.eclipse.jgit.errors.MissingObjectException; import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.Ref; @@ -1040,7 +1038,13 @@ private void collect(Long projectId) { refs.addAll(projectManager.getRepository(projectId).getRefDatabase().getRefsByPrefix(Constants.R_TAGS)); for (Ref ref : refs) { - RevObject revObj = revWalk.peel(revWalk.parseAny(ref.getObjectId())); + RevObject revObj; + try { + revObj = revWalk.peel(revWalk.parseAny(ref.getObjectId())); + } catch (MissingObjectException e) { + var message = String.format("%s (project id: %d, ref: %s)", e.getMessage(), projectId, ref.getName()); + throw new ExplicitException(message); + } if (revObj instanceof RevCommit) { RevCommit commit = (RevCommit) revObj; works.add(new CollectingWork(PRIORITY, commit.copy(), diff --git a/server-plugin/server-plugin-report-clover/src/main/java/io/onedev/server/plugin/report/clover/CloverReportParser.java b/server-plugin/server-plugin-report-clover/src/main/java/io/onedev/server/plugin/report/clover/CloverReportParser.java index 52d44b24ab..7a97987515 100644 --- a/server-plugin/server-plugin-report-clover/src/main/java/io/onedev/server/plugin/report/clover/CloverReportParser.java +++ b/server-plugin/server-plugin-report-clover/src/main/java/io/onedev/server/plugin/report/clover/CloverReportParser.java @@ -36,7 +36,7 @@ public static CoverageReport parse(Build build, Document doc, TaskLogger logger) } } - var pair = parsePackageCoverage("[no name]", projectElement.elements("file"), build, logger); + var pair = parsePackageCoverage("[root]", projectElement.elements("file"), build, logger); var packageCoverage = pair.getLeft(); if (!packageCoverage.getFileCoverages().isEmpty()) { packageCoverages.add(packageCoverage);