Skip to content

Commit 70aac4e

Browse files
committed
Introduce withGroupAsync()
1 parent 8975792 commit 70aac4e

File tree

2 files changed

+24
-9
lines changed

2 files changed

+24
-9
lines changed

src/analyze.ts

+12-9
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { addDiagnostic, makeDiagnostic } from "./diagnostics";
1818
import { EnvVar } from "./environment";
1919
import { FeatureEnablement, Feature } from "./feature-flags";
2020
import { isScannedLanguage, Language } from "./languages";
21-
import { Logger, withGroup } from "./logging";
21+
import { Logger, withGroupAsync } from "./logging";
2222
import { DatabaseCreationTimings, EventReport } from "./status-report";
2323
import { ToolsFeature } from "./tools-features";
2424
import { endTracingForCluster } from "./tracer-config";
@@ -256,14 +256,17 @@ export async function setupDiffInformedQueryRun(
256256
if (!(await features.getValue(Feature.DiffInformedQueries, codeql))) {
257257
return undefined;
258258
}
259-
return await withGroup("Generating diff range extension pack", async () => {
260-
const diffRanges = await getPullRequestEditedDiffRanges(
261-
baseRef,
262-
headRef,
263-
logger,
264-
);
265-
return writeDiffRangeDataExtensionPack(logger, diffRanges);
266-
});
259+
return await withGroupAsync(
260+
"Generating diff range extension pack",
261+
async () => {
262+
const diffRanges = await getPullRequestEditedDiffRanges(
263+
baseRef,
264+
headRef,
265+
logger,
266+
);
267+
return writeDiffRangeDataExtensionPack(logger, diffRanges);
268+
},
269+
);
267270
}
268271

269272
interface DiffThunkRange {

src/logging.ts

+12
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,18 @@ export function withGroup<T>(groupName: string, f: () => T): T {
4141
}
4242
}
4343

44+
export async function withGroupAsync<T>(
45+
groupName: string,
46+
f: () => Promise<T>,
47+
): Promise<T> {
48+
core.startGroup(groupName);
49+
try {
50+
return await f();
51+
} finally {
52+
core.endGroup();
53+
}
54+
}
55+
4456
/** Format a duration for use in logs. */
4557
export function formatDuration(durationMs: number) {
4658
if (durationMs < 1000) {

0 commit comments

Comments
 (0)