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
+20 -18
View File
@@ -86733,14 +86733,30 @@ var path3 = __toESM(require("path"));
var actionsCache = __toESM(require_cache3());
// 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 semver3 = __toESM(require_semver2());
// src/logging.ts
var core7 = __toESM(require_core());
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,
@@ -86760,7 +86776,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;
}
};
@@ -86905,7 +86921,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;
@@ -86930,20 +86946,6 @@ async function isAnalyzingDefaultBranch() {
return currentRef === defaultBranch;
}
// src/logging.ts
var core8 = __toESM(require_core());
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;