internaltool-mcp 1.6.2 → 1.6.3
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/index.js +45 -7
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1527,18 +1527,31 @@ If you have uncommitted tracked changes, it will tell you exactly what to do bef
|
|
|
1527
1527
|
})
|
|
1528
1528
|
}
|
|
1529
1529
|
|
|
1530
|
-
// Step 3 — create branch on GitHub, then link
|
|
1530
|
+
// Step 3 — create branch on GitHub (or confirm it already exists), then link + move
|
|
1531
1531
|
const localState = gitState?.localState || 'unknown'
|
|
1532
1532
|
try {
|
|
1533
|
+
let branchUrl = null
|
|
1534
|
+
let alreadyExisted = false
|
|
1535
|
+
|
|
1533
1536
|
const res = await api.post(`/api/projects/${projectId}/github/branches`, { branchName, fromRef })
|
|
1534
|
-
if (!res?.success)
|
|
1537
|
+
if (!res?.success) {
|
|
1538
|
+
// "Reference already exists" means the branch is already on GitHub — treat as success
|
|
1539
|
+
const msg = (res?.message || '').toLowerCase()
|
|
1540
|
+
if (msg.includes('already exists') || msg.includes('reference already exists')) {
|
|
1541
|
+
alreadyExisted = true
|
|
1542
|
+
} else {
|
|
1543
|
+
return errorText(res?.message || 'Could not create branch')
|
|
1544
|
+
}
|
|
1545
|
+
} else {
|
|
1546
|
+
branchUrl = res.data?.url || null
|
|
1547
|
+
}
|
|
1535
1548
|
|
|
1536
|
-
// Link
|
|
1549
|
+
// Link branch to task regardless of whether it was just created or already existed
|
|
1537
1550
|
try {
|
|
1538
1551
|
await api.patch(`/api/tasks/${taskId}/github/branch`, { headBranch: branchName })
|
|
1539
|
-
} catch { /* non-fatal
|
|
1552
|
+
} catch { /* non-fatal */ }
|
|
1540
1553
|
|
|
1541
|
-
// Move task to in_progress now that
|
|
1554
|
+
// Move task to in_progress now that branch is linked
|
|
1542
1555
|
let movedToInProgress = false
|
|
1543
1556
|
try {
|
|
1544
1557
|
const freshTask = await api.get(`/api/tasks/${taskId}`)
|
|
@@ -1562,17 +1575,42 @@ If you have uncommitted tracked changes, it will tell you exactly what to do bef
|
|
|
1562
1575
|
unknown: null,
|
|
1563
1576
|
}[localState] || null
|
|
1564
1577
|
|
|
1578
|
+
const statusMsg = alreadyExisted
|
|
1579
|
+
? `Branch "${branchName}" already existed on GitHub — linked to task.${movedToInProgress ? ' Task moved to In progress.' : ''}`
|
|
1580
|
+
: `Branch "${branchName}" created on GitHub.${movedToInProgress ? ' Task moved to In progress.' : ''}`
|
|
1581
|
+
|
|
1565
1582
|
return text({
|
|
1566
1583
|
branchName,
|
|
1567
|
-
url:
|
|
1584
|
+
url: branchUrl,
|
|
1585
|
+
alreadyExisted,
|
|
1568
1586
|
localState,
|
|
1569
1587
|
movedToInProgress,
|
|
1570
|
-
message:
|
|
1588
|
+
message: statusMsg,
|
|
1571
1589
|
gitSteps: checkoutSteps,
|
|
1572
1590
|
localStateNote,
|
|
1573
1591
|
nextStep: 'Run the git steps above to switch locally, then start coding. When commits are pushed, use raise_pr.',
|
|
1574
1592
|
})
|
|
1575
1593
|
} catch (e) {
|
|
1594
|
+
// Last-resort catch: if error message indicates branch already exists, still link + move
|
|
1595
|
+
const msg = (e.message || '').toLowerCase()
|
|
1596
|
+
if (msg.includes('already exists') || msg.includes('reference already exists')) {
|
|
1597
|
+
try { await api.patch(`/api/tasks/${taskId}/github/branch`, { headBranch: branchName }) } catch { /* ok */ }
|
|
1598
|
+
try {
|
|
1599
|
+
const freshTask = await api.get(`/api/tasks/${taskId}`)
|
|
1600
|
+
const col = freshTask?.data?.task?.column
|
|
1601
|
+
if (col && ['todo', 'backlog'].includes(col)) {
|
|
1602
|
+
await api.post(`/api/tasks/${taskId}/move`, { column: 'in_progress', toIndex: 0 })
|
|
1603
|
+
}
|
|
1604
|
+
} catch { /* ok */ }
|
|
1605
|
+
return text({
|
|
1606
|
+
branchName,
|
|
1607
|
+
alreadyExisted: true,
|
|
1608
|
+
movedToInProgress: true,
|
|
1609
|
+
message: `Branch "${branchName}" already existed on GitHub — linked to task and moved to In progress.`,
|
|
1610
|
+
gitSteps: ['git fetch origin', `git checkout ${branchName}`],
|
|
1611
|
+
nextStep: 'Run the git steps above to switch locally, then start coding.',
|
|
1612
|
+
})
|
|
1613
|
+
}
|
|
1576
1614
|
return errorText(e.message)
|
|
1577
1615
|
}
|
|
1578
1616
|
}
|
package/package.json
CHANGED