gh-setup-git-identity 0.3.0 → 0.3.1
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/CHANGELOG.md +10 -0
- package/experiments/test-release-regex.mjs +111 -0
- package/package.json +1 -1
- package/scripts/format-release-notes.mjs +21 -17
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# gh-setup-git-identity
|
|
2
2
|
|
|
3
|
+
## 0.3.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 51dceeb: Fix release notes formatting to support Major and Minor changes
|
|
8
|
+
|
|
9
|
+
Previously, the format-release-notes.mjs script only looked for "### Patch Changes" sections in release notes. This caused releases with Minor or Major changes (like v0.3.0) to not be properly formatted with PR links and npm badges.
|
|
10
|
+
|
|
11
|
+
Updated the regex pattern to handle all three change types (Major, Minor, and Patch), matching the release template from test-anywhere repository.
|
|
12
|
+
|
|
3
13
|
## 0.3.0
|
|
4
14
|
|
|
5
15
|
### Minor Changes
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Test script to verify the release notes regex pattern
|
|
5
|
+
* works correctly for Major, Minor, and Patch changes
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
// Test cases representing different release note formats
|
|
9
|
+
const testCases = [
|
|
10
|
+
{
|
|
11
|
+
name: 'Minor Changes with commit hash',
|
|
12
|
+
body: `### Minor Changes
|
|
13
|
+
|
|
14
|
+
- 8c146cc: Automatically run \`gh auth login\` when GitHub CLI is not authenticated, enabling single-command setup instead of requiring manual login first`,
|
|
15
|
+
expectedType: 'Minor',
|
|
16
|
+
expectedHash: '8c146cc',
|
|
17
|
+
expectedDesc: 'Automatically run `gh auth login` when GitHub CLI is not authenticated, enabling single-command setup instead of requiring manual login first',
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
name: 'Patch Changes with commit hash',
|
|
21
|
+
body: `### Patch Changes
|
|
22
|
+
|
|
23
|
+
- abc1234: Fix a bug in the login flow`,
|
|
24
|
+
expectedType: 'Patch',
|
|
25
|
+
expectedHash: 'abc1234',
|
|
26
|
+
expectedDesc: 'Fix a bug in the login flow',
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: 'Major Changes with commit hash',
|
|
30
|
+
body: `### Major Changes
|
|
31
|
+
|
|
32
|
+
- deadbeef: Breaking change - new API`,
|
|
33
|
+
expectedType: 'Major',
|
|
34
|
+
expectedHash: 'deadbeef',
|
|
35
|
+
expectedDesc: 'Breaking change - new API',
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
name: 'Minor Changes without commit hash',
|
|
39
|
+
body: `### Minor Changes
|
|
40
|
+
|
|
41
|
+
- Add new feature`,
|
|
42
|
+
expectedType: 'Minor',
|
|
43
|
+
expectedHash: null,
|
|
44
|
+
expectedDesc: 'Add new feature',
|
|
45
|
+
},
|
|
46
|
+
];
|
|
47
|
+
|
|
48
|
+
// The regex pattern from the updated format-release-notes.mjs
|
|
49
|
+
const changesPattern =
|
|
50
|
+
/### (Major|Minor|Patch) Changes\s*\n\s*-\s+(?:([a-f0-9]+):\s+)?(.+?)$/s;
|
|
51
|
+
|
|
52
|
+
console.log('Testing release notes regex pattern\n');
|
|
53
|
+
console.log('='.repeat(60));
|
|
54
|
+
|
|
55
|
+
let passed = 0;
|
|
56
|
+
let failed = 0;
|
|
57
|
+
|
|
58
|
+
for (const testCase of testCases) {
|
|
59
|
+
console.log(`\nTest: ${testCase.name}`);
|
|
60
|
+
console.log('-'.repeat(40));
|
|
61
|
+
|
|
62
|
+
const match = testCase.body.match(changesPattern);
|
|
63
|
+
|
|
64
|
+
if (!match) {
|
|
65
|
+
console.log('❌ FAILED: No match found');
|
|
66
|
+
failed++;
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const [, changeType, commitHash, rawDescription] = match;
|
|
71
|
+
|
|
72
|
+
let allPassed = true;
|
|
73
|
+
|
|
74
|
+
if (changeType !== testCase.expectedType) {
|
|
75
|
+
console.log(`❌ changeType: expected '${testCase.expectedType}', got '${changeType}'`);
|
|
76
|
+
allPassed = false;
|
|
77
|
+
} else {
|
|
78
|
+
console.log(`✅ changeType: ${changeType}`);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const expectedHash = testCase.expectedHash || null;
|
|
82
|
+
const actualHash = commitHash || null;
|
|
83
|
+
if (actualHash !== expectedHash) {
|
|
84
|
+
console.log(`❌ commitHash: expected '${expectedHash}', got '${actualHash}'`);
|
|
85
|
+
allPassed = false;
|
|
86
|
+
} else {
|
|
87
|
+
console.log(`✅ commitHash: ${actualHash}`);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (rawDescription !== testCase.expectedDesc) {
|
|
91
|
+
console.log(`❌ description: expected '${testCase.expectedDesc}', got '${rawDescription}'`);
|
|
92
|
+
allPassed = false;
|
|
93
|
+
} else {
|
|
94
|
+
console.log(`✅ description: ${rawDescription.substring(0, 50)}...`);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (allPassed) {
|
|
98
|
+
passed++;
|
|
99
|
+
console.log('✅ TEST PASSED');
|
|
100
|
+
} else {
|
|
101
|
+
failed++;
|
|
102
|
+
console.log('❌ TEST FAILED');
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
console.log('\n' + '='.repeat(60));
|
|
107
|
+
console.log(`\nResults: ${passed} passed, ${failed} failed`);
|
|
108
|
+
|
|
109
|
+
if (failed > 0) {
|
|
110
|
+
process.exit(1);
|
|
111
|
+
}
|
package/package.json
CHANGED
|
@@ -86,28 +86,32 @@ try {
|
|
|
86
86
|
process.exit(0);
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
// Extract the
|
|
90
|
-
// This regex handles
|
|
91
|
-
// 1. With commit hash: "- abc1234: Description"
|
|
92
|
-
// 2. Without commit hash: "- Description"
|
|
93
|
-
const
|
|
94
|
-
/### Patch Changes\s*\n\s*-\s+([a-f0-9]+):\s+(.+?)$/s
|
|
95
|
-
);
|
|
96
|
-
const patchChangesMatchNoHash = currentBody.match(
|
|
97
|
-
/### Patch Changes\s*\n\s*-\s+(.+?)$/s
|
|
98
|
-
);
|
|
89
|
+
// Extract the changes section (Major, Minor, or Patch)
|
|
90
|
+
// This regex handles formats:
|
|
91
|
+
// 1. With commit hash: "### Major Changes\n- abc1234: Description"
|
|
92
|
+
// 2. Without commit hash: "### Minor Changes\n- Description"
|
|
93
|
+
const changesPattern =
|
|
94
|
+
/### (Major|Minor|Patch) Changes\s*\n\s*-\s+(?:([a-f0-9]+):\s+)?(.+?)$/s;
|
|
95
|
+
const changesMatch = currentBody.match(changesPattern);
|
|
99
96
|
|
|
100
97
|
let commitHash = null;
|
|
101
98
|
let rawDescription = null;
|
|
99
|
+
let changeType = null;
|
|
100
|
+
|
|
101
|
+
if (changesMatch) {
|
|
102
|
+
[, changeType, commitHash, rawDescription] = changesMatch;
|
|
103
|
+
console.log(`Found ${changeType} Changes section`);
|
|
102
104
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
105
|
+
// Extract commit hash if embedded in description (fallback)
|
|
106
|
+
if (!commitHash && rawDescription) {
|
|
107
|
+
const descWithHashMatch = rawDescription.match(/^([a-f0-9]+):\s+(.+)$/s);
|
|
108
|
+
if (descWithHashMatch) {
|
|
109
|
+
[, commitHash, rawDescription] = descWithHashMatch;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
109
112
|
} else {
|
|
110
|
-
console.log('Could not parse
|
|
113
|
+
console.log('Could not parse changes from release notes');
|
|
114
|
+
console.log(' Looking for pattern: ### [Major|Minor|Patch] Changes');
|
|
111
115
|
process.exit(0);
|
|
112
116
|
}
|
|
113
117
|
|