qkpr 1.0.3 → 1.0.5-beta.1
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/index.mjs +75 -22
- package/dist/pr-C2AR97YR.mjs +3 -0
- package/package.json +1 -1
- package/dist/pr-3u9dEVEc.mjs +0 -3
package/dist/index.mjs
CHANGED
|
@@ -235,6 +235,29 @@ function createMergeBranch(targetBranch, mergeBranchName) {
|
|
|
235
235
|
}
|
|
236
236
|
}
|
|
237
237
|
/**
|
|
238
|
+
* 合并原始分支到合并分支
|
|
239
|
+
*/
|
|
240
|
+
function mergeSourceToMergeBranch(sourceBranch) {
|
|
241
|
+
try {
|
|
242
|
+
console.log(cyan(`\n🔄 Merging source branch '${sourceBranch}' into current merge branch...`));
|
|
243
|
+
execSync(`git merge ${sourceBranch}`, { stdio: "inherit" });
|
|
244
|
+
console.log(green(`✅ Successfully merged '${sourceBranch}' into merge branch`));
|
|
245
|
+
return true;
|
|
246
|
+
} catch (error) {
|
|
247
|
+
if (error.status === 1 && error.stdout?.includes("CONFLICT")) {
|
|
248
|
+
console.log(yellow(`⚠️ Merge conflicts detected!`));
|
|
249
|
+
console.log(dim(` Please resolve conflicts manually and then run:`));
|
|
250
|
+
console.log(dim(` git add <resolved-files>`));
|
|
251
|
+
console.log(dim(` git commit`));
|
|
252
|
+
return false;
|
|
253
|
+
} else {
|
|
254
|
+
console.log(red("❌ Failed to merge source branch"));
|
|
255
|
+
console.log(dim(`Error: ${error.message || "Unknown error"}`));
|
|
256
|
+
return false;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
238
261
|
* 复制文本到剪贴板
|
|
239
262
|
*/
|
|
240
263
|
function copyToClipboard(text) {
|
|
@@ -1237,7 +1260,7 @@ inquirer.registerPrompt("search-checkbox", searchCheckbox);
|
|
|
1237
1260
|
* 通用的分支选择函数,支持单选和多选
|
|
1238
1261
|
*/
|
|
1239
1262
|
async function promptBranchSelection(branches, options) {
|
|
1240
|
-
const { title, message, mode, filterPinned = false } = options;
|
|
1263
|
+
const { title, message, mode, filterPinned = false, defaultSelected = [] } = options;
|
|
1241
1264
|
console.log(cyan(`\n${title}`));
|
|
1242
1265
|
console.log(dim(""));
|
|
1243
1266
|
if (branches.length === 0) {
|
|
@@ -1262,7 +1285,8 @@ async function promptBranchSelection(branches, options) {
|
|
|
1262
1285
|
choices.push({
|
|
1263
1286
|
name: `📌 ${branch.name.padEnd(45)} ${dim(`(${branch.lastCommitTimeFormatted})`)}`,
|
|
1264
1287
|
value: branch.name,
|
|
1265
|
-
short: branch.name
|
|
1288
|
+
short: branch.name,
|
|
1289
|
+
checked: defaultSelected.includes(branch.name)
|
|
1266
1290
|
});
|
|
1267
1291
|
});
|
|
1268
1292
|
choices.push(new inquirer.Separator(" "));
|
|
@@ -1273,7 +1297,8 @@ async function promptBranchSelection(branches, options) {
|
|
|
1273
1297
|
choices.push({
|
|
1274
1298
|
name: ` ${branch.name.padEnd(45)} ${dim(`(${branch.lastCommitTimeFormatted})`)}`,
|
|
1275
1299
|
value: branch.name,
|
|
1276
|
-
short: branch.name
|
|
1300
|
+
short: branch.name,
|
|
1301
|
+
checked: defaultSelected.includes(branch.name)
|
|
1277
1302
|
});
|
|
1278
1303
|
});
|
|
1279
1304
|
choices.push(new inquirer.Separator(" "));
|
|
@@ -1300,7 +1325,7 @@ async function promptBranchSelection(branches, options) {
|
|
|
1300
1325
|
type: "search-checkbox",
|
|
1301
1326
|
name: "selectedBranches",
|
|
1302
1327
|
message,
|
|
1303
|
-
choices
|
|
1328
|
+
choices: choices.filter((c) => c.value)
|
|
1304
1329
|
}]);
|
|
1305
1330
|
return selectedBranches || [];
|
|
1306
1331
|
}
|
|
@@ -1331,11 +1356,25 @@ async function promptCreateMergeBranch(mergeBranchName) {
|
|
|
1331
1356
|
type: "confirm",
|
|
1332
1357
|
name: "createMergeBranch",
|
|
1333
1358
|
message: "Do you want to create a merge branch for conflict resolution?",
|
|
1334
|
-
default:
|
|
1359
|
+
default: true
|
|
1335
1360
|
}]);
|
|
1336
1361
|
return createMergeBranch$1;
|
|
1337
1362
|
}
|
|
1338
1363
|
/**
|
|
1364
|
+
* 确认是否自动合并原始分支到合并分支
|
|
1365
|
+
*/
|
|
1366
|
+
async function promptAutoMergeSource(sourceBranch, targetBranch) {
|
|
1367
|
+
console.log(yellow(`\n🔄 Merge branch created successfully!`));
|
|
1368
|
+
console.log(dim(` This branch is based on '${targetBranch}' and can be used to test the merge.`));
|
|
1369
|
+
const { shouldAutoMerge } = await inquirer.prompt([{
|
|
1370
|
+
type: "confirm",
|
|
1371
|
+
name: "shouldAutoMerge",
|
|
1372
|
+
message: `Auto-merge '${sourceBranch}' to detect potential conflicts now?`,
|
|
1373
|
+
default: false
|
|
1374
|
+
}]);
|
|
1375
|
+
return shouldAutoMerge;
|
|
1376
|
+
}
|
|
1377
|
+
/**
|
|
1339
1378
|
* 显示 PR 信息
|
|
1340
1379
|
*/
|
|
1341
1380
|
function displayPRInfo(prMessage, prUrl) {
|
|
@@ -1361,32 +1400,31 @@ async function handlePinCommand(branchName) {
|
|
|
1361
1400
|
addPinnedBranch(branchName);
|
|
1362
1401
|
console.log(green(`✅ Branch '${branchName}' has been pinned`));
|
|
1363
1402
|
} else {
|
|
1364
|
-
const { getAllBranches: getAllBranches$1 } = await import("./pr-
|
|
1403
|
+
const { getAllBranches: getAllBranches$1 } = await import("./pr-C2AR97YR.mjs");
|
|
1365
1404
|
const branches = getAllBranches$1();
|
|
1366
1405
|
if (branches.length === 0) {
|
|
1367
1406
|
console.log(yellow("⚠️ No branches found"));
|
|
1368
1407
|
return;
|
|
1369
1408
|
}
|
|
1370
1409
|
const pinnedBranches = getPinnedBranches();
|
|
1371
|
-
const
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
return;
|
|
1375
|
-
}
|
|
1376
|
-
const selectedBranches = await promptBranchSelection(availableBranches, {
|
|
1377
|
-
title: "📌 Pin Branches",
|
|
1378
|
-
message: "Select branches to pin (type to search, Space to select, Enter to confirm):",
|
|
1410
|
+
const selectedBranches = await promptBranchSelection(branches, {
|
|
1411
|
+
title: "📌 Manage Pinned Branches",
|
|
1412
|
+
message: "Select branches to pin (type to search, Space to toggle, Enter to confirm):",
|
|
1379
1413
|
mode: "multiple",
|
|
1380
|
-
|
|
1414
|
+
defaultSelected: pinnedBranches
|
|
1381
1415
|
});
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
}
|
|
1386
|
-
selectedBranches.forEach((branch) => {
|
|
1416
|
+
const toAdd = selectedBranches.filter((b) => !pinnedBranches.includes(b));
|
|
1417
|
+
const toRemove = pinnedBranches.filter((b) => !selectedBranches.includes(b));
|
|
1418
|
+
toAdd.forEach((branch) => {
|
|
1387
1419
|
addPinnedBranch(branch);
|
|
1388
1420
|
});
|
|
1389
|
-
|
|
1421
|
+
toRemove.forEach((branch) => {
|
|
1422
|
+
removePinnedBranch(branch);
|
|
1423
|
+
});
|
|
1424
|
+
if (toAdd.length > 0 || toRemove.length > 0) {
|
|
1425
|
+
if (toAdd.length > 0) console.log(green(`✅ Pinned ${toAdd.length} branch(es)`));
|
|
1426
|
+
if (toRemove.length > 0) console.log(green(`✅ Unpinned ${toRemove.length} branch(es)`));
|
|
1427
|
+
} else console.log(dim("No changes made"));
|
|
1390
1428
|
}
|
|
1391
1429
|
const updatedPinnedBranches = getPinnedBranches();
|
|
1392
1430
|
console.log(cyan("\n📌 Current pinned branches:"));
|
|
@@ -1808,6 +1846,21 @@ async function handlePRCommand() {
|
|
|
1808
1846
|
}
|
|
1809
1847
|
if (await promptCreateMergeBranch(prInfo.mergeBranchName)) {
|
|
1810
1848
|
if (!createMergeBranch(targetBranch, prInfo.mergeBranchName)) return;
|
|
1849
|
+
if (await promptAutoMergeSource(gitInfo.currentBranch, targetBranch)) {
|
|
1850
|
+
console.log(yellow(`\n🔄 Merging '${gitInfo.currentBranch}' to detect conflicts...`));
|
|
1851
|
+
if (!mergeSourceToMergeBranch(gitInfo.currentBranch)) {
|
|
1852
|
+
console.log(yellow("\n⚠️ Merge conflicts detected! Please resolve them manually:"));
|
|
1853
|
+
console.log(dim(` 1. Resolve conflicts in your editor`));
|
|
1854
|
+
console.log(dim(` 2. Run: git add <resolved-files>`));
|
|
1855
|
+
console.log(dim(` 3. Run: git commit`));
|
|
1856
|
+
console.log(dim(` 4. Push the merge branch when ready`));
|
|
1857
|
+
}
|
|
1858
|
+
} else {
|
|
1859
|
+
console.log(green(`\n✅ Merge branch '${prInfo.mergeBranchName}' created without merging.`));
|
|
1860
|
+
console.log(dim(` You can manually merge later when ready:`));
|
|
1861
|
+
console.log(dim(` git checkout ${prInfo.mergeBranchName}`));
|
|
1862
|
+
console.log(dim(` git merge ${gitInfo.currentBranch}`));
|
|
1863
|
+
}
|
|
1811
1864
|
}
|
|
1812
1865
|
console.log(green("\n🎉 PR creation process completed!\n"));
|
|
1813
1866
|
}
|
|
@@ -1856,4 +1909,4 @@ yargs(hideBin(process.argv)).scriptName("qkpr").usage("Usage: $0 <command> [opti
|
|
|
1856
1909
|
}).version(version).alias("v", "version").help("h").alias("h", "help").epilog("For more information, visit https://github.com/KazooTTT/qkpr").argv;
|
|
1857
1910
|
|
|
1858
1911
|
//#endregion
|
|
1859
|
-
export { generatePRMessage as a, getBranchCategory as c, getCommitsBetweenBranches as d, getGitInfo as f, generateMergeBranchName as i, getBranchLastCommitTime as l, createMergeBranch as n, generatePRUrl as o,
|
|
1912
|
+
export { generatePRMessage as a, getBranchCategory as c, getCommitsBetweenBranches as d, getGitInfo as f, generateMergeBranchName as i, getBranchLastCommitTime as l, parseRemoteUrl as m, createMergeBranch as n, generatePRUrl as o, mergeSourceToMergeBranch as p, createPullRequest as r, getAllBranches as s, copyToClipboard as t, getBranchesWithInfo as u };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { a as generatePRMessage, c as getBranchCategory, d as getCommitsBetweenBranches, f as getGitInfo, i as generateMergeBranchName, l as getBranchLastCommitTime, m as parseRemoteUrl, n as createMergeBranch, o as generatePRUrl, p as mergeSourceToMergeBranch, r as createPullRequest, s as getAllBranches, t as copyToClipboard, u as getBranchesWithInfo } from "./index.mjs";
|
|
2
|
+
|
|
3
|
+
export { copyToClipboard, createMergeBranch, createPullRequest, generateMergeBranchName, generatePRMessage, generatePRUrl, getAllBranches, getBranchCategory, getBranchLastCommitTime, getBranchesWithInfo, getCommitsBetweenBranches, getGitInfo, mergeSourceToMergeBranch, parseRemoteUrl };
|
package/package.json
CHANGED
package/dist/pr-3u9dEVEc.mjs
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { a as generatePRMessage, c as getBranchCategory, d as getCommitsBetweenBranches, f as getGitInfo, i as generateMergeBranchName, l as getBranchLastCommitTime, n as createMergeBranch, o as generatePRUrl, p as parseRemoteUrl, r as createPullRequest, s as getAllBranches, t as copyToClipboard, u as getBranchesWithInfo } from "./index.mjs";
|
|
2
|
-
|
|
3
|
-
export { copyToClipboard, createMergeBranch, createPullRequest, generateMergeBranchName, generatePRMessage, generatePRUrl, getAllBranches, getBranchCategory, getBranchLastCommitTime, getBranchesWithInfo, getCommitsBetweenBranches, getGitInfo, parseRemoteUrl };
|