Skip to content

Commit d30cd25

Browse files
authored
Logs improvements (#89)
1 parent 7ca5b4e commit d30cd25

2 files changed

Lines changed: 24 additions & 11 deletions

File tree

src/git.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -402,10 +402,13 @@ export function getCommitContextsBetweenShas(
402402
const commits = runLog(args, cwd);
403403

404404
if (commits.length === 0) {
405-
verbose(
406-
`No commits found between ${fromSha.slice(0, 7)}..${toSha.slice(0, 7)}` +
407-
(includePaths?.length ? ` with paths: ${includePaths.join(", ")}` : ""),
408-
);
405+
if (fromSha === toSha) {
406+
const pathFilter = includePaths?.length ? ` include paths: ${includePaths.join(", ")}` : "";
407+
verbose(`Commit ${toSha.slice(0, 7)} did not match${pathFilter}`);
408+
} else {
409+
const pathFilter = includePaths?.length ? ` matching include paths: ${includePaths.join(", ")}` : "";
410+
verbose(`No commits found between ${fromSha.slice(0, 7)}..${toSha.slice(0, 7)}${pathFilter}`);
411+
}
409412
}
410413

411414
return commits;

src/index.ts

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -194,16 +194,26 @@ async function syncCommand(): Promise<{
194194
verbose(`Inspecting current commit (${currentCommit.commit})`);
195195
}
196196
} else {
197-
info(
198-
`Found ${commits.length} ${pluralize(commits.length, "commit")} between ${latestSha.slice(0, 7)} and ${currentCommit.commit.slice(0, 7)}`,
199-
);
197+
const commitNoun = effectiveIncludePaths?.length ? "matching commit" : "commit";
198+
if (latestSha === currentCommit.commit) {
199+
info(
200+
`Inspected current commit ${currentCommit.commit.slice(0, 7)}; found ${commits.length} ${pluralize(commits.length, commitNoun)}`,
201+
);
202+
} else {
203+
info(
204+
`Found ${commits.length} ${pluralize(commits.length, commitNoun)} between ${latestSha.slice(0, 7)} and ${currentCommit.commit.slice(0, 7)}`,
205+
);
206+
}
200207
}
201208

202209
if (commits.length === 0) {
203-
const reason = effectiveIncludePaths?.length
204-
? `matching ${JSON.stringify(effectiveIncludePaths)}`
205-
: "in the computed range";
206-
info(`No commits found ${reason}. Skipping release creation.`);
210+
if (effectiveIncludePaths?.length) {
211+
info(
212+
`No matching commits found for include paths: ${effectiveIncludePaths.join(", ")}. Skipping release creation.`,
213+
);
214+
} else {
215+
info("No commits found in the computed range. Skipping release creation.");
216+
}
207217
return null;
208218
}
209219

0 commit comments

Comments
 (0)