Skip to content

Commit

Permalink
Merge pull request #787 from launchableinc/missing-object
Browse files Browse the repository at this point in the history
Improve a warning message for missing object errors
  • Loading branch information
kohsuke authored Feb 26, 2024
2 parents c9ceb1a + 00e4bc3 commit 040ec82
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
Binary file modified launchable/jar/exe_deploy.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ public class CommitGraphCollector {

private boolean dryRun;

private boolean warnMissingObject;

private String dryRunPrefix() {
if (!dryRun) {
return "";
Expand Down Expand Up @@ -408,7 +410,18 @@ private JSCommit transform(RevCommit r) throws IOException {
for (DiffEntry de : files) {
try {
changes.add(diff.process(de));
} catch (UncheckedIOException e) {
} catch (MissingObjectException e) {
// in a partially cloned repository, BLOBs might be unavailable and that'd result in MissingObjectException
System.err.printf("Warning: %s is missing. Skipping diff calculation for %s -> %s%n",
e.getObjectId().abbreviate(7).name(),
p.abbreviate(7).name(),
r.abbreviate(7).name()
);
if (!warnMissingObject) {
warnMissingObject = true;
System.err.println("See https://www.launchableinc.com/missing-git-object-during-commit-collection");
}
} catch (IOException e) {
logger.warn("Failed to process a change to a file", e);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,13 @@ public CountingDiffFormatter(Repository git) {
}

/** Entry point to compute a file level change. */
JSFileChange process(DiffEntry de) {
JSFileChange process(DiffEntry de) throws IOException {
add = 0;
del = 0;

// This call internally eventually reaches to format(EditList, RawTest, RawText) that counts the
// numbers.
try {
format(de);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
format(de);

JSFileChange fc = new JSFileChange();
fc.setLinesAdded(add);
Expand Down

0 comments on commit 040ec82

Please sign in to comment.