git-utils: deleted unused functions
This commit is contained in:
parent
dc49dcabdb
commit
c31f6c89e8
3 changed files with 2 additions and 126 deletions
57
lib/git-utils.js
generated
57
lib/git-utils.js
generated
|
|
@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|||
};
|
||||
})();
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getGitRoot = exports.decodeGitFilePath = exports.getGitDiffHunkHeaders = exports.getAllGitMergeBases = exports.gitRepack = exports.gitFetch = exports.deepenGitHistory = exports.determineBaseBranchHeadCommitOid = exports.getCommitOid = void 0;
|
||||
exports.getGitRoot = exports.decodeGitFilePath = exports.gitRepack = exports.gitFetch = exports.deepenGitHistory = exports.determineBaseBranchHeadCommitOid = exports.getCommitOid = void 0;
|
||||
exports.getRef = getRef;
|
||||
exports.isAnalyzingDefaultBranch = isAnalyzingDefaultBranch;
|
||||
const core = __importStar(require("@actions/core"));
|
||||
|
|
@ -185,61 +185,6 @@ const gitRepack = async function (flags) {
|
|||
}
|
||||
};
|
||||
exports.gitRepack = gitRepack;
|
||||
/**
|
||||
* Compute the all merge bases between the given refs. Returns an empty array
|
||||
* if no merge base is found, or if there is an error.
|
||||
*
|
||||
* This function uses the `checkout_path` to determine the repository path and
|
||||
* works only when called from `analyze` or `upload-sarif`.
|
||||
*/
|
||||
const getAllGitMergeBases = async function (refs) {
|
||||
try {
|
||||
const stdout = await runGitCommand((0, actions_util_1.getOptionalInput)("checkout_path"), ["merge-base", "--all", ...refs], `Cannot get merge base of ${refs}.`);
|
||||
return stdout.trim().split("\n");
|
||||
}
|
||||
catch {
|
||||
return [];
|
||||
}
|
||||
};
|
||||
exports.getAllGitMergeBases = getAllGitMergeBases;
|
||||
/**
|
||||
* Compute the diff hunk headers between the two given refs.
|
||||
*
|
||||
* This function uses the `checkout_path` to determine the repository path and
|
||||
* works only when called from `analyze` or `upload-sarif`.
|
||||
*
|
||||
* @returns an array of diff hunk headers (one element per line), or undefined
|
||||
* if the action was not triggered by a pull request, or if the diff could not
|
||||
* be determined.
|
||||
*/
|
||||
const getGitDiffHunkHeaders = async function (fromRef, toRef) {
|
||||
let stdout = "";
|
||||
try {
|
||||
stdout = await runGitCommand((0, actions_util_1.getOptionalInput)("checkout_path"), [
|
||||
"-c",
|
||||
"core.quotePath=false",
|
||||
"diff",
|
||||
"--no-renames",
|
||||
"--irreversible-delete",
|
||||
"-U0",
|
||||
fromRef,
|
||||
toRef,
|
||||
], `Cannot get diff from ${fromRef} to ${toRef}.`);
|
||||
}
|
||||
catch {
|
||||
return undefined;
|
||||
}
|
||||
const headers = [];
|
||||
for (const line of stdout.split("\n")) {
|
||||
if (line.startsWith("--- ") ||
|
||||
line.startsWith("+++ ") ||
|
||||
line.startsWith("@@ ")) {
|
||||
headers.push(line);
|
||||
}
|
||||
}
|
||||
return headers;
|
||||
};
|
||||
exports.getGitDiffHunkHeaders = getGitDiffHunkHeaders;
|
||||
/**
|
||||
* Decode, if necessary, a file path produced by Git. See
|
||||
* https://git-scm.com/docs/git-config#Documentation/git-config.txt-corequotePath
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -183,75 +183,6 @@ export const gitRepack = async function (flags: string[]) {
|
|||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Compute the all merge bases between the given refs. Returns an empty array
|
||||
* if no merge base is found, or if there is an error.
|
||||
*
|
||||
* This function uses the `checkout_path` to determine the repository path and
|
||||
* works only when called from `analyze` or `upload-sarif`.
|
||||
*/
|
||||
export const getAllGitMergeBases = async function (
|
||||
refs: string[],
|
||||
): Promise<string[]> {
|
||||
try {
|
||||
const stdout = await runGitCommand(
|
||||
getOptionalInput("checkout_path"),
|
||||
["merge-base", "--all", ...refs],
|
||||
`Cannot get merge base of ${refs}.`,
|
||||
);
|
||||
return stdout.trim().split("\n");
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Compute the diff hunk headers between the two given refs.
|
||||
*
|
||||
* This function uses the `checkout_path` to determine the repository path and
|
||||
* works only when called from `analyze` or `upload-sarif`.
|
||||
*
|
||||
* @returns an array of diff hunk headers (one element per line), or undefined
|
||||
* if the action was not triggered by a pull request, or if the diff could not
|
||||
* be determined.
|
||||
*/
|
||||
export const getGitDiffHunkHeaders = async function (
|
||||
fromRef: string,
|
||||
toRef: string,
|
||||
): Promise<string[] | undefined> {
|
||||
let stdout = "";
|
||||
try {
|
||||
stdout = await runGitCommand(
|
||||
getOptionalInput("checkout_path"),
|
||||
[
|
||||
"-c",
|
||||
"core.quotePath=false",
|
||||
"diff",
|
||||
"--no-renames",
|
||||
"--irreversible-delete",
|
||||
"-U0",
|
||||
fromRef,
|
||||
toRef,
|
||||
],
|
||||
`Cannot get diff from ${fromRef} to ${toRef}.`,
|
||||
);
|
||||
} catch {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const headers: string[] = [];
|
||||
for (const line of stdout.split("\n")) {
|
||||
if (
|
||||
line.startsWith("--- ") ||
|
||||
line.startsWith("+++ ") ||
|
||||
line.startsWith("@@ ")
|
||||
) {
|
||||
headers.push(line);
|
||||
}
|
||||
}
|
||||
return headers;
|
||||
};
|
||||
|
||||
/**
|
||||
* Decode, if necessary, a file path produced by Git. See
|
||||
* https://git-scm.com/docs/git-config#Documentation/git-config.txt-corequotePath
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue