Skip to content
Merged
Show file tree
Hide file tree
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
26 changes: 13 additions & 13 deletions scripts/performRelease/fetchCommitsSinceTag.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import type { GithubClient } from '../utils/getGitHubClient';
import getRepoContext from '../utils/getRepoContext';
import runGithubRequestWithRetries from './runGithubRequestWithRetries';
import childProcess from 'child_process';
import util from 'util';

export default async function fetchCommitsSinceTag(client: GithubClient, tagSha: string) {
const execFile = util.promisify(childProcess.execFile);

export default async function fetchCommitsSinceTag(tagSha: string) {
console.log('Fetching commits since sha', tagSha);

const { owner, repo } = getRepoContext();
return runGithubRequestWithRetries(`Fetch commits since ${tagSha}`, () =>
client.request('GET /repos/{owner}/{repo}/compare/{base}...{head}', {
owner,
repo,
base: tagSha,
head: 'HEAD',
}),
);
const { stdout } = await execFile('git', ['rev-list', '--reverse', `${tagSha}..HEAD`]);
const commits = stdout
.trim()
.split('\n')
.filter(Boolean)
.map((sha) => ({ sha }));

return { data: { commits } };
}
9 changes: 4 additions & 5 deletions scripts/performRelease/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,13 @@ async function performRelease() {
console.log('Most recent non-alpha tag found is', mostRecentNonAlphaTag.name);

// get commits since most recent alpha / non-alpha tag
const commitsSinceLastTagRequest = await fetchCommitsSinceTag(client, mostRecentTag.commit.sha);
const commitsSinceNonAlphaTagRequest = await fetchCommitsSinceTag(
client,
const commitsSinceLastTagResponse = await fetchCommitsSinceTag(mostRecentTag.commit.sha);
const commitsSinceNonAlphaTagResponse = await fetchCommitsSinceTag(
mostRecentNonAlphaTag.commit.sha,
);

const commitsSinceNonAlphaTag = commitsSinceNonAlphaTagRequest.data.commits;
const commitsSinceLastTag = commitsSinceLastTagRequest.data.commits;
const commitsSinceNonAlphaTag = commitsSinceNonAlphaTagResponse.data.commits;
const commitsSinceLastTag = commitsSinceLastTagResponse.data.commits;

if (commitsSinceLastTag.length === 0) {
console.log(`No commits found since last release tag. Exiting.`);
Expand Down
Loading