Address feedback: cache git version, improve error handling, add telemetry

- Cache the git version to avoid recomputing on repeated calls
- Refactor getGitVersion to getGitVersionOrThrow with detailed errors
- Add getGitVersion that logs errors and handles caching
- Add makeTelemetryDiagnostic helper to diagnostics.ts
- Add logGitVersionTelemetry function to log git version telemetry
- Call logGitVersionTelemetry in init-action.ts
- Add resetCachedGitVersion for testing
- Update tests to work with new function signatures and caching

Co-authored-by: henrymercer <14129055+henrymercer@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2025-12-16 17:19:46 +00:00
parent fc2bbb041e
commit c3dc529aef
15 changed files with 694 additions and 480 deletions

View File

@@ -83601,14 +83601,41 @@ var actionsCache = __toESM(require_cache3());
var core6 = __toESM(require_core());
// src/git-utils.ts
var core7 = __toESM(require_core());
var core8 = __toESM(require_core());
var toolrunner2 = __toESM(require_toolrunner());
var io3 = __toESM(require_io2());
var semver2 = __toESM(require_semver2());
// src/logging.ts
var core7 = __toESM(require_core());
function getActionsLogger() {
return {
debug: core7.debug,
info: core7.info,
warning: core7.warning,
error: core7.error,
isDebug: core7.isDebug,
startGroup: core7.startGroup,
endGroup: core7.endGroup
};
}
function formatDuration(durationMs) {
if (durationMs < 1e3) {
return `${durationMs}ms`;
}
if (durationMs < 60 * 1e3) {
return `${(durationMs / 1e3).toFixed(1)}s`;
}
const minutes = Math.floor(durationMs / (60 * 1e3));
const seconds = Math.floor(durationMs % (60 * 1e3) / 1e3);
return `${minutes}m${seconds}s`;
}
// src/git-utils.ts
var runGitCommand = async function(workingDirectory, args, customErrorMessage) {
let stdout = "";
let stderr = "";
core7.debug(`Running git command: git ${args.join(" ")}`);
core8.debug(`Running git command: git ${args.join(" ")}`);
try {
await new toolrunner2.ToolRunner(await io3.which("git", true), args, {
silent: true,
@@ -83628,7 +83655,7 @@ var runGitCommand = async function(workingDirectory, args, customErrorMessage) {
if (stderr.includes("not a git repository")) {
reason = "The checkout path provided to the action does not appear to be a git repository.";
}
core7.info(`git call failed. ${customErrorMessage} Error: ${reason}`);
core8.info(`git call failed. ${customErrorMessage} Error: ${reason}`);
throw error3;
}
};
@@ -83739,7 +83766,7 @@ async function getRef() {
) !== head;
if (hasChangedRef) {
const newRef = ref.replace(pull_ref_regex, "refs/pull/$1/head");
core7.debug(
core8.debug(
`No longer on merge commit, rewriting ref from ${ref} to ${newRef}.`
);
return newRef;
@@ -83764,31 +83791,6 @@ async function isAnalyzingDefaultBranch() {
return currentRef === defaultBranch;
}
// src/logging.ts
var core8 = __toESM(require_core());
function getActionsLogger() {
return {
debug: core8.debug,
info: core8.info,
warning: core8.warning,
error: core8.error,
isDebug: core8.isDebug,
startGroup: core8.startGroup,
endGroup: core8.endGroup
};
}
function formatDuration(durationMs) {
if (durationMs < 1e3) {
return `${durationMs}ms`;
}
if (durationMs < 60 * 1e3) {
return `${(durationMs / 1e3).toFixed(1)}s`;
}
const minutes = Math.floor(durationMs / (60 * 1e3));
const seconds = Math.floor(durationMs % (60 * 1e3) / 1e3);
return `${minutes}m${seconds}s`;
}
// src/overlay-database-utils.ts
var CODEQL_OVERLAY_MINIMUM_VERSION = "2.23.5";
var OVERLAY_BASE_DATABASE_MAX_UPLOAD_SIZE_MB = 7500;