screw-up 1.32.0 → 1.34.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +125 -68
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +3 -11
- package/dist/index.mjs.map +1 -1
- package/dist/main.cjs +132 -63
- package/dist/main.cjs.map +1 -1
- package/dist/main.mjs +4 -6
- package/dist/main.mjs.map +1 -1
- package/dist/{metadata-file-D79yMa_A.js → metadata-file-DmnBAdfN.js} +130 -68
- package/dist/metadata-file-DmnBAdfN.js.map +1 -0
- package/dist/src/analyzer.d.ts +2 -2
- package/dist/src/analyzer.d.ts.map +1 -1
- package/dist/src/cli-internal.d.ts +2 -2
- package/dist/src/cli.d.ts +2 -2
- package/dist/src/cli.d.ts.map +1 -1
- package/dist/src/declaration-import-fix.d.ts +2 -2
- package/dist/src/default-import-fix.d.ts +2 -2
- package/dist/src/fast-tags.d.ts +2 -2
- package/dist/src/generated/packageMetadata.d.ts +4 -4
- package/dist/src/git-operations.d.ts +2 -2
- package/dist/src/git-operations.d.ts.map +1 -1
- package/dist/src/git-ref-utils.d.ts +34 -6
- package/dist/src/git-ref-utils.d.ts.map +1 -1
- package/dist/src/index.d.ts +2 -2
- package/dist/src/internal.d.ts +2 -2
- package/dist/src/main.d.ts +2 -2
- package/dist/src/metadata-file.d.ts +2 -2
- package/dist/src/text-edits.d.ts +2 -2
- package/dist/src/types.d.ts +2 -2
- package/dist/src/vite-plugin.d.ts +2 -2
- package/package.json +10 -10
- package/dist/metadata-file-D79yMa_A.js.map +0 -1
- package/dist/packageMetadata-6po5LHyH.cjs +0 -55
- package/dist/packageMetadata-6po5LHyH.cjs.map +0 -1
- package/dist/packageMetadata-Cwh4Fqmw.cjs +0 -15
- package/dist/packageMetadata-Sm2NpI2b.js +0 -29
- package/dist/packageMetadata-Sm2NpI2b.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* name: screw-up
|
|
3
|
-
* version: 1.
|
|
3
|
+
* version: 1.34.0
|
|
4
4
|
* description: Simply package metadata inserter on Vite plugin
|
|
5
5
|
* author: Kouji Matsui (@kekyo@mi.kekyo.net)
|
|
6
6
|
* license: MIT
|
|
7
7
|
* repository.url: https://github.com/kekyo/screw-up.git
|
|
8
|
-
* git.commit.hash:
|
|
8
|
+
* git.commit.hash: bcd53f2a2326d1600b105c38a496c6c9c04b6a97
|
|
9
9
|
*/
|
|
10
10
|
//#region \0rolldown/runtime.js
|
|
11
11
|
var __create = Object.create;
|
|
@@ -14,7 +14,7 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
14
14
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
15
15
|
var __getProtoOf = Object.getPrototypeOf;
|
|
16
16
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
17
|
-
var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
17
|
+
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
|
|
18
18
|
var __copyProps = (to, from, except, desc) => {
|
|
19
19
|
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
20
20
|
key = keys[i];
|
|
@@ -31,12 +31,12 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
31
31
|
}) : target, mod));
|
|
32
32
|
//#endregion
|
|
33
33
|
let fs_promises = require("fs/promises");
|
|
34
|
-
fs_promises = __toESM(fs_promises);
|
|
34
|
+
fs_promises = __toESM(fs_promises, 1);
|
|
35
35
|
let fs = require("fs");
|
|
36
36
|
let path = require("path");
|
|
37
37
|
require("glob");
|
|
38
38
|
let isomorphic_git = require("isomorphic-git");
|
|
39
|
-
isomorphic_git = __toESM(isomorphic_git);
|
|
39
|
+
isomorphic_git = __toESM(isomorphic_git, 1);
|
|
40
40
|
let crypto$1 = require("crypto");
|
|
41
41
|
let zlib = require("zlib");
|
|
42
42
|
//#region node_modules/async-primitives/dist/index.mjs
|
|
@@ -213,18 +213,11 @@ var createMutex = (maxConsecutiveCalls = 20) => {
|
|
|
213
213
|
}
|
|
214
214
|
};
|
|
215
215
|
};
|
|
216
|
-
var createLogicalContext = (id) => {
|
|
217
|
-
return {
|
|
218
|
-
id,
|
|
219
|
-
data: /* @__PURE__ */ new Map()
|
|
220
|
-
};
|
|
221
|
-
};
|
|
222
|
-
createLogicalContext(Symbol("[root]"));
|
|
223
216
|
//#endregion
|
|
224
217
|
//#region src/generated/packageMetadata.ts
|
|
225
218
|
var name = "screw-up";
|
|
226
|
-
var version = "1.
|
|
227
|
-
var git_commit_hash = "
|
|
219
|
+
var version = "1.34.0";
|
|
220
|
+
var git_commit_hash = "bcd53f2a2326d1600b105c38a496c6c9c04b6a97";
|
|
228
221
|
//#endregion
|
|
229
222
|
//#region node_modules/json5/dist/index.js
|
|
230
223
|
var require_dist = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
@@ -1863,17 +1856,45 @@ var PACKED_OBJECT_TYPE_BY_CODE = new Map([
|
|
|
1863
1856
|
[7, "ref-delta"]
|
|
1864
1857
|
]);
|
|
1865
1858
|
/**
|
|
1866
|
-
* Resolve
|
|
1859
|
+
* Resolve Git directory paths for repositories, worktrees, and submodules.
|
|
1867
1860
|
* @param repoPath - Repository path
|
|
1868
|
-
* @returns The resolved Git directory
|
|
1861
|
+
* @returns The resolved Git directory paths
|
|
1869
1862
|
*/
|
|
1870
|
-
var
|
|
1863
|
+
var resolveGitDirectoryPaths = async (repoPath) => {
|
|
1871
1864
|
const gitDir = (0, path.join)(repoPath, ".git");
|
|
1872
1865
|
const gitStat = await (0, fs_promises.stat)(gitDir).catch(() => null);
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1866
|
+
const resolvedGitDir = !(gitStat === null || gitStat === void 0 ? void 0 : gitStat.isFile()) ? gitDir : await (async () => {
|
|
1867
|
+
const match = (await (0, fs_promises.readFile)(gitDir, "utf-8")).match(/^gitdir:\s*(.+)$/m);
|
|
1868
|
+
if (!match) return gitDir;
|
|
1869
|
+
return (0, path.isAbsolute)(match[1]) ? match[1] : (0, path.join)(repoPath, match[1]);
|
|
1870
|
+
})();
|
|
1871
|
+
return {
|
|
1872
|
+
gitDir: resolvedGitDir,
|
|
1873
|
+
commonGitDir: await (0, fs_promises.readFile)((0, path.join)(resolvedGitDir, "commondir"), "utf-8").then((content) => {
|
|
1874
|
+
const commondir = content.trim();
|
|
1875
|
+
if (!commondir) return resolvedGitDir;
|
|
1876
|
+
return (0, path.isAbsolute)(commondir) ? commondir : (0, path.join)(resolvedGitDir, commondir);
|
|
1877
|
+
}).catch((error) => {
|
|
1878
|
+
if ((error === null || error === void 0 ? void 0 : error.code) !== "ENOENT") throw error;
|
|
1879
|
+
return resolvedGitDir;
|
|
1880
|
+
})
|
|
1881
|
+
};
|
|
1882
|
+
};
|
|
1883
|
+
/**
|
|
1884
|
+
* Resolve the worktree-specific Git directory.
|
|
1885
|
+
* @param repoPath - Repository path
|
|
1886
|
+
* @returns The resolved worktree-specific Git directory path
|
|
1887
|
+
*/
|
|
1888
|
+
var getActualGitDir = async (repoPath) => {
|
|
1889
|
+
return (await resolveGitDirectoryPaths(repoPath)).gitDir;
|
|
1890
|
+
};
|
|
1891
|
+
/**
|
|
1892
|
+
* Resolve the common Git directory used for refs and objects.
|
|
1893
|
+
* @param repoPath - Repository path
|
|
1894
|
+
* @returns The resolved common Git directory path
|
|
1895
|
+
*/
|
|
1896
|
+
var getCommonGitDir = async (repoPath) => {
|
|
1897
|
+
return (await resolveGitDirectoryPaths(repoPath)).commonGitDir;
|
|
1877
1898
|
};
|
|
1878
1899
|
var readFixedRange = async (fileHandle, offset, length) => {
|
|
1879
1900
|
const buffer = Buffer.alloc(length);
|
|
@@ -2090,11 +2111,11 @@ var parseTreeEntries = (treeContent) => {
|
|
|
2090
2111
|
return entries;
|
|
2091
2112
|
};
|
|
2092
2113
|
var createGitObjectResolver = async (repoPath) => {
|
|
2093
|
-
const
|
|
2114
|
+
const commonGitDir = await getCommonGitDir(repoPath);
|
|
2094
2115
|
const resolvedObjects = /* @__PURE__ */ new Map();
|
|
2095
2116
|
let packStorePromise;
|
|
2096
2117
|
const getPackStore = async () => {
|
|
2097
|
-
if (!packStorePromise) packStorePromise = loadPackStore(
|
|
2118
|
+
if (!packStorePromise) packStorePromise = loadPackStore(commonGitDir);
|
|
2098
2119
|
return packStorePromise;
|
|
2099
2120
|
};
|
|
2100
2121
|
const readPackedObject = async (location) => {
|
|
@@ -2130,7 +2151,7 @@ var createGitObjectResolver = async (repoPath) => {
|
|
|
2130
2151
|
const cachedObject = resolvedObjects.get(oid);
|
|
2131
2152
|
if (cachedObject) return cachedObject;
|
|
2132
2153
|
const objectPromise = (async () => {
|
|
2133
|
-
const looseObject = await readLooseObject(
|
|
2154
|
+
const looseObject = await readLooseObject(commonGitDir, oid);
|
|
2134
2155
|
if (looseObject) return looseObject;
|
|
2135
2156
|
const location = (await getPackStore()).objectByOid.get(oid);
|
|
2136
2157
|
if (!location) throw new Error(`Git object not found: ${oid}`);
|
|
@@ -2205,14 +2226,14 @@ var collectTreeFiles = async (resolver, treeOid, prefix, files) => {
|
|
|
2205
2226
|
await collectTreeFiles(resolver, entry.oid, path$7, files);
|
|
2206
2227
|
continue;
|
|
2207
2228
|
}
|
|
2208
|
-
|
|
2229
|
+
files.set(path$7, entry.oid);
|
|
2209
2230
|
}
|
|
2210
2231
|
};
|
|
2211
2232
|
/**
|
|
2212
|
-
* Collect all tracked file
|
|
2233
|
+
* Collect all tracked file and submodule OIDs under the specified tree.
|
|
2213
2234
|
* @param repoPath - Repository path
|
|
2214
2235
|
* @param treeOid - Tree object OID
|
|
2215
|
-
* @returns Map of repository-relative file path to blob OID
|
|
2236
|
+
* @returns Map of repository-relative file path to blob or submodule OID
|
|
2216
2237
|
*/
|
|
2217
2238
|
var listTreeFiles = async (repoPath, treeOid) => {
|
|
2218
2239
|
const resolver = await createGitObjectResolver(repoPath);
|
|
@@ -2275,8 +2296,8 @@ var readLooseTags = async (refsTagsPath) => {
|
|
|
2275
2296
|
* @returns Array of all tag names
|
|
2276
2297
|
*/
|
|
2277
2298
|
var listTagsFast = async (repoPath) => {
|
|
2278
|
-
const
|
|
2279
|
-
const [packedTags, looseTags] = await Promise.all([parsePackedRefs((0, path.join)(
|
|
2299
|
+
const commonGitDir = await getCommonGitDir(repoPath);
|
|
2300
|
+
const [packedTags, looseTags] = await Promise.all([parsePackedRefs((0, path.join)(commonGitDir, "packed-refs")), readLooseTags((0, path.join)(commonGitDir, "refs", "tags"))]);
|
|
2280
2301
|
const allTags = new Set([...packedTags, ...looseTags]);
|
|
2281
2302
|
return Array.from(allTags).sort();
|
|
2282
2303
|
};
|
|
@@ -2289,11 +2310,11 @@ var listTagsFast = async (repoPath) => {
|
|
|
2289
2310
|
var resolveTagsBatchWithCommit = async (repoPath, tagNames, logger) => {
|
|
2290
2311
|
const startTime = Date.now();
|
|
2291
2312
|
const result = /* @__PURE__ */ new Map();
|
|
2292
|
-
const
|
|
2313
|
+
const commonGitDir = await getCommonGitDir(repoPath);
|
|
2293
2314
|
const tagSet = new Set(tagNames);
|
|
2294
2315
|
const packedRefsStart = Date.now();
|
|
2295
2316
|
try {
|
|
2296
|
-
const lines = (await (0, fs_promises.readFile)((0, path.join)(
|
|
2317
|
+
const lines = (await (0, fs_promises.readFile)((0, path.join)(commonGitDir, "packed-refs"), "utf-8")).split("\n");
|
|
2297
2318
|
for (let i = 0; i < lines.length; i++) {
|
|
2298
2319
|
const line = lines[i];
|
|
2299
2320
|
if (line.startsWith("#") || !line.trim()) continue;
|
|
@@ -2317,7 +2338,7 @@ var resolveTagsBatchWithCommit = async (repoPath, tagNames, logger) => {
|
|
|
2317
2338
|
if (remainingTags.length > 0) {
|
|
2318
2339
|
const looseRefsStart = Date.now();
|
|
2319
2340
|
const looseTagEntries = (await Promise.all(remainingTags.map(async (tagName) => {
|
|
2320
|
-
const looseRefPath = (0, path.join)(
|
|
2341
|
+
const looseRefPath = (0, path.join)(commonGitDir, "refs", "tags", tagName);
|
|
2321
2342
|
try {
|
|
2322
2343
|
return {
|
|
2323
2344
|
tagName,
|
|
@@ -2533,16 +2554,26 @@ var formatVersion = (version) => {
|
|
|
2533
2554
|
return result;
|
|
2534
2555
|
};
|
|
2535
2556
|
/**
|
|
2536
|
-
*
|
|
2557
|
+
* Build a Git read context that can operate correctly inside worktrees.
|
|
2537
2558
|
* @param repositoryPath - Local Git repository directory
|
|
2559
|
+
* @returns The resolved Git read context
|
|
2560
|
+
*/
|
|
2561
|
+
var createGitReadContext = async (repositoryPath) => ({
|
|
2562
|
+
dir: repositoryPath,
|
|
2563
|
+
gitdir: await getCommonGitDir(repositoryPath)
|
|
2564
|
+
});
|
|
2565
|
+
/**
|
|
2566
|
+
* Get a commit by hash
|
|
2567
|
+
* @param context - Git read context
|
|
2538
2568
|
* @param hash - The hash of the commit
|
|
2539
2569
|
* @returns The commit or undefined if the commit is not found
|
|
2540
2570
|
*/
|
|
2541
|
-
var getCommit = async (
|
|
2571
|
+
var getCommit = async (context, hash) => {
|
|
2542
2572
|
try {
|
|
2543
2573
|
const commit = await isomorphic_git.readCommit({
|
|
2544
2574
|
fs: fs_promises.default,
|
|
2545
|
-
dir:
|
|
2575
|
+
dir: context.dir,
|
|
2576
|
+
gitdir: context.gitdir,
|
|
2546
2577
|
oid: hash
|
|
2547
2578
|
});
|
|
2548
2579
|
return {
|
|
@@ -2559,19 +2590,20 @@ var getCommit = async (repositoryPath, hash) => {
|
|
|
2559
2590
|
};
|
|
2560
2591
|
/**
|
|
2561
2592
|
* Get the current commit
|
|
2562
|
-
* @param
|
|
2593
|
+
* @param context - Git read context
|
|
2563
2594
|
* @returns The current commit or undefined if the current commit is not found
|
|
2564
2595
|
*/
|
|
2565
|
-
var getCurrentCommit = async (
|
|
2596
|
+
var getCurrentCommit = async (context) => {
|
|
2566
2597
|
try {
|
|
2567
2598
|
const currentOid = await isomorphic_git.resolveRef({
|
|
2568
2599
|
fs: fs_promises.default,
|
|
2569
|
-
dir:
|
|
2600
|
+
dir: context.dir,
|
|
2570
2601
|
ref: "HEAD"
|
|
2571
2602
|
});
|
|
2572
2603
|
const commit = await isomorphic_git.readCommit({
|
|
2573
2604
|
fs: fs_promises.default,
|
|
2574
|
-
dir:
|
|
2605
|
+
dir: context.dir,
|
|
2606
|
+
gitdir: context.gitdir,
|
|
2575
2607
|
oid: currentOid
|
|
2576
2608
|
});
|
|
2577
2609
|
return {
|
|
@@ -2597,21 +2629,23 @@ var getRelatedTagsFromMap = (commitToTags, commitHash) => {
|
|
|
2597
2629
|
};
|
|
2598
2630
|
/**
|
|
2599
2631
|
* Get the commit related branch name.
|
|
2600
|
-
* @param
|
|
2632
|
+
* @param context - Git read context
|
|
2601
2633
|
* @param commitHash - The hash of the commit
|
|
2602
2634
|
* @returns The commit related branch name or undefined if not found
|
|
2603
2635
|
*/
|
|
2604
|
-
var getRelatedBranches = async (
|
|
2636
|
+
var getRelatedBranches = async (context, commitHash) => {
|
|
2605
2637
|
try {
|
|
2606
2638
|
const branches = await isomorphic_git.listBranches({
|
|
2607
2639
|
fs: fs_promises.default,
|
|
2608
|
-
dir:
|
|
2640
|
+
dir: context.dir,
|
|
2641
|
+
gitdir: context.gitdir
|
|
2609
2642
|
});
|
|
2610
2643
|
const relatedBranches = [];
|
|
2611
2644
|
for (const branch of branches) try {
|
|
2612
2645
|
if (await isomorphic_git.resolveRef({
|
|
2613
2646
|
fs: fs_promises.default,
|
|
2614
|
-
dir:
|
|
2647
|
+
dir: context.dir,
|
|
2648
|
+
gitdir: context.gitdir,
|
|
2615
2649
|
ref: branch
|
|
2616
2650
|
}) === commitHash) relatedBranches.push(branch);
|
|
2617
2651
|
} catch (_unused3) {}
|
|
@@ -2620,6 +2654,9 @@ var getRelatedBranches = async (repositoryPath, commitHash) => {
|
|
|
2620
2654
|
return [];
|
|
2621
2655
|
}
|
|
2622
2656
|
};
|
|
2657
|
+
var GITLINK_INDEX_MODE = 57344;
|
|
2658
|
+
var INDEX_MODE_TYPE_MASK = 61440;
|
|
2659
|
+
var isGitLinkIndexEntry = (entry) => (entry.mode & INDEX_MODE_TYPE_MASK) === GITLINK_INDEX_MODE;
|
|
2623
2660
|
var parseGitIndex = async (gitDir) => {
|
|
2624
2661
|
try {
|
|
2625
2662
|
const buffer = await fs_promises.default.readFile((0, path.join)(gitDir, "index"));
|
|
@@ -2631,6 +2668,7 @@ var parseGitIndex = async (gitDir) => {
|
|
|
2631
2668
|
const entries = /* @__PURE__ */ new Map();
|
|
2632
2669
|
for (let index = 0; index < entryCount; index++) {
|
|
2633
2670
|
const entryStart = offset;
|
|
2671
|
+
const mode = buffer.readUInt32BE(entryStart + 24);
|
|
2634
2672
|
const size = buffer.readUInt32BE(entryStart + 36);
|
|
2635
2673
|
const oid = buffer.subarray(entryStart + 40, entryStart + 60).toString("hex");
|
|
2636
2674
|
const flags = buffer.readUInt16BE(entryStart + 60);
|
|
@@ -2645,6 +2683,7 @@ var parseGitIndex = async (gitDir) => {
|
|
|
2645
2683
|
entries.set(path$3, {
|
|
2646
2684
|
path: path$3,
|
|
2647
2685
|
oid,
|
|
2686
|
+
mode,
|
|
2648
2687
|
size,
|
|
2649
2688
|
stage
|
|
2650
2689
|
});
|
|
@@ -2667,7 +2706,7 @@ var listTrackedDirectories = (indexEntries) => {
|
|
|
2667
2706
|
}
|
|
2668
2707
|
return directories;
|
|
2669
2708
|
};
|
|
2670
|
-
var listWorkingDirectoryFiles = async (repositoryPath, trackedDirectories, relativePath = "") => {
|
|
2709
|
+
var listWorkingDirectoryFiles = async (repositoryPath, trackedDirectories, excludedDirectories, relativePath = "") => {
|
|
2671
2710
|
const directoryPath = relativePath ? (0, path.join)(repositoryPath, relativePath) : repositoryPath;
|
|
2672
2711
|
const entries = await fs_promises.default.readdir(directoryPath, { withFileTypes: true });
|
|
2673
2712
|
const files = [];
|
|
@@ -2675,6 +2714,7 @@ var listWorkingDirectoryFiles = async (repositoryPath, trackedDirectories, relat
|
|
|
2675
2714
|
if (entry.name === ".git") continue;
|
|
2676
2715
|
const entryPath = relativePath ? `${relativePath}/${entry.name}` : entry.name;
|
|
2677
2716
|
if (entry.isDirectory()) {
|
|
2717
|
+
if (excludedDirectories.has(entryPath)) continue;
|
|
2678
2718
|
if (!trackedDirectories.has(entryPath)) {
|
|
2679
2719
|
if (await isomorphic_git.isIgnored({
|
|
2680
2720
|
fs: fs_promises.default,
|
|
@@ -2682,7 +2722,7 @@ var listWorkingDirectoryFiles = async (repositoryPath, trackedDirectories, relat
|
|
|
2682
2722
|
filepath: entryPath
|
|
2683
2723
|
})) continue;
|
|
2684
2724
|
}
|
|
2685
|
-
files.push(...await listWorkingDirectoryFiles(repositoryPath, trackedDirectories, entryPath));
|
|
2725
|
+
files.push(...await listWorkingDirectoryFiles(repositoryPath, trackedDirectories, excludedDirectories, entryPath));
|
|
2686
2726
|
continue;
|
|
2687
2727
|
}
|
|
2688
2728
|
if (entry.isFile() || entry.isSymbolicLink()) files.push(entryPath);
|
|
@@ -2697,7 +2737,7 @@ var getModifiedFiles = async (repositoryPath, headTreeOid) => {
|
|
|
2697
2737
|
try {
|
|
2698
2738
|
const gitDir = await getActualGitDir(repositoryPath);
|
|
2699
2739
|
const [headFiles, indexEntries] = await Promise.all([listTreeFiles(repositoryPath, headTreeOid), parseGitIndex(gitDir)]);
|
|
2700
|
-
const workdirFiles = await listWorkingDirectoryFiles(repositoryPath, listTrackedDirectories(indexEntries));
|
|
2740
|
+
const workdirFiles = await listWorkingDirectoryFiles(repositoryPath, listTrackedDirectories(indexEntries), new Set(Array.from(indexEntries.values()).filter(isGitLinkIndexEntry).map((entry) => entry.path)));
|
|
2701
2741
|
const modifiedFiles = /* @__PURE__ */ new Map();
|
|
2702
2742
|
const rememberModifiedFile = (path$5, reason) => {
|
|
2703
2743
|
if (!modifiedFiles.has(path$5)) modifiedFiles.set(path$5, {
|
|
@@ -2715,6 +2755,10 @@ var getModifiedFiles = async (repositoryPath, headTreeOid) => {
|
|
|
2715
2755
|
const absolutePath = (0, path.join)(repositoryPath, indexEntry.path);
|
|
2716
2756
|
try {
|
|
2717
2757
|
const stats = await fs_promises.default.lstat(absolutePath);
|
|
2758
|
+
if (isGitLinkIndexEntry(indexEntry)) {
|
|
2759
|
+
if (indexEntry.stage !== 0) rememberModifiedFile(indexEntry.path, "staged");
|
|
2760
|
+
continue;
|
|
2761
|
+
}
|
|
2718
2762
|
if (!stats.isFile() && !stats.isSymbolicLink()) {
|
|
2719
2763
|
rememberModifiedFile(indexEntry.path, "worktree");
|
|
2720
2764
|
continue;
|
|
@@ -2755,7 +2799,7 @@ var formatModifiedFile = (modifiedFile) => `'${modifiedFile.path}':${modifiedFil
|
|
|
2755
2799
|
* @param commitToTags - Map of commit hash to tags for performance
|
|
2756
2800
|
* @returns The version or undefined if no version is found
|
|
2757
2801
|
*/
|
|
2758
|
-
var lookupVersionLabelRecursive = async (
|
|
2802
|
+
var lookupVersionLabelRecursive = async (context, commit, reachedCommits, commitToTags) => {
|
|
2759
2803
|
const scheduledStack = [];
|
|
2760
2804
|
let version = {
|
|
2761
2805
|
major: 0,
|
|
@@ -2779,10 +2823,11 @@ var lookupVersionLabelRecursive = async (cwd, commit, reachedCommits, commitToTa
|
|
|
2779
2823
|
try {
|
|
2780
2824
|
const parentHashes = (await isomorphic_git.readCommit({
|
|
2781
2825
|
fs: fs_promises.default,
|
|
2782
|
-
dir:
|
|
2826
|
+
dir: context.dir,
|
|
2827
|
+
gitdir: context.gitdir,
|
|
2783
2828
|
oid: currentCommit.hash
|
|
2784
2829
|
})).commit.parent || [];
|
|
2785
|
-
parentCommits = (await Promise.all(parentHashes.map((parentHash) => getCommit(
|
|
2830
|
+
parentCommits = (await Promise.all(parentHashes.map((parentHash) => getCommit(context, parentHash)))).filter((ci) => ci !== void 0);
|
|
2786
2831
|
} catch (_unused6) {}
|
|
2787
2832
|
if (parentCommits.length === 0) {
|
|
2788
2833
|
reachedCommits.set(currentCommit.hash, version);
|
|
@@ -2797,7 +2842,7 @@ var lookupVersionLabelRecursive = async (cwd, commit, reachedCommits, commitToTa
|
|
|
2797
2842
|
while (scheduledStack.length >= 1) {
|
|
2798
2843
|
const { commit: scheduledCommit, parents } = scheduledStack.pop();
|
|
2799
2844
|
if (parents.length >= 2) for (let index = 1; index < parents.length; index++) {
|
|
2800
|
-
const alternateParentVersion = await lookupVersionLabelRecursive(
|
|
2845
|
+
const alternateParentVersion = await lookupVersionLabelRecursive(context, parents[index], reachedCommits, commitToTags);
|
|
2801
2846
|
if (alternateParentVersion && compareVersions(alternateParentVersion, version) < 0) version = alternateParentVersion;
|
|
2802
2847
|
}
|
|
2803
2848
|
version = incrementLastVersionComponent(version);
|
|
@@ -2825,12 +2870,31 @@ var getGitMetadata = async (repositoryPath, checkWorkingDirectoryStatus, logger)
|
|
|
2825
2870
|
logger.debug(`[screw-up] Total getGitMetadata: ${Date.now() - startTime}ms`);
|
|
2826
2871
|
return metadata;
|
|
2827
2872
|
}
|
|
2873
|
+
let gitContext;
|
|
2828
2874
|
try {
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2875
|
+
gitContext = await createGitReadContext(gitRootPath);
|
|
2876
|
+
} catch (error) {
|
|
2877
|
+
logger.warn(`Failed to resolve git metadata context: ${error}`);
|
|
2878
|
+
logger.debug(`[screw-up] Total getGitMetadata: ${Date.now() - startTime}ms`);
|
|
2879
|
+
return metadata;
|
|
2880
|
+
}
|
|
2881
|
+
const currentCommit = await getCurrentCommit(gitContext);
|
|
2882
|
+
if (!currentCommit) {
|
|
2883
|
+
logger.debug(`[screw-up] Total getGitMetadata: ${Date.now() - startTime}ms`);
|
|
2884
|
+
return metadata;
|
|
2885
|
+
}
|
|
2886
|
+
const gitMetadata = {
|
|
2887
|
+
tags: [],
|
|
2888
|
+
branches: [],
|
|
2889
|
+
commit: {
|
|
2890
|
+
hash: currentCommit.hash,
|
|
2891
|
+
shortHash: currentCommit.shortHash,
|
|
2892
|
+
date: dayjs(currentCommit.date).format("YYYY-MM-DDTHH:mm:ssZ"),
|
|
2893
|
+
message: currentCommit.message
|
|
2833
2894
|
}
|
|
2895
|
+
};
|
|
2896
|
+
metadata.git = gitMetadata;
|
|
2897
|
+
try {
|
|
2834
2898
|
const buildStart = Date.now();
|
|
2835
2899
|
const commitToTags = await buildCompleteTagCache(gitRootPath, (tagName) => {
|
|
2836
2900
|
const version = parseVersion(tagName);
|
|
@@ -2838,12 +2902,7 @@ var getGitMetadata = async (repositoryPath, checkWorkingDirectoryStatus, logger)
|
|
|
2838
2902
|
}, logger);
|
|
2839
2903
|
logger.debug(`[screw-up] buildCompleteTagCache: ${Date.now() - buildStart}ms`);
|
|
2840
2904
|
logger.debug(`Built tag map with ${commitToTags.size} commits`);
|
|
2841
|
-
let version = await lookupVersionLabelRecursive(
|
|
2842
|
-
const gitMetadata = {
|
|
2843
|
-
tags: [],
|
|
2844
|
-
branches: []
|
|
2845
|
-
};
|
|
2846
|
-
metadata.git = gitMetadata;
|
|
2905
|
+
let version = await lookupVersionLabelRecursive(gitContext, currentCommit, /* @__PURE__ */ new Map(), commitToTags);
|
|
2847
2906
|
if (version) {
|
|
2848
2907
|
if (checkWorkingDirectoryStatus) {
|
|
2849
2908
|
const modifiedFiles = await getModifiedFiles(gitRootPath, currentCommit.tree);
|
|
@@ -2857,16 +2916,14 @@ var getGitMetadata = async (repositoryPath, checkWorkingDirectoryStatus, logger)
|
|
|
2857
2916
|
gitMetadata.version = gitVersion;
|
|
2858
2917
|
metadata.version = gitVersion;
|
|
2859
2918
|
}
|
|
2860
|
-
gitMetadata.commit = {
|
|
2861
|
-
hash: currentCommit.hash,
|
|
2862
|
-
shortHash: currentCommit.shortHash,
|
|
2863
|
-
date: dayjs(currentCommit.date).format("YYYY-MM-DDTHH:mm:ssZ"),
|
|
2864
|
-
message: currentCommit.message
|
|
2865
|
-
};
|
|
2866
2919
|
gitMetadata.tags = getRelatedTagsFromMap(commitToTags, currentCommit.hash).map((tag) => tag.name);
|
|
2867
|
-
gitMetadata.branches = await getRelatedBranches(gitRootPath, currentCommit.hash);
|
|
2868
2920
|
} catch (error) {
|
|
2869
|
-
logger.warn(`Failed to
|
|
2921
|
+
logger.warn(`Failed to resolve git versioning metadata: ${error}`);
|
|
2922
|
+
}
|
|
2923
|
+
try {
|
|
2924
|
+
gitMetadata.branches = await getRelatedBranches(gitContext, currentCommit.hash);
|
|
2925
|
+
} catch (error) {
|
|
2926
|
+
logger.warn(`Failed to resolve git branch metadata: ${error}`);
|
|
2870
2927
|
}
|
|
2871
2928
|
logger.debug(`[screw-up] Total getGitMetadata: ${Date.now() - startTime}ms`);
|
|
2872
2929
|
return metadata;
|