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.
Files changed (37) hide show
  1. package/dist/index.cjs +125 -68
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.mjs +3 -11
  4. package/dist/index.mjs.map +1 -1
  5. package/dist/main.cjs +132 -63
  6. package/dist/main.cjs.map +1 -1
  7. package/dist/main.mjs +4 -6
  8. package/dist/main.mjs.map +1 -1
  9. package/dist/{metadata-file-D79yMa_A.js → metadata-file-DmnBAdfN.js} +130 -68
  10. package/dist/metadata-file-DmnBAdfN.js.map +1 -0
  11. package/dist/src/analyzer.d.ts +2 -2
  12. package/dist/src/analyzer.d.ts.map +1 -1
  13. package/dist/src/cli-internal.d.ts +2 -2
  14. package/dist/src/cli.d.ts +2 -2
  15. package/dist/src/cli.d.ts.map +1 -1
  16. package/dist/src/declaration-import-fix.d.ts +2 -2
  17. package/dist/src/default-import-fix.d.ts +2 -2
  18. package/dist/src/fast-tags.d.ts +2 -2
  19. package/dist/src/generated/packageMetadata.d.ts +4 -4
  20. package/dist/src/git-operations.d.ts +2 -2
  21. package/dist/src/git-operations.d.ts.map +1 -1
  22. package/dist/src/git-ref-utils.d.ts +34 -6
  23. package/dist/src/git-ref-utils.d.ts.map +1 -1
  24. package/dist/src/index.d.ts +2 -2
  25. package/dist/src/internal.d.ts +2 -2
  26. package/dist/src/main.d.ts +2 -2
  27. package/dist/src/metadata-file.d.ts +2 -2
  28. package/dist/src/text-edits.d.ts +2 -2
  29. package/dist/src/types.d.ts +2 -2
  30. package/dist/src/vite-plugin.d.ts +2 -2
  31. package/package.json +10 -10
  32. package/dist/metadata-file-D79yMa_A.js.map +0 -1
  33. package/dist/packageMetadata-6po5LHyH.cjs +0 -55
  34. package/dist/packageMetadata-6po5LHyH.cjs.map +0 -1
  35. package/dist/packageMetadata-Cwh4Fqmw.cjs +0 -15
  36. package/dist/packageMetadata-Sm2NpI2b.js +0 -29
  37. package/dist/packageMetadata-Sm2NpI2b.js.map +0 -1
@@ -1,11 +1,11 @@
1
1
  /*!
2
2
  * name: screw-up
3
- * version: 1.32.0
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: 8a0078c34fa41bdb0cbf2d23837ac5e3217cbf53
8
+ * git.commit.hash: bcd53f2a2326d1600b105c38a496c6c9c04b6a97
9
9
  */
10
10
  import fs, { mkdir, open, readFile, readdir, stat, writeFile } from "fs/promises";
11
11
  import { existsSync } from "fs";
@@ -22,16 +22,7 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
22
22
  var __getOwnPropNames = Object.getOwnPropertyNames;
23
23
  var __getProtoOf = Object.getPrototypeOf;
24
24
  var __hasOwnProp = Object.prototype.hasOwnProperty;
25
- var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
26
- var __exportAll = (all, no_symbols) => {
27
- let target = {};
28
- for (var name in all) __defProp(target, name, {
29
- get: all[name],
30
- enumerable: true
31
- });
32
- if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
33
- return target;
34
- };
25
+ var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
35
26
  var __copyProps = (to, from, except, desc) => {
36
27
  if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
37
28
  key = keys[i];
@@ -47,6 +38,13 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
47
38
  enumerable: true
48
39
  }) : target, mod));
49
40
  //#endregion
41
+ //#region src/generated/packageMetadata.ts
42
+ var name = "screw-up";
43
+ var version = "1.34.0";
44
+ var author = "Kouji Matsui (@kekyo@mi.kekyo.net)";
45
+ var repository_url = "https://github.com/kekyo/screw-up.git";
46
+ var git_commit_hash = "bcd53f2a2326d1600b105c38a496c6c9c04b6a97";
47
+ //#endregion
50
48
  //#region node_modules/json5/dist/index.js
51
49
  var require_dist = /* @__PURE__ */ __commonJSMin(((exports, module) => {
52
50
  (function(global, factory) {
@@ -1892,17 +1890,45 @@ var PACKED_OBJECT_TYPE_BY_CODE = new Map([
1892
1890
  [7, "ref-delta"]
1893
1891
  ]);
1894
1892
  /**
1895
- * Resolve the actual Git directory for repositories, worktrees, and submodules.
1893
+ * Resolve Git directory paths for repositories, worktrees, and submodules.
1896
1894
  * @param repoPath - Repository path
1897
- * @returns The resolved Git directory path
1895
+ * @returns The resolved Git directory paths
1898
1896
  */
1899
- var getActualGitDir = async (repoPath) => {
1897
+ var resolveGitDirectoryPaths = async (repoPath) => {
1900
1898
  const gitDir = join(repoPath, ".git");
1901
1899
  const gitStat = await stat(gitDir).catch(() => null);
1902
- if (!(gitStat === null || gitStat === void 0 ? void 0 : gitStat.isFile())) return gitDir;
1903
- const match = (await readFile(gitDir, "utf-8")).match(/^gitdir:\s*(.+)$/m);
1904
- if (!match) return gitDir;
1905
- return isAbsolute(match[1]) ? match[1] : join(repoPath, match[1]);
1900
+ const resolvedGitDir = !(gitStat === null || gitStat === void 0 ? void 0 : gitStat.isFile()) ? gitDir : await (async () => {
1901
+ const match = (await readFile(gitDir, "utf-8")).match(/^gitdir:\s*(.+)$/m);
1902
+ if (!match) return gitDir;
1903
+ return isAbsolute(match[1]) ? match[1] : join(repoPath, match[1]);
1904
+ })();
1905
+ return {
1906
+ gitDir: resolvedGitDir,
1907
+ commonGitDir: await readFile(join(resolvedGitDir, "commondir"), "utf-8").then((content) => {
1908
+ const commondir = content.trim();
1909
+ if (!commondir) return resolvedGitDir;
1910
+ return isAbsolute(commondir) ? commondir : join(resolvedGitDir, commondir);
1911
+ }).catch((error) => {
1912
+ if ((error === null || error === void 0 ? void 0 : error.code) !== "ENOENT") throw error;
1913
+ return resolvedGitDir;
1914
+ })
1915
+ };
1916
+ };
1917
+ /**
1918
+ * Resolve the worktree-specific Git directory.
1919
+ * @param repoPath - Repository path
1920
+ * @returns The resolved worktree-specific Git directory path
1921
+ */
1922
+ var getActualGitDir = async (repoPath) => {
1923
+ return (await resolveGitDirectoryPaths(repoPath)).gitDir;
1924
+ };
1925
+ /**
1926
+ * Resolve the common Git directory used for refs and objects.
1927
+ * @param repoPath - Repository path
1928
+ * @returns The resolved common Git directory path
1929
+ */
1930
+ var getCommonGitDir = async (repoPath) => {
1931
+ return (await resolveGitDirectoryPaths(repoPath)).commonGitDir;
1906
1932
  };
1907
1933
  var readFixedRange = async (fileHandle, offset, length) => {
1908
1934
  const buffer = Buffer.alloc(length);
@@ -2119,11 +2145,11 @@ var parseTreeEntries = (treeContent) => {
2119
2145
  return entries;
2120
2146
  };
2121
2147
  var createGitObjectResolver = async (repoPath) => {
2122
- const actualGitDir = await getActualGitDir(repoPath);
2148
+ const commonGitDir = await getCommonGitDir(repoPath);
2123
2149
  const resolvedObjects = /* @__PURE__ */ new Map();
2124
2150
  let packStorePromise;
2125
2151
  const getPackStore = async () => {
2126
- if (!packStorePromise) packStorePromise = loadPackStore(actualGitDir);
2152
+ if (!packStorePromise) packStorePromise = loadPackStore(commonGitDir);
2127
2153
  return packStorePromise;
2128
2154
  };
2129
2155
  const readPackedObject = async (location) => {
@@ -2159,7 +2185,7 @@ var createGitObjectResolver = async (repoPath) => {
2159
2185
  const cachedObject = resolvedObjects.get(oid);
2160
2186
  if (cachedObject) return cachedObject;
2161
2187
  const objectPromise = (async () => {
2162
- const looseObject = await readLooseObject(actualGitDir, oid);
2188
+ const looseObject = await readLooseObject(commonGitDir, oid);
2163
2189
  if (looseObject) return looseObject;
2164
2190
  const location = (await getPackStore()).objectByOid.get(oid);
2165
2191
  if (!location) throw new Error(`Git object not found: ${oid}`);
@@ -2234,14 +2260,14 @@ var collectTreeFiles = async (resolver, treeOid, prefix, files) => {
2234
2260
  await collectTreeFiles(resolver, entry.oid, path, files);
2235
2261
  continue;
2236
2262
  }
2237
- if (entry.mode !== "160000") files.set(path, entry.oid);
2263
+ files.set(path, entry.oid);
2238
2264
  }
2239
2265
  };
2240
2266
  /**
2241
- * Collect all tracked file blob OIDs under the specified tree.
2267
+ * Collect all tracked file and submodule OIDs under the specified tree.
2242
2268
  * @param repoPath - Repository path
2243
2269
  * @param treeOid - Tree object OID
2244
- * @returns Map of repository-relative file path to blob OID
2270
+ * @returns Map of repository-relative file path to blob or submodule OID
2245
2271
  */
2246
2272
  var listTreeFiles = async (repoPath, treeOid) => {
2247
2273
  const resolver = await createGitObjectResolver(repoPath);
@@ -2304,8 +2330,8 @@ var readLooseTags = async (refsTagsPath) => {
2304
2330
  * @returns Array of all tag names
2305
2331
  */
2306
2332
  var listTagsFast = async (repoPath) => {
2307
- const actualGitDir = await getActualGitDir(repoPath);
2308
- const [packedTags, looseTags] = await Promise.all([parsePackedRefs(join(actualGitDir, "packed-refs")), readLooseTags(join(actualGitDir, "refs", "tags"))]);
2333
+ const commonGitDir = await getCommonGitDir(repoPath);
2334
+ const [packedTags, looseTags] = await Promise.all([parsePackedRefs(join(commonGitDir, "packed-refs")), readLooseTags(join(commonGitDir, "refs", "tags"))]);
2309
2335
  const allTags = new Set([...packedTags, ...looseTags]);
2310
2336
  return Array.from(allTags).sort();
2311
2337
  };
@@ -2318,11 +2344,11 @@ var listTagsFast = async (repoPath) => {
2318
2344
  var resolveTagsBatchWithCommit = async (repoPath, tagNames, logger) => {
2319
2345
  const startTime = Date.now();
2320
2346
  const result = /* @__PURE__ */ new Map();
2321
- const actualGitDir = await getActualGitDir(repoPath);
2347
+ const commonGitDir = await getCommonGitDir(repoPath);
2322
2348
  const tagSet = new Set(tagNames);
2323
2349
  const packedRefsStart = Date.now();
2324
2350
  try {
2325
- const lines = (await readFile(join(actualGitDir, "packed-refs"), "utf-8")).split("\n");
2351
+ const lines = (await readFile(join(commonGitDir, "packed-refs"), "utf-8")).split("\n");
2326
2352
  for (let i = 0; i < lines.length; i++) {
2327
2353
  const line = lines[i];
2328
2354
  if (line.startsWith("#") || !line.trim()) continue;
@@ -2346,7 +2372,7 @@ var resolveTagsBatchWithCommit = async (repoPath, tagNames, logger) => {
2346
2372
  if (remainingTags.length > 0) {
2347
2373
  const looseRefsStart = Date.now();
2348
2374
  const looseTagEntries = (await Promise.all(remainingTags.map(async (tagName) => {
2349
- const looseRefPath = join(actualGitDir, "refs", "tags", tagName);
2375
+ const looseRefPath = join(commonGitDir, "refs", "tags", tagName);
2350
2376
  try {
2351
2377
  return {
2352
2378
  tagName,
@@ -2562,16 +2588,26 @@ var formatVersion = (version) => {
2562
2588
  return result;
2563
2589
  };
2564
2590
  /**
2565
- * Get a commit by hash
2591
+ * Build a Git read context that can operate correctly inside worktrees.
2566
2592
  * @param repositoryPath - Local Git repository directory
2593
+ * @returns The resolved Git read context
2594
+ */
2595
+ var createGitReadContext = async (repositoryPath) => ({
2596
+ dir: repositoryPath,
2597
+ gitdir: await getCommonGitDir(repositoryPath)
2598
+ });
2599
+ /**
2600
+ * Get a commit by hash
2601
+ * @param context - Git read context
2567
2602
  * @param hash - The hash of the commit
2568
2603
  * @returns The commit or undefined if the commit is not found
2569
2604
  */
2570
- var getCommit = async (repositoryPath, hash) => {
2605
+ var getCommit = async (context, hash) => {
2571
2606
  try {
2572
2607
  const commit = await git.readCommit({
2573
2608
  fs,
2574
- dir: repositoryPath,
2609
+ dir: context.dir,
2610
+ gitdir: context.gitdir,
2575
2611
  oid: hash
2576
2612
  });
2577
2613
  return {
@@ -2588,19 +2624,20 @@ var getCommit = async (repositoryPath, hash) => {
2588
2624
  };
2589
2625
  /**
2590
2626
  * Get the current commit
2591
- * @param repositoryPath - Local Git repository directory
2627
+ * @param context - Git read context
2592
2628
  * @returns The current commit or undefined if the current commit is not found
2593
2629
  */
2594
- var getCurrentCommit = async (repositoryPath) => {
2630
+ var getCurrentCommit = async (context) => {
2595
2631
  try {
2596
2632
  const currentOid = await git.resolveRef({
2597
2633
  fs,
2598
- dir: repositoryPath,
2634
+ dir: context.dir,
2599
2635
  ref: "HEAD"
2600
2636
  });
2601
2637
  const commit = await git.readCommit({
2602
2638
  fs,
2603
- dir: repositoryPath,
2639
+ dir: context.dir,
2640
+ gitdir: context.gitdir,
2604
2641
  oid: currentOid
2605
2642
  });
2606
2643
  return {
@@ -2626,21 +2663,23 @@ var getRelatedTagsFromMap = (commitToTags, commitHash) => {
2626
2663
  };
2627
2664
  /**
2628
2665
  * Get the commit related branch name.
2629
- * @param repositoryPath - Local Git repository directory
2666
+ * @param context - Git read context
2630
2667
  * @param commitHash - The hash of the commit
2631
2668
  * @returns The commit related branch name or undefined if not found
2632
2669
  */
2633
- var getRelatedBranches = async (repositoryPath, commitHash) => {
2670
+ var getRelatedBranches = async (context, commitHash) => {
2634
2671
  try {
2635
2672
  const branches = await git.listBranches({
2636
2673
  fs,
2637
- dir: repositoryPath
2674
+ dir: context.dir,
2675
+ gitdir: context.gitdir
2638
2676
  });
2639
2677
  const relatedBranches = [];
2640
2678
  for (const branch of branches) try {
2641
2679
  if (await git.resolveRef({
2642
2680
  fs,
2643
- dir: repositoryPath,
2681
+ dir: context.dir,
2682
+ gitdir: context.gitdir,
2644
2683
  ref: branch
2645
2684
  }) === commitHash) relatedBranches.push(branch);
2646
2685
  } catch (_unused3) {}
@@ -2649,6 +2688,9 @@ var getRelatedBranches = async (repositoryPath, commitHash) => {
2649
2688
  return [];
2650
2689
  }
2651
2690
  };
2691
+ var GITLINK_INDEX_MODE = 57344;
2692
+ var INDEX_MODE_TYPE_MASK = 61440;
2693
+ var isGitLinkIndexEntry = (entry) => (entry.mode & INDEX_MODE_TYPE_MASK) === GITLINK_INDEX_MODE;
2652
2694
  var parseGitIndex = async (gitDir) => {
2653
2695
  try {
2654
2696
  const buffer = await fs.readFile(join(gitDir, "index"));
@@ -2660,6 +2702,7 @@ var parseGitIndex = async (gitDir) => {
2660
2702
  const entries = /* @__PURE__ */ new Map();
2661
2703
  for (let index = 0; index < entryCount; index++) {
2662
2704
  const entryStart = offset;
2705
+ const mode = buffer.readUInt32BE(entryStart + 24);
2663
2706
  const size = buffer.readUInt32BE(entryStart + 36);
2664
2707
  const oid = buffer.subarray(entryStart + 40, entryStart + 60).toString("hex");
2665
2708
  const flags = buffer.readUInt16BE(entryStart + 60);
@@ -2674,6 +2717,7 @@ var parseGitIndex = async (gitDir) => {
2674
2717
  entries.set(path, {
2675
2718
  path,
2676
2719
  oid,
2720
+ mode,
2677
2721
  size,
2678
2722
  stage
2679
2723
  });
@@ -2696,7 +2740,7 @@ var listTrackedDirectories = (indexEntries) => {
2696
2740
  }
2697
2741
  return directories;
2698
2742
  };
2699
- var listWorkingDirectoryFiles = async (repositoryPath, trackedDirectories, relativePath = "") => {
2743
+ var listWorkingDirectoryFiles = async (repositoryPath, trackedDirectories, excludedDirectories, relativePath = "") => {
2700
2744
  const directoryPath = relativePath ? join(repositoryPath, relativePath) : repositoryPath;
2701
2745
  const entries = await fs.readdir(directoryPath, { withFileTypes: true });
2702
2746
  const files = [];
@@ -2704,6 +2748,7 @@ var listWorkingDirectoryFiles = async (repositoryPath, trackedDirectories, relat
2704
2748
  if (entry.name === ".git") continue;
2705
2749
  const entryPath = relativePath ? `${relativePath}/${entry.name}` : entry.name;
2706
2750
  if (entry.isDirectory()) {
2751
+ if (excludedDirectories.has(entryPath)) continue;
2707
2752
  if (!trackedDirectories.has(entryPath)) {
2708
2753
  if (await git.isIgnored({
2709
2754
  fs,
@@ -2711,7 +2756,7 @@ var listWorkingDirectoryFiles = async (repositoryPath, trackedDirectories, relat
2711
2756
  filepath: entryPath
2712
2757
  })) continue;
2713
2758
  }
2714
- files.push(...await listWorkingDirectoryFiles(repositoryPath, trackedDirectories, entryPath));
2759
+ files.push(...await listWorkingDirectoryFiles(repositoryPath, trackedDirectories, excludedDirectories, entryPath));
2715
2760
  continue;
2716
2761
  }
2717
2762
  if (entry.isFile() || entry.isSymbolicLink()) files.push(entryPath);
@@ -2726,7 +2771,7 @@ var getModifiedFiles = async (repositoryPath, headTreeOid) => {
2726
2771
  try {
2727
2772
  const gitDir = await getActualGitDir(repositoryPath);
2728
2773
  const [headFiles, indexEntries] = await Promise.all([listTreeFiles(repositoryPath, headTreeOid), parseGitIndex(gitDir)]);
2729
- const workdirFiles = await listWorkingDirectoryFiles(repositoryPath, listTrackedDirectories(indexEntries));
2774
+ const workdirFiles = await listWorkingDirectoryFiles(repositoryPath, listTrackedDirectories(indexEntries), new Set(Array.from(indexEntries.values()).filter(isGitLinkIndexEntry).map((entry) => entry.path)));
2730
2775
  const modifiedFiles = /* @__PURE__ */ new Map();
2731
2776
  const rememberModifiedFile = (path, reason) => {
2732
2777
  if (!modifiedFiles.has(path)) modifiedFiles.set(path, {
@@ -2744,6 +2789,10 @@ var getModifiedFiles = async (repositoryPath, headTreeOid) => {
2744
2789
  const absolutePath = join(repositoryPath, indexEntry.path);
2745
2790
  try {
2746
2791
  const stats = await fs.lstat(absolutePath);
2792
+ if (isGitLinkIndexEntry(indexEntry)) {
2793
+ if (indexEntry.stage !== 0) rememberModifiedFile(indexEntry.path, "staged");
2794
+ continue;
2795
+ }
2747
2796
  if (!stats.isFile() && !stats.isSymbolicLink()) {
2748
2797
  rememberModifiedFile(indexEntry.path, "worktree");
2749
2798
  continue;
@@ -2784,7 +2833,7 @@ var formatModifiedFile = (modifiedFile) => `'${modifiedFile.path}':${modifiedFil
2784
2833
  * @param commitToTags - Map of commit hash to tags for performance
2785
2834
  * @returns The version or undefined if no version is found
2786
2835
  */
2787
- var lookupVersionLabelRecursive = async (cwd, commit, reachedCommits, commitToTags) => {
2836
+ var lookupVersionLabelRecursive = async (context, commit, reachedCommits, commitToTags) => {
2788
2837
  const scheduledStack = [];
2789
2838
  let version = {
2790
2839
  major: 0,
@@ -2808,10 +2857,11 @@ var lookupVersionLabelRecursive = async (cwd, commit, reachedCommits, commitToTa
2808
2857
  try {
2809
2858
  const parentHashes = (await git.readCommit({
2810
2859
  fs,
2811
- dir: cwd,
2860
+ dir: context.dir,
2861
+ gitdir: context.gitdir,
2812
2862
  oid: currentCommit.hash
2813
2863
  })).commit.parent || [];
2814
- parentCommits = (await Promise.all(parentHashes.map((parentHash) => getCommit(cwd, parentHash)))).filter((ci) => ci !== void 0);
2864
+ parentCommits = (await Promise.all(parentHashes.map((parentHash) => getCommit(context, parentHash)))).filter((ci) => ci !== void 0);
2815
2865
  } catch (_unused6) {}
2816
2866
  if (parentCommits.length === 0) {
2817
2867
  reachedCommits.set(currentCommit.hash, version);
@@ -2826,7 +2876,7 @@ var lookupVersionLabelRecursive = async (cwd, commit, reachedCommits, commitToTa
2826
2876
  while (scheduledStack.length >= 1) {
2827
2877
  const { commit: scheduledCommit, parents } = scheduledStack.pop();
2828
2878
  if (parents.length >= 2) for (let index = 1; index < parents.length; index++) {
2829
- const alternateParentVersion = await lookupVersionLabelRecursive(cwd, parents[index], reachedCommits, commitToTags);
2879
+ const alternateParentVersion = await lookupVersionLabelRecursive(context, parents[index], reachedCommits, commitToTags);
2830
2880
  if (alternateParentVersion && compareVersions(alternateParentVersion, version) < 0) version = alternateParentVersion;
2831
2881
  }
2832
2882
  version = incrementLastVersionComponent(version);
@@ -2854,12 +2904,31 @@ var getGitMetadata = async (repositoryPath, checkWorkingDirectoryStatus, logger)
2854
2904
  logger.debug(`[screw-up] Total getGitMetadata: ${Date.now() - startTime}ms`);
2855
2905
  return metadata;
2856
2906
  }
2907
+ let gitContext;
2857
2908
  try {
2858
- const currentCommit = await getCurrentCommit(gitRootPath);
2859
- if (!currentCommit) {
2860
- logger.debug(`[screw-up] Total getGitMetadata: ${Date.now() - startTime}ms`);
2861
- return metadata;
2909
+ gitContext = await createGitReadContext(gitRootPath);
2910
+ } catch (error) {
2911
+ logger.warn(`Failed to resolve git metadata context: ${error}`);
2912
+ logger.debug(`[screw-up] Total getGitMetadata: ${Date.now() - startTime}ms`);
2913
+ return metadata;
2914
+ }
2915
+ const currentCommit = await getCurrentCommit(gitContext);
2916
+ if (!currentCommit) {
2917
+ logger.debug(`[screw-up] Total getGitMetadata: ${Date.now() - startTime}ms`);
2918
+ return metadata;
2919
+ }
2920
+ const gitMetadata = {
2921
+ tags: [],
2922
+ branches: [],
2923
+ commit: {
2924
+ hash: currentCommit.hash,
2925
+ shortHash: currentCommit.shortHash,
2926
+ date: dayjs(currentCommit.date).format("YYYY-MM-DDTHH:mm:ssZ"),
2927
+ message: currentCommit.message
2862
2928
  }
2929
+ };
2930
+ metadata.git = gitMetadata;
2931
+ try {
2863
2932
  const buildStart = Date.now();
2864
2933
  const commitToTags = await buildCompleteTagCache(gitRootPath, (tagName) => {
2865
2934
  const version = parseVersion(tagName);
@@ -2867,12 +2936,7 @@ var getGitMetadata = async (repositoryPath, checkWorkingDirectoryStatus, logger)
2867
2936
  }, logger);
2868
2937
  logger.debug(`[screw-up] buildCompleteTagCache: ${Date.now() - buildStart}ms`);
2869
2938
  logger.debug(`Built tag map with ${commitToTags.size} commits`);
2870
- let version = await lookupVersionLabelRecursive(gitRootPath, currentCommit, /* @__PURE__ */ new Map(), commitToTags);
2871
- const gitMetadata = {
2872
- tags: [],
2873
- branches: []
2874
- };
2875
- metadata.git = gitMetadata;
2939
+ let version = await lookupVersionLabelRecursive(gitContext, currentCommit, /* @__PURE__ */ new Map(), commitToTags);
2876
2940
  if (version) {
2877
2941
  if (checkWorkingDirectoryStatus) {
2878
2942
  const modifiedFiles = await getModifiedFiles(gitRootPath, currentCommit.tree);
@@ -2886,16 +2950,14 @@ var getGitMetadata = async (repositoryPath, checkWorkingDirectoryStatus, logger)
2886
2950
  gitMetadata.version = gitVersion;
2887
2951
  metadata.version = gitVersion;
2888
2952
  }
2889
- gitMetadata.commit = {
2890
- hash: currentCommit.hash,
2891
- shortHash: currentCommit.shortHash,
2892
- date: dayjs(currentCommit.date).format("YYYY-MM-DDTHH:mm:ssZ"),
2893
- message: currentCommit.message
2894
- };
2895
2953
  gitMetadata.tags = getRelatedTagsFromMap(commitToTags, currentCommit.hash).map((tag) => tag.name);
2896
- gitMetadata.branches = await getRelatedBranches(gitRootPath, currentCommit.hash);
2897
2954
  } catch (error) {
2898
- logger.warn(`Failed to extract git metadata: ${error}`);
2955
+ logger.warn(`Failed to resolve git versioning metadata: ${error}`);
2956
+ }
2957
+ try {
2958
+ gitMetadata.branches = await getRelatedBranches(gitContext, currentCommit.hash);
2959
+ } catch (error) {
2960
+ logger.warn(`Failed to resolve git branch metadata: ${error}`);
2899
2961
  }
2900
2962
  logger.debug(`[screw-up] Total getGitMetadata: ${Date.now() - startTime}ms`);
2901
2963
  return metadata;
@@ -2979,6 +3041,6 @@ var ensureMetadataGitignore = async (metadataSourcePath, logger) => {
2979
3041
  }
2980
3042
  };
2981
3043
  //#endregion
2982
- export { collectWorkspaceSiblings as a, replacePeerDependenciesWildcards as c, require_dist as d, __exportAll as f, getFetchGitMetadata as i, resolvePackageMetadata as l, generateMetadataFileContent as n, createConsoleLogger as o, __toESM as p, writeFileIfChanged as r, findWorkspaceRoot as s, ensureMetadataGitignore as t, resolveRawPackageJsonObject as u };
3044
+ export { __toESM as _, collectWorkspaceSiblings as a, replacePeerDependenciesWildcards as c, require_dist as d, author as f, version as g, repository_url as h, getFetchGitMetadata as i, resolvePackageMetadata as l, name as m, generateMetadataFileContent as n, createConsoleLogger as o, git_commit_hash as p, writeFileIfChanged as r, findWorkspaceRoot as s, ensureMetadataGitignore as t, resolveRawPackageJsonObject as u };
2983
3045
 
2984
- //# sourceMappingURL=metadata-file-D79yMa_A.js.map
3046
+ //# sourceMappingURL=metadata-file-DmnBAdfN.js.map