@miketromba/issy-core 0.1.7 → 0.1.8
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/package.json +1 -1
- package/src/lib/index.ts +1 -0
- package/src/lib/issues.ts +29 -2
package/package.json
CHANGED
package/src/lib/index.ts
CHANGED
package/src/lib/issues.ts
CHANGED
|
@@ -61,11 +61,30 @@ export function findIssuesDirUpward(fromPath: string): string | null {
|
|
|
61
61
|
return null
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
+
/**
|
|
65
|
+
* Find the git repository root by walking up from the given path.
|
|
66
|
+
* Returns the directory containing .git, or null if not in a git repo.
|
|
67
|
+
*/
|
|
68
|
+
export function findGitRoot(fromPath: string): string | null {
|
|
69
|
+
let current = resolve(fromPath)
|
|
70
|
+
for (let i = 0; i < 20; i++) {
|
|
71
|
+
const gitDir = join(current, '.git')
|
|
72
|
+
if (existsSync(gitDir)) {
|
|
73
|
+
return current
|
|
74
|
+
}
|
|
75
|
+
const parent = dirname(current)
|
|
76
|
+
if (parent === current) break // reached filesystem root
|
|
77
|
+
current = parent
|
|
78
|
+
}
|
|
79
|
+
return null
|
|
80
|
+
}
|
|
81
|
+
|
|
64
82
|
/**
|
|
65
83
|
* Resolve the issues directory using the following priority:
|
|
66
84
|
* 1. ISSUES_DIR env var (explicit override)
|
|
67
85
|
* 2. Walk up from ISSUES_ROOT or cwd to find existing .issues directory
|
|
68
|
-
* 3.
|
|
86
|
+
* 3. If in a git repo, use .issues at the repo root
|
|
87
|
+
* 4. Fall back to creating .issues in ISSUES_ROOT or cwd
|
|
69
88
|
*
|
|
70
89
|
* This also sets the internal issuesDir variable.
|
|
71
90
|
*/
|
|
@@ -85,7 +104,15 @@ export function resolveIssuesDir(): string {
|
|
|
85
104
|
return found
|
|
86
105
|
}
|
|
87
106
|
|
|
88
|
-
// 3.
|
|
107
|
+
// 3. If in a git repo, use .issues at the repo root
|
|
108
|
+
const gitRoot = findGitRoot(startDir)
|
|
109
|
+
if (gitRoot) {
|
|
110
|
+
const gitIssuesDir = join(gitRoot, '.issues')
|
|
111
|
+
setIssuesDir(gitIssuesDir)
|
|
112
|
+
return gitIssuesDir
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// 4. Fall back to creating .issues in the start directory
|
|
89
116
|
const fallback = join(resolve(startDir), '.issues')
|
|
90
117
|
setIssuesDir(fallback)
|
|
91
118
|
return fallback
|