Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Jan 23, 2025. It is now read-only.

feat!: rename regex match as --title option #388

Merged
merged 7 commits into from
Apr 2, 2020
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
29 changes: 16 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ Now you are good to go!
### repo approve

```sh
$ repo approve [regex]
$ repo approve [--title title]
```

Iterates over all open pull requests matching `regex` (all PRs if
no regex is given) in all configured repositories.
Iterates over all open pull requests matching `title` (this can be a regex,
and all PRs will be processed if no regex for title is given) in all configured repositories.
For each pull request, asks (in console) if it should be approved
and merged. Useful for managing GreenKeeper's PRs:

Expand All @@ -78,36 +78,39 @@ or all PRs with the word `test` in the title:
### repo list

```sh
$ repo list [regex]
$ repo list [--title title]
```

Iterates over all open pull requests matching `regex` (all PRs if
no regex is given) in all configured repositories, and prints them.
Iterates over all open pull requests matching `title` (this can be a regex,
and all PRs will be processed if no regex for title is given)
in all configured repositories, and prints them.

`$ repo list 🚀`
`$ repo list --title 🚀`

or all PRs with the word `test` in the title:

`$ repo list test`
`$ repo list --title test`

### repo reject

```sh
$ repo reject [regex]
$ repo reject [--title title]
```

Iterates over all open pull requests matching `regex`, and closes
Iterates over all open pull requests matching `title` (this can be a regex,
and all PRs will be processed if no regex for title is given) and closes
them. For example, close all PRs with the word `test` in the title:

`$ repo reject test`
`$ repo reject --title test`

### repo rename

```sh
$ repo rename 'title to match' 'new title'
$ repo rename --title title 'new title'
```

Iterates over all open pull requests matching `regex`, and renames
Iterates over all open pull requests matching `title` (this can be a regex,
and all PRs will be processed if no regex for title is given), and renames
them.

### repo apply
Expand Down
18 changes: 11 additions & 7 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ export const meowFlags: {
type: 'boolean',
alias: 'q',
},
title: {
type: 'string',
alias: 't',
},
auto: {type: 'boolean'},
concurrency: {type: 'string'},
author: {type: 'string'},
Expand All @@ -68,13 +72,13 @@ const cli = meow(
$ repo <command>

Examples
$ repo list [--branch branch] [--author author] [regex]
$ repo approve [--branch branch] [--author author] [regex]
$ repo update [--branch branch] [--author author] [regex]
$ repo merge [--branch branch] [--author author] [regex]
$ repo reject [--branch branch] [--author author] [regex]
$ repo rename [--branch branch] [--author author] regex 'new PR title'
$ repo tag [--branch branch] [--author author] regex label1 label2 ...
$ repo list [--branch branch] [--author author] [--title title]
$ repo approve [--branch branch] [--author author] [--title title]
$ repo update [--branch branch] [--author author] [--title title]
$ repo merge [--branch branch] [--author author] [--title title]
$ repo reject [--branch branch] [--author author] [--title title]
$ repo rename [--branch branch] [--author author] [--title title] 'new PR title'
$ repo tag [--branch branch] [--author author] [--title title] label1 label2 ...
$ repo apply --branch branch --message message --comment comment [--reviewers username[,username...]] [--silent] command
$ repo check
$ repo sync
Expand Down
10 changes: 6 additions & 4 deletions src/lib/asyncPrIterator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,11 @@ export async function process(
cli: meow.Result<typeof meowFlags>,
options: PRIteratorOptions
) {
if (!cli.input[1] && !cli.flags.branch) {
console.log(`Usage: repo ${options.commandName} [--branch branch] [regex]`);
console.log(`Either branch name or regex must present.`);
if (!cli.flags.title && !cli.flags.branch) {
console.log(
`Usage: repo ${options.commandName} [--branch branch] [--title title]`
);
console.log(`Either branch name or title regex must present.`);
console.log(options.commandDesc);
return;
}
Expand All @@ -54,7 +56,7 @@ export async function process(
: 15;
const config = await getConfig();
const github = new GitHub(config);
const regex = new RegExp(cli.input[1] || '.*');
const regex = new RegExp((cli.flags.title as string) || '.*');
const repos = await github.getRepositories();
const successful: PullRequest[] = [];
const failed: PullRequest[] = [];
Expand Down
6 changes: 5 additions & 1 deletion src/rename-prs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ async function processMethod(repository: GitHubRepository, pr: PullRequest) {
}

export async function rename(cli: meow.Result<typeof meowFlags>) {
title = cli.input[2];
if (cli.input.length < 2) {
console.log(`New title name must present.`);
return;
}
title = cli.input[1];
console.log(`title: ${title}`);
return process(cli, {
commandName: 'rename',
Expand Down
2 changes: 1 addition & 1 deletion src/tag-prs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ async function processMethod(
cli: meow.Result<typeof meowFlags>
) {
try {
await repository.tagPullRequest(pr, cli.input.slice(2));
await repository.tagPullRequest(pr, cli.input.slice(1));
} catch (err) {
console.warn(` error trying to tag PR ${pr.html_url}:`, err.toString());
return false;
Expand Down