Skip to content

[core] Allow repo to be accepted as an argument for releaseTag #45801

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
Apr 2, 2025
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
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@
"eslint-plugin-react-hooks": "^5.2.0",
"fast-glob": "^3.3.3",
"fs-extra": "^11.3.0",
"git-url-parse": "^16.0.1",
"globby": "^14.1.0",
"jsonc-parser": "^3.3.1",
"karma": "^6.4.4",
Expand Down
32 changes: 32 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 20 additions & 15 deletions scripts/releaseTag.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import fse from 'fs-extra';
import path from 'path';
import { promisify } from 'util';
import yargs from 'yargs';
import gitUrlParse from 'git-url-parse';

import { getWorkspaceRoot } from './utils.mjs';

/**
Expand All @@ -23,8 +25,10 @@ function execDry(command, options) {
* Find the remote pointing to mui/material-ui.
*
* Conventionally this should be named `upstream` but some collaborators might've used a different naming scheme.
*
* @param {string} repo
*/
async function findMuiOrgRemote() {
async function findMuiOrgRemote(repo) {
const { stdout } = await execActual(['git', 'remote', '-v'].join(' '));
const remoteLines = stdout.trim().split(/\r?\n/);

Expand All @@ -34,18 +38,13 @@ async function findMuiOrgRemote() {
return { name, url, method };
})
.find((remote) => {
// test: https://regex101.com/r/fBVJUX/1
// matching:
// - https://github.com/mui/material-ui
// - [email protected]:mui/material-ui.git
// but not:
// - [email protected]:mui/material-ui-docs.git
return /mui\/material-ui(\.git)?$/.test(remote.url) && remote.method === '(push)';
const parsed = gitUrlParse(remote.url);
return parsed.owner === 'mui' && parsed.name === repo;
});
}

async function main(argv) {
const { dryRun } = argv;
const { dryRun, repo } = argv;

const exec = dryRun ? execDry : execActual;

Expand All @@ -59,7 +58,7 @@ async function main(argv) {
// eslint-disable-next-line no-console -- verbose logging
console.log(`Created tag '${tag}'. To remove enter 'git tag -d ${tag}'`);

const muiOrgRemote = await findMuiOrgRemote();
const muiOrgRemote = await findMuiOrgRemote(repo);
if (muiOrgRemote === undefined) {
throw new TypeError(
'Unable to find the upstream remote. It should be a remote pointing to "mui/material-ui". ' +
Expand All @@ -81,11 +80,17 @@ yargs(process.argv.slice(2))
command: '$0',
description: 'Tags the current release and pushes these changes to mui/material-ui.',
builder: (command) => {
return command.option('dryRun', {
default: false,
describe: 'If true, the script will not have any permanent side-effects.',
type: 'boolean',
});
return command
.option('dryRun', {
default: false,
describe: 'If true, the script will not have any permanent side-effects.',
type: 'boolean',
})
.option('repo', {
default: 'material-ui',
describe: 'Repository to tag',
type: 'string',
});
},
handler: main,
})
Expand Down