jettypod 4.4.35 → 4.4.36

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/hooks/pre-commit CHANGED
@@ -1,30 +1,61 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- const { exportAll } = require('jettypod/lib/db-export');
3
+ // JettyPod pre-commit hook: Block direct commits to main branch
4
+ // This is the standalone version used for BDD testing
5
+ // The production version is in lib/git-hooks/pre-commit
6
+
4
7
  const { execSync } = require('child_process');
8
+ const fs = require('fs');
9
+ const path = require('path');
5
10
 
6
- (async () => {
11
+ // Check if direct commits to main should be blocked
12
+ function checkBranchRestriction() {
7
13
  try {
8
- // Export databases to JSON
9
- await exportAll();
10
-
11
- // Stage the JSON files
12
- try {
13
- execSync('git add .jettypod/snapshots/work.json', { stdio: 'inherit' });
14
- execSync('git add .jettypod/snapshots/database.json', { stdio: 'inherit' });
15
- } catch (gitErr) {
16
- // Log warning but don't block commit
17
- console.error('Pre-commit hook warning: Failed to stage snapshot files');
18
- console.error(` ${gitErr.message}`);
19
- console.error(' Commit will proceed but snapshots may not be included');
14
+ // Get current branch name
15
+ const branch = execSync('git symbolic-ref --short HEAD', {
16
+ encoding: 'utf-8',
17
+ stdio: ['pipe', 'pipe', 'pipe']
18
+ }).trim();
19
+
20
+ // Only restrict main/master branches
21
+ if (branch !== 'main' && branch !== 'master') {
22
+ return true; // Allow commits on feature branches
20
23
  }
21
24
 
22
- // Always exit successfully to allow commit to proceed
23
- process.exit(0);
25
+ // Check if this is a merge commit (MERGE_HEAD exists)
26
+ const gitDir = execSync('git rev-parse --git-dir', {
27
+ encoding: 'utf-8',
28
+ stdio: ['pipe', 'pipe', 'pipe']
29
+ }).trim();
30
+
31
+ if (fs.existsSync(path.join(gitDir, 'MERGE_HEAD'))) {
32
+ return true; // Allow merge commits on main
33
+ }
34
+
35
+ // Block direct commits to main
36
+ console.error('');
37
+ console.error('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
38
+ console.error('❌ Direct commits to main are not allowed');
39
+ console.error('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
40
+ console.error('');
41
+ console.error('Use the JettyPod workflow instead:');
42
+ console.error('');
43
+ console.error(' jettypod work start <work-item-id>');
44
+ console.error('');
45
+ console.error('This creates a feature branch where you can commit freely.');
46
+ console.error('When done, use \'jettypod work done\' to merge back to main.');
47
+ console.error('');
48
+ return false;
24
49
  } catch (err) {
25
- // Log warning but don't block commit
26
- console.error('Pre-commit hook warning:', err.message);
27
- console.error(' Commit will proceed but snapshots were not updated');
28
- process.exit(0);
50
+ // If we can't determine branch (detached HEAD, etc.), allow the commit
51
+ return true;
29
52
  }
30
- })();
53
+ }
54
+
55
+ // Check branch restriction first
56
+ if (!checkBranchRestriction()) {
57
+ process.exit(1);
58
+ }
59
+
60
+ // Allow commit
61
+ process.exit(0);
@@ -1,11 +1,60 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- // Pre-commit hook: Run tests before allowing commit
3
+ // Pre-commit hook: Block direct commits to main + run tests
4
4
 
5
5
  const { execSync } = require('child_process');
6
6
  const fs = require('fs');
7
7
  const path = require('path');
8
8
 
9
+ // Check if direct commits to main should be blocked
10
+ function checkBranchRestriction() {
11
+ try {
12
+ // Get current branch name
13
+ const branch = execSync('git symbolic-ref --short HEAD', {
14
+ encoding: 'utf-8',
15
+ stdio: ['pipe', 'pipe', 'pipe']
16
+ }).trim();
17
+
18
+ // Only restrict main/master branches
19
+ if (branch !== 'main' && branch !== 'master') {
20
+ return true; // Allow commits on feature branches
21
+ }
22
+
23
+ // Check if this is a merge commit (MERGE_HEAD exists)
24
+ const gitDir = execSync('git rev-parse --git-dir', {
25
+ encoding: 'utf-8',
26
+ stdio: ['pipe', 'pipe', 'pipe']
27
+ }).trim();
28
+
29
+ if (fs.existsSync(path.join(gitDir, 'MERGE_HEAD'))) {
30
+ return true; // Allow merge commits on main
31
+ }
32
+
33
+ // Block direct commits to main
34
+ console.error('');
35
+ console.error('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
36
+ console.error('❌ Direct commits to main are not allowed');
37
+ console.error('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
38
+ console.error('');
39
+ console.error('Use the JettyPod workflow instead:');
40
+ console.error('');
41
+ console.error(' jettypod work start <work-item-id>');
42
+ console.error('');
43
+ console.error('This creates a feature branch where you can commit freely.');
44
+ console.error('When done, use \'jettypod work done\' to merge back to main.');
45
+ console.error('');
46
+ return false;
47
+ } catch (err) {
48
+ // If we can't determine branch (detached HEAD, etc.), allow the commit
49
+ return true;
50
+ }
51
+ }
52
+
53
+ // First check branch restriction
54
+ if (!checkBranchRestriction()) {
55
+ process.exit(1);
56
+ }
57
+
9
58
  // Check if we're in a real project (not a test directory)
10
59
  const packageJsonPath = path.join(process.cwd(), 'package.json');
11
60
  if (!fs.existsSync(packageJsonPath)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jettypod",
3
- "version": "4.4.35",
3
+ "version": "4.4.36",
4
4
  "description": "AI-powered development workflow manager with TDD, BDD, and automatic test generation",
5
5
  "main": "jettypod.js",
6
6
  "bin": {