-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
418 additions
and
230 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { chalk, question, $ } from 'zx' | ||
|
||
import { consoleBoxen } from './console_helpers.js' | ||
import { getUserLogin } from './github.js' | ||
import { resolveRes } from './prompts.js' | ||
import type { Commit, Range } from './types.js' | ||
|
||
export async function cherryPickCommits(commits: Commit[], { | ||
range, | ||
afterCherryPick, | ||
}: { | ||
range: Range | ||
afterCherryPick?: (commit: Commit) => Promise<void> | ||
}) { | ||
const login = await getUserLogin() | ||
|
||
for (let i = 0; i < commits.length; i++) { | ||
const commit = commits[i] | ||
consoleBoxen(`🧮 Triaging ${i + 1} of ${commits.length}`, commit.line) | ||
|
||
while (true) { | ||
const res = resolveRes(await question('Ok to cherry pick? [Y/n/o(pen)] > ')) | ||
|
||
if (res === 'open') { | ||
if (commit.url) { | ||
await $`open ${commit.url}` | ||
} else { | ||
console.log("There's no PR associated with this commit") | ||
} | ||
continue | ||
} else if (res === 'no') { | ||
let res = await question('Add a note explaining why not > ') | ||
res = `(${login}) ${res}` | ||
await $`git notes add -m ${res} ${commit.hash}` | ||
await $`git notes show ${commit.hash}` | ||
console.log(`You can edit the note with \`git notes edit ${commit.hash}\``) | ||
break | ||
} | ||
|
||
try { | ||
await $`git switch ${range.to}` | ||
await $`git cherry-pick ${commit.hash}` | ||
console.log() | ||
console.log(chalk.green('🌸 Successfully cherry picked')) | ||
await afterCherryPick?.(commit) | ||
break | ||
} catch (error) { | ||
console.log() | ||
console.log(chalk.yellow("✋ Couldn't cleanly cherry pick. Resolve the conflicts and run `git cherry-pick --continue`")) | ||
await question('Press anything to continue > ') | ||
await afterCherryPick?.(commit) | ||
break | ||
} | ||
} | ||
|
||
console.log() | ||
} | ||
|
||
consoleBoxen('🏁 Finish!', `All ${commits.length} commits have been triaged`) | ||
} | ||
|
||
export function reportCommitsEligibleForCherryPick(commits: Commit[]) { | ||
consoleBoxen(`🧮 ${commits.length} commits to triage`, commits.map(commit => commit.line).join('\n')) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
0
triage/lib/types.ts → lib/types.ts
100755 → 100644
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.