-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
125 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
This program and the accompanying materials are | ||
made available under the terms of the Eclipse Public License v2.0 which accompanies | ||
this distribution, and is available at https://www.eclipse.org/legal/epl-v20.html | ||
SPDX-License-Identifier: EPL-2.0 | ||
Copyright Contributors to the Zowe Project. | ||
*/ | ||
|
||
const fs = require('fs'); | ||
|
||
// Must run with args: PR_NUMBER | ||
const PR_NUMBER = process.argv[2]; | ||
const description = fs.readFileSync('/tmp/pr_description.txt', 'utf8'); | ||
let changelogMsg, version; | ||
|
||
if (description.includes('VERSION:') && description.includes('CHANGELOG:')) { | ||
let lines = description.split('\n'); | ||
lines.forEach((line) => { | ||
if (line.startsWith('CHANGELOG:')) { | ||
changelogMsg = line.substring('CHANGELOG:'.length).trim(); | ||
} else if (line.startsWith('VERSION:')) { | ||
version = line.substring('VERSION:'.length).trim(); | ||
} | ||
}); | ||
|
||
if (changelogMsg && version) { | ||
let changelog = fs.readFileSync('CHANGELOG.md', 'utf8'); | ||
let changelogLines = changelog.split('\n'); | ||
let versionIndex = -1; | ||
let anchorIndex = 0; | ||
for (let i = 0; i < changelogLines.length; i++) { | ||
if (changelogLines[i].includes('All notable changes to the Zlux App Manager will be documented in this file.')) { | ||
anchorIndex = i; | ||
} else if (changelogLines[i].startsWith('## ' + version)) { // Removed "v" prefix | ||
versionIndex = i; | ||
break; | ||
} | ||
} | ||
if (versionIndex != -1) { | ||
changelogLines.splice(versionIndex + 2, 0, `- ${changelogMsg} (#${PR_NUMBER})`); | ||
} else { | ||
changelogLines.splice(anchorIndex + 1, 0, `\n## \`${version}\`\n- ${changelogMsg} (#${PR_NUMBER})`); | ||
} | ||
const newChangelog = changelogLines.join('\n'); | ||
fs.writeFileSync('CHANGELOG.md', newChangelog); | ||
console.log('Success'); | ||
} else { | ||
if (!changelogMsg) { | ||
console.log('Missing CHANGELOG'); | ||
} | ||
if (!version) { | ||
console.log('Missing VERSION'); | ||
} | ||
} | ||
} else { | ||
console.log('Missing CHANGELOG or VERSION'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.