| 3 | const ISSUE_URL = 'https://github.com/getsentry/sentry-javascript/pull/'; |
| 4 | |
| 5 | export function getNewGitCommits(): string[] { |
| 6 | const commits = execSync('git log --format="- %s"').toString().split('\n'); |
| 7 | |
| 8 | const lastReleasePos = commits.findIndex(commit => /- meta\(changelog\)/i.test(commit)); |
| 9 | |
| 10 | const newCommits = commits.splice(0, lastReleasePos).filter(commit => { |
| 11 | // Filter out merge commits |
| 12 | if (/Merge pull request/.test(commit)) { |
| 13 | return false; |
| 14 | } |
| 15 | // Filter release branch merged |
| 16 | if (/Merge branch/.test(commit)) { |
| 17 | return false; |
| 18 | } |
| 19 | // Filter release commit itself |
| 20 | if (/release:/.test(commit)) { |
| 21 | return false; |
| 22 | } |
| 23 | |
| 24 | return true; |
| 25 | }); |
| 26 | |
| 27 | newCommits.sort((a, b) => a.localeCompare(b)); |
| 28 | |
| 29 | return newCommits.map(commit => commit.replace(/#(\d+)/, `[#$1](${ISSUE_URL}$1)`)); |
| 30 | } |
| 31 | |
| 32 | function run(): void { |
| 33 | // eslint-disable-next-line no-console |