@aictiq/cli 0.3.0 → 0.4.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.js +26 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1603,12 +1603,30 @@ async function provisionLocal(run, checkout, options, env) {
|
|
|
1603
1603
|
return false;
|
|
1604
1604
|
}
|
|
1605
1605
|
);
|
|
1606
|
+
if (run.workOnDefaultBranch && !hasOrigin) {
|
|
1607
|
+
throw new RunFailure(
|
|
1608
|
+
"no-remote",
|
|
1609
|
+
`${repo}, ${origin} ${run.projectKey}, has no origin remote to push ${run.branchName} to. Direct delivery needs one; add it with \`git remote add origin <url>\` or use branch-and-pull-request delivery.`
|
|
1610
|
+
);
|
|
1611
|
+
}
|
|
1606
1612
|
let base = run.defaultBranch;
|
|
1607
1613
|
if (hasOrigin) {
|
|
1608
1614
|
options.event(`Fetching origin in ${repo}`);
|
|
1609
1615
|
await call(["fetch", "origin"]);
|
|
1610
1616
|
base = `origin/${run.defaultBranch}`;
|
|
1611
1617
|
}
|
|
1618
|
+
if (run.workOnDefaultBranch) {
|
|
1619
|
+
await call(["clone", "--no-hardlinks", "--", repo, checkout]);
|
|
1620
|
+
const isolated = (args) => gitStep(args, { cwd: checkout, env, signal: options.signal });
|
|
1621
|
+
const remote = (await git(["remote", "get-url", "origin"], { cwd: repo, env })).trim();
|
|
1622
|
+
const remoteUrl = isAbsolute(remote) || /^[A-Za-z][A-Za-z0-9+.-]*:/.test(remote) || /^[^/]+:/.test(remote) ? remote : resolve(repo, remote);
|
|
1623
|
+
await isolated(["remote", "set-url", "origin", remoteUrl]);
|
|
1624
|
+
await isolated(["fetch", "origin"]);
|
|
1625
|
+
await isolated(["checkout", "-B", run.branchName, `origin/${run.branchName}`]);
|
|
1626
|
+
await isolated(["branch", "--set-upstream-to", `origin/${run.branchName}`, run.branchName]);
|
|
1627
|
+
options.event(`Created isolated clone ${checkout} on default branch ${run.branchName}`);
|
|
1628
|
+
return null;
|
|
1629
|
+
}
|
|
1612
1630
|
const branchExists = await git(
|
|
1613
1631
|
["rev-parse", "--verify", "--quiet", `refs/heads/${run.branchName}`],
|
|
1614
1632
|
{
|
|
@@ -1673,8 +1691,10 @@ async function provisionGithub(run, runDir, checkout, options, env) {
|
|
|
1673
1691
|
);
|
|
1674
1692
|
options.event(`Cloned ${full} (depth 50)`);
|
|
1675
1693
|
const call = (args) => gitStep(args, { cwd: checkout, env, signal: options.signal }, token);
|
|
1676
|
-
|
|
1677
|
-
|
|
1694
|
+
if (!run.workOnDefaultBranch) {
|
|
1695
|
+
await call(["checkout", "-b", run.branchName]);
|
|
1696
|
+
options.event(`Created branch ${run.branchName} from ${run.defaultBranch}`);
|
|
1697
|
+
}
|
|
1678
1698
|
await call(["config", "--local", "--replace-all", "credential.helper", ""]);
|
|
1679
1699
|
await call(["config", "--local", "--add", "credential.helper", CREDENTIAL_HELPER]);
|
|
1680
1700
|
return { [TOKEN_ENV]: token };
|
|
@@ -2202,7 +2222,9 @@ async function executeRun(run, options) {
|
|
|
2202
2222
|
...invocation.stdin === void 0 ? {} : { stdin: invocation.stdin },
|
|
2203
2223
|
onLine: (stream, raw) => {
|
|
2204
2224
|
const line = stripVTControlCharacters(raw);
|
|
2205
|
-
|
|
2225
|
+
if (!run.workOnDefaultBranch) {
|
|
2226
|
+
for (const match of line.matchAll(PullRequestUrl)) pullRequestUrl = match[0];
|
|
2227
|
+
}
|
|
2206
2228
|
if (stream === "stderr") {
|
|
2207
2229
|
log.push("stderr", line);
|
|
2208
2230
|
remember(line);
|
|
@@ -2226,7 +2248,7 @@ async function executeRun(run, options) {
|
|
|
2226
2248
|
const usage = { costUsd, inputTokens, outputTokens, exitCode };
|
|
2227
2249
|
if (stopReason) return stopped(exitCode, lastLines, usage);
|
|
2228
2250
|
const verdict = adapter.outcome(exitCode, lastLines, lastResult);
|
|
2229
|
-
if (verdict.outcome === "succeeded" && !pullRequestUrl) {
|
|
2251
|
+
if (verdict.outcome === "succeeded" && !run.workOnDefaultBranch && !pullRequestUrl) {
|
|
2230
2252
|
pullRequestUrl = await (options.findPullRequest ?? findPullRequest)(
|
|
2231
2253
|
workspace.checkout,
|
|
2232
2254
|
run.branchName,
|