@gracefullight/validate-branch 1.1.3 → 1.1.4

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/cli.js CHANGED
@@ -49,15 +49,30 @@ async function loadConfig() {
49
49
 
50
50
  // src/validate-branch-name.ts
51
51
  import * as fs from "fs";
52
+ import { readFileSync } from "fs";
53
+ import { resolve as resolvePath } from "path";
52
54
  import { cwd as cwd2 } from "process";
53
55
  import * as git from "isomorphic-git";
56
+ function resolveGitdir(startDir) {
57
+ const dotGit = resolvePath(startDir, ".git");
58
+ const stat = fs.statSync(dotGit);
59
+ if (stat.isFile()) {
60
+ const content = readFileSync(dotGit, "utf-8");
61
+ const match = content.match(/gitdir:\s*(.+)/);
62
+ if (match) {
63
+ return resolvePath(match[1].trim());
64
+ }
65
+ }
66
+ return dotGit;
67
+ }
54
68
  var GITFLOW_PATTERN = /^(main|master|develop|stage|feature\/[A-Za-z0-9_-]+|fix\/[A-Za-z0-9_-]+|hotfix\/[A-Za-z0-9_-]+|release\/[A-Za-z0-9_.-]+)$/;
55
69
  var JIRA_PATTERN = /^(main|master|develop|stage|[A-Z]+-[0-9]+)$/;
56
70
  async function getCurrentBranchName() {
57
71
  try {
72
+ const gitdir = resolveGitdir(cwd2());
58
73
  const branch = await git.currentBranch({
59
74
  fs,
60
- dir: cwd2(),
75
+ gitdir,
61
76
  fullname: false
62
77
  });
63
78
  return branch ?? null;
package/dist/index.js CHANGED
@@ -43,8 +43,22 @@ async function loadConfig() {
43
43
 
44
44
  // src/validate-branch-name.ts
45
45
  import * as fs from "fs";
46
+ import { readFileSync } from "fs";
47
+ import { resolve as resolvePath } from "path";
46
48
  import { cwd as cwd2 } from "process";
47
49
  import * as git from "isomorphic-git";
50
+ function resolveGitdir(startDir) {
51
+ const dotGit = resolvePath(startDir, ".git");
52
+ const stat = fs.statSync(dotGit);
53
+ if (stat.isFile()) {
54
+ const content = readFileSync(dotGit, "utf-8");
55
+ const match = content.match(/gitdir:\s*(.+)/);
56
+ if (match) {
57
+ return resolvePath(match[1].trim());
58
+ }
59
+ }
60
+ return dotGit;
61
+ }
48
62
  var GITFLOW_PATTERN = /^(main|master|develop|stage|feature\/[A-Za-z0-9_-]+|fix\/[A-Za-z0-9_-]+|hotfix\/[A-Za-z0-9_-]+|release\/[A-Za-z0-9_.-]+)$/;
49
63
  var JIRA_PATTERN = /^(main|master|develop|stage|[A-Z]+-[0-9]+)$/;
50
64
  function validateBranchName(branchName, options) {
@@ -57,9 +71,10 @@ function validateBranchName(branchName, options) {
57
71
  }
58
72
  async function getCurrentBranchName() {
59
73
  try {
74
+ const gitdir = resolveGitdir(cwd2());
60
75
  const branch = await git.currentBranch({
61
76
  fs,
62
- dir: cwd2(),
77
+ gitdir,
63
78
  fullname: false
64
79
  });
65
80
  return branch ?? null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gracefullight/validate-branch",
3
- "version": "1.1.3",
3
+ "version": "1.1.4",
4
4
  "description": "Git branch name validation tool with custom regexp support",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",