MCPcopy
hub / github.com/webpack/webpack / getBase

Function getBase

test/BenchmarkTestCases.benchmark.mjs:83–117  ·  view source on GitHub ↗

* @param {string} head head * @param {[string, string, string, string | undefined]} revList rev list * @returns {Promise<string>} base

(head, revList)

Source from the content-addressed store, hash-verified

81 * @returns {Promise<string>} base
82 */
83async function getBase(head, revList) {
84 if (typeof process.env.BASE !== "undefined") {
85 return process.env.BASE;
86 }
87
88 if (revList[3]) {
89 return revList[2];
90 }
91
92 const branchName = await git.raw(["rev-parse", "--abbrev-ref", "HEAD"]);
93
94 if (branchName.trim() !== "main") {
95 const resultParents = await git.raw([
96 "rev-list",
97 "--parents",
98 "-n",
99 "1",
100 "main"
101 ]);
102
103 const revList = REV_LIST_REGEXP.exec(resultParents);
104
105 if (!revList || !revList[1] || !revList[2]) {
106 throw new Error("No parent commit found");
107 }
108
109 if (head === revList[1]) {
110 return revList[2];
111 }
112
113 return revList[1];
114 }
115
116 return revList[2];
117}
118
119/**
120 * @returns {Promise<{ name: string, rev?: string }[]>} baseline revs

Callers 1

getBaselineRevsFunction · 0.85

Calls 1

execMethod · 0.80

Tested by

no test coverage detected