@dunnewold-labs/mr-manager 0.4.23 → 0.4.24
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 +12 -42
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -185,7 +185,7 @@ import { fileURLToPath } from "url";
|
|
|
185
185
|
// cli/package.json
|
|
186
186
|
var package_default = {
|
|
187
187
|
name: "@dunnewold-labs/mr-manager",
|
|
188
|
-
version: "0.4.
|
|
188
|
+
version: "0.4.24",
|
|
189
189
|
description: "Mr. Manager - Task and project management CLI",
|
|
190
190
|
bin: {
|
|
191
191
|
mr: "./dist/index.mjs"
|
|
@@ -1744,7 +1744,7 @@ async function extractPrUrlFromUpdates(taskId) {
|
|
|
1744
1744
|
return null;
|
|
1745
1745
|
}
|
|
1746
1746
|
function checkPrStatus(prUrl, repoDir, vcs = "github") {
|
|
1747
|
-
const cmd = vcs === "gitlab" ? `glab mr view "${prUrl}" --output json 2>/dev/null` : `gh pr view "${prUrl}" --json merged,mergeable
|
|
1747
|
+
const cmd = vcs === "gitlab" ? `glab mr view "${prUrl}" --output json 2>/dev/null` : `gh pr view "${prUrl}" --json merged,mergeable 2>/dev/null`;
|
|
1748
1748
|
return new Promise((resolve9) => {
|
|
1749
1749
|
exec(cmd, { cwd: repoDir }, (err, stdout) => {
|
|
1750
1750
|
if (err || !stdout.trim()) {
|
|
@@ -1754,18 +1754,15 @@ function checkPrStatus(prUrl, repoDir, vcs = "github") {
|
|
|
1754
1754
|
try {
|
|
1755
1755
|
const data = JSON.parse(stdout.trim());
|
|
1756
1756
|
if (vcs === "gitlab") {
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1757
|
+
resolve9({
|
|
1758
|
+
merged: data.state === "merged",
|
|
1759
|
+
hasConflicts: data.has_conflicts === true
|
|
1760
|
+
});
|
|
1761
1761
|
} else {
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
const noChangesRequested = data.reviewDecision !== "CHANGES_REQUESTED";
|
|
1767
|
-
const isMergeable = !merged && !hasConflicts && !data.isDraft && data.mergeable === "MERGEABLE" && allChecksPassed && noChangesRequested;
|
|
1768
|
-
resolve9({ merged, hasConflicts, isMergeable });
|
|
1762
|
+
resolve9({
|
|
1763
|
+
merged: data.merged === true,
|
|
1764
|
+
hasConflicts: data.mergeable === "CONFLICTING"
|
|
1765
|
+
});
|
|
1769
1766
|
}
|
|
1770
1767
|
} catch {
|
|
1771
1768
|
resolve9(null);
|
|
@@ -1773,14 +1770,6 @@ function checkPrStatus(prUrl, repoDir, vcs = "github") {
|
|
|
1773
1770
|
});
|
|
1774
1771
|
});
|
|
1775
1772
|
}
|
|
1776
|
-
function mergePrViaCli(prUrl, repoDir, vcs = "github") {
|
|
1777
|
-
const cmd = vcs === "gitlab" ? `glab mr merge "${prUrl}" --squash --remove-source-branch 2>&1` : `gh pr merge "${prUrl}" --squash --delete-branch 2>&1`;
|
|
1778
|
-
return new Promise((resolve9) => {
|
|
1779
|
-
exec(cmd, { cwd: repoDir }, (err) => {
|
|
1780
|
-
resolve9(!err);
|
|
1781
|
-
});
|
|
1782
|
-
});
|
|
1783
|
-
}
|
|
1784
1773
|
function buildPrototypeSection(protoRefs, workingDir) {
|
|
1785
1774
|
if (protoRefs.length === 0) return "";
|
|
1786
1775
|
const sections = [
|
|
@@ -4135,7 +4124,8 @@ ${divider}`);
|
|
|
4135
4124
|
const prefix = taskTag(sid);
|
|
4136
4125
|
const prLabel = task.link.includes("gitlab") ? "MR" : "PR";
|
|
4137
4126
|
const vcs = task.link.includes("gitlab") ? "gitlab" : "github";
|
|
4138
|
-
const repoDir = findDirectoryForProject(config, task.projectId, rootDir)
|
|
4127
|
+
const repoDir = findDirectoryForProject(config, task.projectId, rootDir);
|
|
4128
|
+
if (!repoDir) continue;
|
|
4139
4129
|
const status = await checkPrStatus(task.link, repoDir, vcs);
|
|
4140
4130
|
if (!status) continue;
|
|
4141
4131
|
if (status.merged) {
|
|
@@ -4152,26 +4142,6 @@ ${divider}`);
|
|
|
4152
4142
|
}
|
|
4153
4143
|
continue;
|
|
4154
4144
|
}
|
|
4155
|
-
if (task.autoMerge && status.isMergeable) {
|
|
4156
|
-
logInfo(prefix, `Auto-merging ${prLabel} for "${paint("bold", task.title)}"`);
|
|
4157
|
-
const mergeOk = await mergePrViaCli(task.link, repoDir, vcs);
|
|
4158
|
-
if (mergeOk) {
|
|
4159
|
-
logSuccess(prefix, `${prLabel} auto-merged \u2014 completing "${paint("bold", task.title)}"`);
|
|
4160
|
-
try {
|
|
4161
|
-
await api.patch(`/api/tasks/${task.id}`, {
|
|
4162
|
-
status: "completed",
|
|
4163
|
-
completedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
4164
|
-
inProgressSince: null
|
|
4165
|
-
});
|
|
4166
|
-
await postTaskUpdate(task.id, `${prLabel} auto-merged and task completed`, "system");
|
|
4167
|
-
} catch (err) {
|
|
4168
|
-
logError(prefix, `Failed to complete task after auto-merge: ${err.message}`);
|
|
4169
|
-
}
|
|
4170
|
-
} else {
|
|
4171
|
-
logWarn(prefix, `Auto-merge of ${prLabel} failed for "${paint("bold", task.title)}" \u2014 will retry next poll`);
|
|
4172
|
-
}
|
|
4173
|
-
continue;
|
|
4174
|
-
}
|
|
4175
4145
|
if (status.hasConflicts) {
|
|
4176
4146
|
logWarn(prefix, `${prLabel} has merge conflicts \u2014 re-dispatching agent for "${paint("bold", task.title)}"`);
|
|
4177
4147
|
try {
|