@evanpurkhiser/tooling-personal 1.17.0 → 1.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cmd/pr.js +19 -4
- package/dist/editor.js +8 -5
- package/dist/utils.js +1 -2
- package/package.json +1 -1
package/dist/cmd/pr.js
CHANGED
|
@@ -84,9 +84,17 @@ async function pr() {
|
|
|
84
84
|
const willOpenPr = prs.some(pr => pr.headRefName === branchName);
|
|
85
85
|
// 03. Rebase and push the selected commits
|
|
86
86
|
const doRebase = async () => {
|
|
87
|
-
|
|
87
|
+
const rebase = simple_git_1.default()
|
|
88
88
|
.env({ ...process.env, GIT_SEQUENCE_EDITOR: `echo "${rebaseContents}" >` })
|
|
89
89
|
.rebase(['--interactive', '--autostash', 'origin/master']);
|
|
90
|
+
try {
|
|
91
|
+
await rebase;
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
// Abort a failed rebase
|
|
95
|
+
await simple_git_1.default().rebase(['--abort']);
|
|
96
|
+
throw new Error(`Failed to rebase\n${error}`);
|
|
97
|
+
}
|
|
90
98
|
};
|
|
91
99
|
const doPush = async () => {
|
|
92
100
|
const newCommits = await getCommits();
|
|
@@ -107,12 +115,19 @@ async function pr() {
|
|
|
107
115
|
// Cork stdout to avoid listr output polluting vim. We'll uncork after we
|
|
108
116
|
// close vim
|
|
109
117
|
process.stdout.cork();
|
|
110
|
-
const rebaseAndPush = rebaseAndPushTask.run();
|
|
111
|
-
const { title, body } = await editor_1.editPullRequest(targetCommit);
|
|
112
118
|
// 05. Open an editor to write the pull request
|
|
119
|
+
const { editor, editorResult } = await editor_1.editPullRequest(targetCommit);
|
|
120
|
+
const rebaseAndPush = rebaseAndPushTask.run();
|
|
121
|
+
rebaseAndPush.catch(() => editor.kill());
|
|
122
|
+
const { title, body } = await editorResult;
|
|
113
123
|
// XXX: We cork stdout here to avoid listr from corrupting vims output
|
|
114
124
|
process.stdout.uncork();
|
|
115
|
-
|
|
125
|
+
try {
|
|
126
|
+
await rebaseAndPush;
|
|
127
|
+
}
|
|
128
|
+
catch {
|
|
129
|
+
process.exit(1);
|
|
130
|
+
}
|
|
116
131
|
if (title.length === 0) {
|
|
117
132
|
console.log(chalk_1.default.red `Missing PR title, aborting`);
|
|
118
133
|
process.exit(1);
|
package/dist/editor.js
CHANGED
|
@@ -18,10 +18,13 @@ async function editPullRequest(commit) {
|
|
|
18
18
|
shell: true,
|
|
19
19
|
stdio: 'inherit',
|
|
20
20
|
});
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
async function getResult() {
|
|
22
|
+
await new Promise(resolve => editor.on('close', resolve));
|
|
23
|
+
const prContents = await promises_1.default.readFile(pullEditFile).then(b => b.toString());
|
|
24
|
+
const [title, ...bodyParts] = prContents.split('\n');
|
|
25
|
+
const body = bodyParts.join('\n').trim();
|
|
26
|
+
return { title, body };
|
|
27
|
+
}
|
|
28
|
+
return { editor, editorResult: getResult() };
|
|
26
29
|
}
|
|
27
30
|
exports.editPullRequest = editPullRequest;
|
package/dist/utils.js
CHANGED
|
@@ -9,7 +9,6 @@ const js_yaml_1 = __importDefault(require("js-yaml"));
|
|
|
9
9
|
const simple_git_1 = __importDefault(require("simple-git"));
|
|
10
10
|
const fs_1 = require("fs");
|
|
11
11
|
const path_1 = __importDefault(require("path"));
|
|
12
|
-
const BRANCH_PREFIX = 'evanpurkhiser/';
|
|
13
12
|
/**
|
|
14
13
|
* Get's the current repo information
|
|
15
14
|
*/
|
|
@@ -58,6 +57,6 @@ function branchFromMessage(prefix, commitMessage) {
|
|
|
58
57
|
.replaceAll(/[^0-9a-zA-Z]/g, '-')
|
|
59
58
|
.replaceAll(/-+/g, '-')
|
|
60
59
|
.slice(0, 255);
|
|
61
|
-
return
|
|
60
|
+
return `${prefix}/${branch}`;
|
|
62
61
|
}
|
|
63
62
|
exports.branchFromMessage = branchFromMessage;
|
package/package.json
CHANGED