jettypod 4.2.6 → 4.2.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/lib/worktree-manager.js +59 -1
- package/package.json +1 -1
package/lib/worktree-manager.js
CHANGED
|
@@ -84,6 +84,46 @@ async function createWorktree(workItem, options = {}) {
|
|
|
84
84
|
let worktreeCreated = false;
|
|
85
85
|
|
|
86
86
|
try {
|
|
87
|
+
// Step 0: Auto-commit untracked BDD files before creating worktree
|
|
88
|
+
// Feature planning creates .feature and step definition files in main repo
|
|
89
|
+
// These need to be committed so the worktree branch can access them
|
|
90
|
+
try {
|
|
91
|
+
// Find untracked BDD files
|
|
92
|
+
const untrackedOutput = execSync('git ls-files --others --exclude-standard', {
|
|
93
|
+
cwd: gitRoot,
|
|
94
|
+
encoding: 'utf8'
|
|
95
|
+
}).trim();
|
|
96
|
+
|
|
97
|
+
if (untrackedOutput) {
|
|
98
|
+
const untrackedFiles = untrackedOutput.split('\n');
|
|
99
|
+
const bddFiles = untrackedFiles.filter(f =>
|
|
100
|
+
f.endsWith('.feature') ||
|
|
101
|
+
f.includes('step_definitions/') ||
|
|
102
|
+
f.includes('steps/')
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
if (bddFiles.length > 0) {
|
|
106
|
+
// Stage and commit BDD files
|
|
107
|
+
for (const file of bddFiles) {
|
|
108
|
+
execSync(`git add "${file}"`, { cwd: gitRoot, stdio: 'pipe' });
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
execSync(`git commit -m "Add BDD scenarios for work item #${workItem.id}"`, {
|
|
112
|
+
cwd: gitRoot,
|
|
113
|
+
stdio: 'pipe'
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
console.log(`📝 Auto-committed ${bddFiles.length} BDD file(s) before creating worktree`);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
} catch (commitErr) {
|
|
120
|
+
// Non-fatal - log warning but continue
|
|
121
|
+
// Could fail if no BDD files or already committed
|
|
122
|
+
if (!commitErr.message.includes('nothing to commit')) {
|
|
123
|
+
console.warn(`Warning: Could not auto-commit BDD files: ${commitErr.message}`);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
87
127
|
// Step 1: Create database entry with status='active'
|
|
88
128
|
// Note: We use 'active' from the start because if anything fails,
|
|
89
129
|
// we'll delete the entire entry during rollback
|
|
@@ -177,7 +217,25 @@ async function createWorktree(workItem, options = {}) {
|
|
|
177
217
|
throw new Error(`Failed to create .jettypod symlink: ${symlinkErr.message}`);
|
|
178
218
|
}
|
|
179
219
|
|
|
180
|
-
// Step 5:
|
|
220
|
+
// Step 5: Symlink .env files from main repo
|
|
221
|
+
// Environment files are typically gitignored, so worktrees don't get them
|
|
222
|
+
try {
|
|
223
|
+
const envFiles = fs.readdirSync(gitRoot).filter(f => f.startsWith('.env'));
|
|
224
|
+
for (const envFile of envFiles) {
|
|
225
|
+
const envSource = path.join(gitRoot, envFile);
|
|
226
|
+
const envTarget = path.join(worktreePath, envFile);
|
|
227
|
+
|
|
228
|
+
// Only symlink if source is a file and target doesn't exist
|
|
229
|
+
if (fs.statSync(envSource).isFile() && !fs.existsSync(envTarget)) {
|
|
230
|
+
fs.symlinkSync(envSource, envTarget);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
} catch (envErr) {
|
|
234
|
+
// Non-fatal - log warning but continue
|
|
235
|
+
console.warn(`Warning: Could not symlink .env files: ${envErr.message}`);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
// Step 6: Return the created worktree record
|
|
181
239
|
const worktree = await new Promise((resolve, reject) => {
|
|
182
240
|
db.get('SELECT * FROM worktrees WHERE id = ?', [worktreeId], (err, row) => {
|
|
183
241
|
if (err) reject(err);
|