Skip to content

Commit 55d8324

Browse files
Merge pull request #116 from VirdocsSoftware/hotfix/v2.22.1
hotfix v2.23.0 to main
2 parents 25101a7 + 244fcf0 commit 55d8324

5 files changed

Lines changed: 87 additions & 37 deletions

File tree

.github/actions/auto-pr-description/filter_diff.js

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ const fs = require('fs');
44

55
/**
66
* Filters out specified files from a git diff
7-
* Usage: node filter_diff.js <diff_file> <ignore_files_comma_separated>
7+
* Usage: node filter_diff.js <diff_file> <ignore_files_comma_separated> [max_lines]
88
*/
99

10-
function filterDiff(diffContent, ignoreFiles) {
10+
function filterDiff(diffContent, ignoreFiles, maxLines = null) {
1111
if (!ignoreFiles || ignoreFiles.trim() === '') {
1212
return diffContent;
1313
}
@@ -55,15 +55,24 @@ function filterDiff(diffContent, ignoreFiles) {
5555
}
5656
}
5757

58-
return filteredLines.join('\n');
58+
let result = filteredLines.join('\n');
59+
60+
// Apply line limit if specified
61+
if (maxLines && filteredLines.length > maxLines) {
62+
const truncatedLines = filteredLines.slice(0, maxLines);
63+
truncatedLines.push('', '# ... (diff truncated due to size limits) ...', '');
64+
result = truncatedLines.join('\n');
65+
}
66+
67+
return result;
5968
}
6069

6170
// Main execution
6271
if (require.main === module) {
63-
const [, , diffFile, ignoreFiles] = process.argv;
72+
const [, , diffFile, ignoreFiles, maxLines] = process.argv;
6473

6574
if (!diffFile) {
66-
console.error('Usage: filter_diff.js <diff_file> <ignore_files_comma_separated>');
75+
console.error('Usage: filter_diff.js <diff_file> <ignore_files_comma_separated> [max_lines]');
6776
process.exit(1);
6877
}
6978

@@ -74,7 +83,8 @@ if (require.main === module) {
7483

7584
try {
7685
const diffContent = fs.readFileSync(diffFile, 'utf8');
77-
const filteredDiff = filterDiff(diffContent, ignoreFiles || '');
86+
const maxLinesInt = maxLines ? parseInt(maxLines, 10) : null;
87+
const filteredDiff = filterDiff(diffContent, ignoreFiles || '', maxLinesInt);
7888

7989
// Write filtered diff back to the same file
8090
fs.writeFileSync(diffFile, filteredDiff, 'utf8');
@@ -88,6 +98,9 @@ if (require.main === module) {
8898
if (ignoreFiles) {
8999
console.error(`Ignored files: ${ignoreFiles}`);
90100
}
101+
if (maxLinesInt && originalLines > maxLinesInt) {
102+
console.error(`Applied line limit: ${maxLinesInt}`);
103+
}
91104
} catch (error) {
92105
console.error(`Error filtering diff: ${error.message}`);
93106
process.exit(1);

.github/actions/auto-pr-description/generate_pr_description.js

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,22 @@ const path = require('path');
2222
}
2323

2424
// Create prompt for PR description generation
25-
const promptTemplate = `You are an expert programmer who is tasked with writing a pull request description.
26-
You will be given the git diff of the changes and you must write a markdown pull request description.
27-
Do not include the git diff in the pull request description. Do not include any other text in the pull request description.
28-
The pull request description should follow the following format:
25+
const promptTemplate = `Write a concise pull request description based on the git diff. Use this exact format:
2926
3027
## Description
31-
A short description of the changes.
28+
Brief summary of changes (1-2 sentences max).
3229
3330
## Changes
34-
- [ ] Change 1
35-
- [ ] Change 2
31+
- [ ] Key change 1
32+
- [ ] Key change 2
33+
- [ ] Key change 3 (max 5 items)
3634
3735
## Verification
38-
- [ ] Verification step 1
39-
- [ ] Verification step 2
40-
`;
36+
- [ ] Test step 1
37+
- [ ] Test step 2
38+
- [ ] Test step 3 (max 3 items)
39+
40+
Keep it concise and focused on the most important changes.`;
4141

4242
const diffContent = fs.readFileSync(diffFile, 'utf8');
4343
const combinedPrompt = `${promptTemplate}\n\nHere is the git diff:\n\n${diffContent}`;
@@ -56,7 +56,7 @@ A short description of the changes.
5656
temperature: 0.7,
5757
topK: 40,
5858
topP: 0.95,
59-
maxOutputTokens: 2048,
59+
maxOutputTokens: 1024,
6060
}
6161
})
6262
});
@@ -70,12 +70,24 @@ A short description of the changes.
7070

7171
const json = await response.json();
7272

73-
if (!json.candidates || !json.candidates[0] || !json.candidates[0].content) {
73+
if (!json.candidates || !json.candidates[0]) {
7474
console.error('Error: Invalid response from Gemini API');
7575
console.error(JSON.stringify(json, null, 2));
7676
process.exit(1);
7777
}
7878

79+
// Check if response was truncated due to max tokens
80+
if (json.candidates[0].finishReason === 'MAX_TOKENS') {
81+
console.error('Warning: Response was truncated due to token limit. Consider reducing diff size or using more specific ignore-files.');
82+
// Continue processing the partial response
83+
}
84+
85+
if (!json.candidates[0].content) {
86+
console.error('Error: No content in API response');
87+
console.error(JSON.stringify(json, null, 2));
88+
process.exit(1);
89+
}
90+
7991
if (!json.candidates[0].content.parts || !json.candidates[0].content.parts[0] || !json.candidates[0].content.parts[0].text) {
8092
console.error('Error: Invalid response structure from Gemini API - missing parts or text');
8193
console.error(JSON.stringify(json, null, 2));

.github/actions/auto-release-description/filter_diff.js

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ const fs = require('fs');
44

55
/**
66
* Filters out specified files from a git diff
7-
* Usage: node filter_diff.js <diff_file> <ignore_files_comma_separated>
7+
* Usage: node filter_diff.js <diff_file> <ignore_files_comma_separated> [max_lines]
88
*/
99

10-
function filterDiff(diffContent, ignoreFiles) {
10+
function filterDiff(diffContent, ignoreFiles, maxLines = null) {
1111
if (!ignoreFiles || ignoreFiles.trim() === '') {
1212
return diffContent;
1313
}
@@ -55,15 +55,24 @@ function filterDiff(diffContent, ignoreFiles) {
5555
}
5656
}
5757

58-
return filteredLines.join('\n');
58+
let result = filteredLines.join('\n');
59+
60+
// Apply line limit if specified
61+
if (maxLines && filteredLines.length > maxLines) {
62+
const truncatedLines = filteredLines.slice(0, maxLines);
63+
truncatedLines.push('', '# ... (diff truncated due to size limits) ...', '');
64+
result = truncatedLines.join('\n');
65+
}
66+
67+
return result;
5968
}
6069

6170
// Main execution
6271
if (require.main === module) {
63-
const [, , diffFile, ignoreFiles] = process.argv;
72+
const [, , diffFile, ignoreFiles, maxLines] = process.argv;
6473

6574
if (!diffFile) {
66-
console.error('Usage: filter_diff.js <diff_file> <ignore_files_comma_separated>');
75+
console.error('Usage: filter_diff.js <diff_file> <ignore_files_comma_separated> [max_lines]');
6776
process.exit(1);
6877
}
6978

@@ -74,7 +83,8 @@ if (require.main === module) {
7483

7584
try {
7685
const diffContent = fs.readFileSync(diffFile, 'utf8');
77-
const filteredDiff = filterDiff(diffContent, ignoreFiles || '');
86+
const maxLinesInt = maxLines ? parseInt(maxLines, 10) : null;
87+
const filteredDiff = filterDiff(diffContent, ignoreFiles || '', maxLinesInt);
7888

7989
// Write filtered diff back to the same file
8090
fs.writeFileSync(diffFile, filteredDiff, 'utf8');
@@ -88,6 +98,9 @@ if (require.main === module) {
8898
if (ignoreFiles) {
8999
console.error(`Ignored files: ${ignoreFiles}`);
90100
}
101+
if (maxLinesInt && originalLines > maxLinesInt) {
102+
console.error(`Applied line limit: ${maxLinesInt}`);
103+
}
91104
} catch (error) {
92105
console.error(`Error filtering diff: ${error.message}`);
93106
process.exit(1);

.github/actions/auto-release-description/generate_pr_description.js

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,22 @@ const path = require('path');
2222
}
2323

2424
// Create prompt for PR description generation
25-
const promptTemplate = `You are an expert programmer who is tasked with writing a pull request description.
26-
You will be given the git diff of the changes and you must write a markdown pull request description.
27-
Do not include the git diff in the pull request description. Do not include any other text in the pull request description.
28-
The pull request description should follow the following format:
25+
const promptTemplate = `Write a concise pull request description based on the git diff. Use this exact format:
2926
3027
## Description
31-
A short description of the changes.
28+
Brief summary of changes (1-2 sentences max).
3229
3330
## Changes
34-
- [ ] Change 1
35-
- [ ] Change 2
31+
- [ ] Key change 1
32+
- [ ] Key change 2
33+
- [ ] Key change 3 (max 5 items)
3634
3735
## Verification
38-
- [ ] Verification step 1
39-
- [ ] Verification step 2
40-
`;
36+
- [ ] Test step 1
37+
- [ ] Test step 2
38+
- [ ] Test step 3 (max 3 items)
39+
40+
Keep it concise and focused on the most important changes.`;
4141

4242
const diffContent = fs.readFileSync(diffFile, 'utf8');
4343
const combinedPrompt = `${promptTemplate}\n\nHere is the git diff:\n\n${diffContent}`;
@@ -56,7 +56,7 @@ A short description of the changes.
5656
temperature: 0.7,
5757
topK: 40,
5858
topP: 0.95,
59-
maxOutputTokens: 2048,
59+
maxOutputTokens: 1024,
6060
}
6161
})
6262
});
@@ -70,12 +70,24 @@ A short description of the changes.
7070

7171
const json = await response.json();
7272

73-
if (!json.candidates || !json.candidates[0] || !json.candidates[0].content) {
73+
if (!json.candidates || !json.candidates[0]) {
7474
console.error('Error: Invalid response from Gemini API');
7575
console.error(JSON.stringify(json, null, 2));
7676
process.exit(1);
7777
}
7878

79+
// Check if response was truncated due to max tokens
80+
if (json.candidates[0].finishReason === 'MAX_TOKENS') {
81+
console.error('Warning: Response was truncated due to token limit. Consider reducing diff size or using more specific ignore-files.');
82+
// Continue processing the partial response
83+
}
84+
85+
if (!json.candidates[0].content) {
86+
console.error('Error: No content in API response');
87+
console.error(JSON.stringify(json, null, 2));
88+
process.exit(1);
89+
}
90+
7991
if (!json.candidates[0].content.parts || !json.candidates[0].content.parts[0] || !json.candidates[0].content.parts[0].text) {
8092
console.error('Error: Invalid response structure from Gemini API - missing parts or text');
8193
console.error(JSON.stringify(json, null, 2));

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "github-actions",
3-
"version": "2.22.0",
3+
"version": "2.23.0",
44
"description": "Used to store GitHub actions for use across the enterprise",
55
"scripts": {
66
"test": "./tooling/scripts/run_tests.sh",

0 commit comments

Comments
 (0)