@adhdev/daemon-standalone 0.9.62 → 0.9.63
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
CHANGED
|
@@ -33496,7 +33496,8 @@ var require_dist2 = __commonJS({
|
|
|
33496
33496
|
"git_stash_push",
|
|
33497
33497
|
"git_stash_pop",
|
|
33498
33498
|
"git_checkout_files",
|
|
33499
|
-
"git_remote_url"
|
|
33499
|
+
"git_remote_url",
|
|
33500
|
+
"git_push"
|
|
33500
33501
|
]);
|
|
33501
33502
|
var SNAPSHOT_REASONS = /* @__PURE__ */ new Set([
|
|
33502
33503
|
"session_baseline",
|
|
@@ -33542,7 +33543,8 @@ var require_dist2 = __commonJS({
|
|
|
33542
33543
|
stashPush: async ({ workspace, message, includeUntracked = false }) => gitStashPush(workspace, message, includeUntracked),
|
|
33543
33544
|
stashPop: async ({ workspace, stashRef }) => gitStashPop(workspace, stashRef),
|
|
33544
33545
|
checkoutFiles: async ({ workspace, paths }) => gitCheckoutFiles(workspace, paths),
|
|
33545
|
-
getRemoteUrl: async ({ workspace, remote = "origin" }) => gitGetRemoteUrl(workspace, remote)
|
|
33546
|
+
getRemoteUrl: async ({ workspace, remote = "origin" }) => gitGetRemoteUrl(workspace, remote),
|
|
33547
|
+
push: async ({ workspace, remote = "origin", branch, setUpstream = false }) => gitPush(workspace, remote, branch, setUpstream)
|
|
33546
33548
|
};
|
|
33547
33549
|
}
|
|
33548
33550
|
var defaultGitCommandServices = createDefaultGitCommandServices();
|
|
@@ -33710,6 +33712,20 @@ var require_dist2 = __commonJS({
|
|
|
33710
33712
|
if ("success" in remoteResult) return remoteResult;
|
|
33711
33713
|
return { success: true, remoteUrl: remoteResult.remoteUrl, remote: remoteResult.remote };
|
|
33712
33714
|
}
|
|
33715
|
+
case "git_push": {
|
|
33716
|
+
if (!services.push) return serviceNotImplemented(command);
|
|
33717
|
+
const remote = typeof args?.remote === "string" && args.remote.trim() ? args.remote.trim() : "origin";
|
|
33718
|
+
const branch = typeof args?.branch === "string" && args.branch.trim() ? args.branch.trim() : void 0;
|
|
33719
|
+
const setUpstream = Boolean(args?.setUpstream);
|
|
33720
|
+
if (!/^[a-zA-Z0-9_.\-]+$/.test(remote)) {
|
|
33721
|
+
return failure("invalid_args", "remote must contain only alphanumeric characters, dots, hyphens, and underscores");
|
|
33722
|
+
}
|
|
33723
|
+
if (branch !== void 0 && !/^[a-zA-Z0-9/_.\-]+$/.test(branch)) {
|
|
33724
|
+
return failure("invalid_args", "branch must contain only alphanumeric characters, slashes, dots, hyphens, and underscores");
|
|
33725
|
+
}
|
|
33726
|
+
const pushResult = await runService(() => services.push({ workspace, remote, branch, setUpstream }));
|
|
33727
|
+
return "success" in pushResult ? pushResult : { success: true, push: pushResult };
|
|
33728
|
+
}
|
|
33713
33729
|
default:
|
|
33714
33730
|
return failure("invalid_args", `Unknown Git command: ${command}`);
|
|
33715
33731
|
}
|
|
@@ -33812,6 +33828,49 @@ var require_dist2 = __commonJS({
|
|
|
33812
33828
|
}
|
|
33813
33829
|
return { remoteUrl, remote };
|
|
33814
33830
|
}
|
|
33831
|
+
async function gitPush(workspace, remote, branch, setUpstream) {
|
|
33832
|
+
const lastCheckedAt = Date.now();
|
|
33833
|
+
const repo = await resolveGitRepository(workspace);
|
|
33834
|
+
const repoRoot = repo.repoRoot;
|
|
33835
|
+
let resolvedBranch = branch;
|
|
33836
|
+
if (!resolvedBranch) {
|
|
33837
|
+
const branchResult = await runGit(repo, ["symbolic-ref", "--short", "HEAD"], { cwd: repoRoot });
|
|
33838
|
+
resolvedBranch = branchResult.stdout.trim();
|
|
33839
|
+
if (!resolvedBranch) {
|
|
33840
|
+
throw new GitCommandError("git_command_failed", "Cannot push: not on a branch (detached HEAD)");
|
|
33841
|
+
}
|
|
33842
|
+
}
|
|
33843
|
+
const pushArgs = ["push"];
|
|
33844
|
+
if (setUpstream) pushArgs.push("--set-upstream");
|
|
33845
|
+
pushArgs.push(remote, resolvedBranch);
|
|
33846
|
+
let output = "";
|
|
33847
|
+
let newBranch = false;
|
|
33848
|
+
try {
|
|
33849
|
+
const result = await runGit(repo, pushArgs, { cwd: repoRoot });
|
|
33850
|
+
output = (result.stdout + result.stderr).trim();
|
|
33851
|
+
newBranch = /\[new branch\]/i.test(output);
|
|
33852
|
+
} catch (err) {
|
|
33853
|
+
const errOutput = (err?.stdout ?? "") + (err?.stderr ?? "");
|
|
33854
|
+
if (!setUpstream && /no upstream branch|set-upstream/i.test(errOutput)) {
|
|
33855
|
+
const retryArgs = ["push", "--set-upstream", remote, resolvedBranch];
|
|
33856
|
+
const retryResult = await runGit(repo, retryArgs, { cwd: repoRoot });
|
|
33857
|
+
output = (retryResult.stdout + retryResult.stderr).trim();
|
|
33858
|
+
newBranch = /\[new branch\]/i.test(output);
|
|
33859
|
+
} else {
|
|
33860
|
+
throw new GitCommandError("git_command_failed", errOutput || err?.message || "git push failed");
|
|
33861
|
+
}
|
|
33862
|
+
}
|
|
33863
|
+
return {
|
|
33864
|
+
workspace: repo.workspace,
|
|
33865
|
+
repoRoot,
|
|
33866
|
+
isGitRepo: true,
|
|
33867
|
+
remote,
|
|
33868
|
+
branch: resolvedBranch,
|
|
33869
|
+
output,
|
|
33870
|
+
newBranch,
|
|
33871
|
+
lastCheckedAt
|
|
33872
|
+
};
|
|
33873
|
+
}
|
|
33815
33874
|
function formatOptionalGitLogRangeArg(flag, value) {
|
|
33816
33875
|
return value ? [`${flag}=${value}`] : [];
|
|
33817
33876
|
}
|