Skip to content

fix: resolve bug in changelog.js for commit retrieval during release #53

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions .github/scripts/changelog.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,16 +177,20 @@ async function getGitHubUsername(email) {
}

/**
* Gets all commits between HEAD and origin/main, including commit hash,
* author email, GitHub username (if found), and commit message.
* Retrieves all commits between the specified latest release tag and HEAD,
* including the commit hash, author email, GitHub username (if found), and
* commit message. Filters out merge commits following a specific pattern.
*
* @returns {Promise<Array>} Array of processed commit objects with hash, username, and message
* @throws {Error} If git command execution fails
* @param {string} latestVersionTag - The latest release tag to compare against HEAD.
* @returns {Promise<Array>} A promise that resolves to an array of processed
* commit objects, each containing the commit hash, GitHub username, and message.
* @throws {Error} If git command execution fails.
*/
async function getCommitsBetweenHeadAndMain() {
async function getCommitsBetweenLatestReleaseAndMain(latestVersionTag) {
try {
const baseBranch = process.env.GITHUB_BASE_REF || 'main';
const args = ['log', `origin/${baseBranch}..HEAD`, '--pretty=format:%H|%aE|%B\x1E'];
const args = ['log', `${latestVersionTag}..HEAD`, '--pretty=format:%H|%aE|%B\x1E'];

console.debug('Executing git command:', 'git', args.join(' '));

const stdout = execFileSync('/usr/bin/git', args, {
encoding: 'utf-8',
Expand Down Expand Up @@ -270,7 +274,7 @@ async function generateChangelog(version) {

validateEnvironment();

const commits = await getCommitsBetweenHeadAndMain();
const commits = await getCommitsBetweenLatestReleaseAndMain(latestVersionTag);
console.log('Commits:');
console.debug(commits);

Expand Down