Skip to content
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

refactor: use main in release-notes #29410

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 16 additions & 6 deletions script/release/notes/index.js
Expand Up @@ -8,6 +8,11 @@ const semver = require('semver');
const { ELECTRON_DIR } = require('../../lib/utils');
const notesGenerator = require('./notes.js');

const { Octokit } = require('@octokit/rest');
const octokit = new Octokit({
auth: process.env.ELECTRON_GITHUB_TOKEN
});

const semverify = version => version.replace(/^origin\//, '').replace(/[xy]/g, '0').replace(/-/g, '.');

const runGit = async (args) => {
Expand Down Expand Up @@ -37,13 +42,17 @@ const getTagsOf = async (point) => {
};

const getTagsOnBranch = async (point) => {
const masterTags = await getTagsOf('master');
if (point === 'master') {
return masterTags;
const { data: { default_branch: defaultBranch } } = await octokit.repos.get({
owner: 'electron',
repo: 'electron'
});
const mainTags = await getTagsOf(defaultBranch);
if (point === defaultBranch) {
return mainTags;
}

const masterTagsSet = new Set(masterTags);
return (await getTagsOf(point)).filter(tag => !masterTagsSet.has(tag));
const mainTagsSet = new Set(mainTags);
return (await getTagsOf(point)).filter(tag => !mainTagsSet.has(tag));
};

const getBranchOf = async (point) => {
Expand All @@ -66,7 +75,8 @@ const getAllBranches = async () => {
return branches.split('\n')
.map(branch => branch.trim())
.filter(branch => !!branch)
.filter(branch => branch !== 'origin/HEAD -> origin/master')
// TODO(main-migration): Simplify once branch rename is complete.
.filter(branch => branch !== 'origin/HEAD -> origin/master' && branch !== 'origin/HEAD -> origin/main')
.sort();
} catch (err) {
console.error('Failed to fetch all branches');
Expand Down