GeezerVison is showing github.com — Merge remote-tracking branch 'origin/main' into t3/fix-epub-cdata-ent… · pingdotgg/t3code@e6861da
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: apps/mobile/src/lib/threadActivity.ts +3-1Lines changed: 3 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -761,7 +761,9 @@ function toWorkLogEntry( | 761 | 761 | case "file_change": | 762 | 762 | return { | 763 | 763 | ...common, | 764 | | - changedFiles: item.changes?.map((change) => change.path) ?? [item.fileName], | | 764 | + changedFiles: item.changes?.length | | 765 | + ? item.changes.map((change) => change.path) | | 766 | + : [item.fileName], | 765 | 767 | toolTitle: title ?? "File change", | 766 | 768 | toolData: item, | 767 | 769 | }; | |
Collapse file Copy file name to clipboardExpand all lines: apps/server/src/git/GitManager.test.ts +51Lines changed: 51 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -4759,6 +4759,57 @@ it.layer(layerGitManagerTest)("GitManager", (it) => { | 4759 | 4759 | }), | 4760 | 4760 | ); | 4761 | 4761 |
| | 4762 | + it.effect( | | 4763 | + "create_pr publishes to the push remote when the tracked upstream already has HEAD", | | 4764 | + () => | | 4765 | + Effect.gen(function* () { | | 4766 | + const repoDir = yield* makeTempDir("t3code-git-manager-"); | | 4767 | + yield* initRepo(repoDir); | | 4768 | + const originDir = yield* createBareRemote(); | | 4769 | + const forkDir = yield* createBareRemote(); | | 4770 | + yield* runGit(repoDir, ["remote", "add", "origin", originDir]); | | 4771 | + yield* runGit(repoDir, ["remote", "add", "fork", forkDir]); | | 4772 | + yield* runGit(repoDir, ["checkout", "-b", "topic"]); | | 4773 | + NodeFS.writeFileSync(NodePath.join(repoDir, "changes.txt"), "change\n"); | | 4774 | + yield* runGit(repoDir, ["add", "changes.txt"]); | | 4775 | + yield* runGit(repoDir, ["commit", "-m", "Topic change"]); | | 4776 | + yield* runGit(repoDir, ["push", "-u", "origin", "topic"]); | | 4777 | + yield* configureVisibleRemoteUrlWithLocalRewrite( | | 4778 | + repoDir, | | 4779 | + "origin", | | 4780 | + | | 4781 | + originDir, | | 4782 | + ); | | 4783 | + yield* configureVisibleRemoteUrlWithLocalRewrite( | | 4784 | + repoDir, | | 4785 | + "fork", | | 4786 | + | | 4787 | + forkDir, | | 4788 | + ); | | 4789 | + yield* runGit(repoDir, ["config", "remote.pushDefault", "fork"]); | | 4790 | + | | 4791 | + const { manager, providerCalls } = yield* makeManager(); | | 4792 | + const result = yield* runStackedAction(manager, { | | 4793 | + cwd: repoDir, | | 4794 | + action: "create_pr", | | 4795 | + }); | | 4796 | + | | 4797 | + expect(result.push).toMatchObject({ status: "pushed", upstreamBranch: "fork/topic" }); | | 4798 | + expect(result.pr.status).toBe("created"); | | 4799 | + expect( | | 4800 | + yield* runGit(forkDir, ["--git-dir=.", "log", "-1", "--pretty=%s", "topic"]), | | 4801 | + ).toMatchObject({ | | 4802 | + stdout: "Topic change\n", | | 4803 | + }); | | 4804 | + expect(created(providerCalls)).toEqual([ | | 4805 | + { baseRefName: "main", headSelector: "octocat:topic" }, | | 4806 | + ]); | | 4807 | + expect(yield* runGit(repoDir, ["rev-parse", "--abbrev-ref", "@{upstream}"])).toMatchObject({ | | 4808 | + stdout: "origin/topic\n", | | 4809 | + }); | | 4810 | + }), | | 4811 | + ); | | 4812 | + | 4762 | 4813 | it.effect("rejects push/pr actions from detached HEAD", () => | 4763 | 4814 | Effect.gen(function* () { | 4764 | 4815 | const repoDir = yield* makeTempDir("t3code-git-manager-"); | |
Collapse file Copy file name to clipboardExpand all lines: apps/server/src/git/GitManager.ts +25-5Lines changed: 25 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -2376,6 +2376,7 @@ export const make = Effect.gen(function* () { | 2376 | 2376 | fallbackBranch: string | null, | 2377 | 2377 | threadId: ThreadId | undefined, | 2378 | 2378 | emit: GitActionProgressEmitter, | | 2379 | + pushRemoteRef?: { readonly remoteName: string; readonly upstreamRef: string }, | 2379 | 2380 | ) { | 2380 | 2381 | const provider = yield* sourceControlProvider(cwd); | 2381 | 2382 | const terms = sourceControlDefinitions.get(provider.kind).changeRequest; | @@ -2396,10 +2397,12 @@ export const make = Effect.gen(function* () { | 2396 | 2397 | }); | 2397 | 2398 | } | 2398 | 2399 |
| 2399 | | - const headContext = yield* resolveBranchHeadContext(cwd, { | 2400 | | - branch, | 2401 | | - upstreamRef: details.upstreamRef, | 2402 | | - }); | | 2400 | + // A configured push remote receives the commits while the branch keeps | | 2401 | + // tracking its upstream, so the PR head is the push remote's branch. | | 2402 | + const headContext = yield* resolveBranchHeadContext( | | 2403 | + cwd, | | 2404 | + pushRemoteRef ? { branch, ...pushRemoteRef } : { branch, upstreamRef: details.upstreamRef }, | | 2405 | + ); | 2403 | 2406 |
| 2404 | 2407 | const existing = yield* findOpenPr(cwd, headContext); | 2405 | 2408 | if (existing) { | @@ -3412,12 +3415,26 @@ export const make = Effect.gen(function* () { | 3412 | 3415 | > { | 3413 | 3416 | const initialStatus = yield* gitCore.statusDetails(input.cwd); | 3414 | 3417 | const wantsCommit = isCommitAction(input.action); | | 3418 | + const upToDateBranch = | | 3419 | + input.action === "create_pr" && | | 3420 | + initialStatus.hasUpstream && | | 3421 | + initialStatus.aheadCount === 0 | | 3422 | + ? initialStatus.branch | | 3423 | + : null; | | 3424 | + // A current upstream says nothing about a separate push remote, which may lack HEAD. | | 3425 | + const pushTarget = upToDateBranch | | 3426 | + ? yield* gitCore | | 3427 | + .resolvePushTarget(input.cwd, { branch: upToDateBranch, hasUpstream: true }) | | 3428 | + .pipe(Effect.orElseSucceed(() => null)) | | 3429 | + : null; | 3415 | 3430 | const wantsPush = | 3416 | 3431 | input.action === "push" || | 3417 | 3432 | input.action === "commit_push" || | 3418 | 3433 | input.action === "commit_push_pr" || | 3419 | 3434 | (input.action === "create_pr" && | 3420 | | - (!initialStatus.hasUpstream || initialStatus.aheadCount > 0)); | | 3435 | + (!initialStatus.hasUpstream || | | 3436 | + initialStatus.aheadCount > 0 || | | 3437 | + pushTarget?.viaPushRemote === true)); | 3421 | 3438 | const wantsPr = input.action === "create_pr" || input.action === "commit_push_pr"; | 3422 | 3439 |
| 3423 | 3440 | if (input.featureBranch && !wantsCommit) { | @@ -3570,6 +3587,9 @@ export const make = Effect.gen(function* () { | 3570 | 3587 | currentBranch, | 3571 | 3588 | input.threadId, | 3572 | 3589 | progress.emit, | | 3590 | + "pushRemote" in push && push.pushRemote && push.upstreamBranch | | 3591 | + ? { remoteName: push.pushRemote, upstreamRef: push.upstreamBranch } | | 3592 | + : undefined, | 3573 | 3593 | ), | 3574 | 3594 | ), | 3575 | 3595 | ) | |
Collapse file Copy file name to clipboardExpand all lines: apps/server/src/orchestration-v2/ContextHandoffBudget.test.ts +4Lines changed: 4 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -151,6 +151,10 @@ describe("handoff budget", () => { | 151 | 151 | })?.text, | 152 | 152 | "File change: src/a.ts, src/b.ts, src/new.ts", | 153 | 153 | ); | | 154 | + assert.equal( | | 155 | + historicalMessage({ ...base, type: "file_change", fileName: "src/a.ts", changes: [] })?.text, | | 156 | + "File change: src/a.ts", | | 157 | + ); | 154 | 158 | assert.isNull( | 155 | 159 | historicalMessage({ | 156 | 160 | ...base, | |
Collapse file Copy file name to clipboardExpand all lines: apps/server/src/orchestration-v2/ContextHandoffService.ts +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -215,7 +215,7 @@ function summarizeDeltaItem(item: OrchestrationV2TurnItem): string | null { | 215 | 215 | case "command_execution": | 216 | 216 | return `- Command: ${compactText(item.input)}`; | 217 | 217 | case "file_change": | 218 | | - return `- File change: ${compactText(item.changes?.map((change) => change.path).join(", ") ?? item.fileName)}`; | | 218 | + return `- File change: ${compactText(item.changes?.length ? item.changes.map((change) => change.path).join(", ") : item.fileName)}`; | 219 | 219 | case "checkpoint": | 220 | 220 | return `- Checkpoint: ${item.files.length} files`; | 221 | 221 | case "handoff": | |
Collapse file Copy file name to clipboardExpand all lines: apps/server/src/vcs/GitVcsDriver.ts +4Lines changed: 4 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -179,12 +179,16 @@ export interface GitPushResult { | 179 | 179 | status: "pushed" | "skipped_up_to_date"; | 180 | 180 | branch: string; | 181 | 181 | upstreamBranch?: string | undefined; | | 182 | + /** Set when `upstreamBranch` is on a configured push remote instead of the tracked upstream. */ | | 183 | + pushRemote?: string | undefined; | 182 | 184 | setUpstream?: boolean | undefined; | 183 | 185 | } | 184 | 186 |
| 185 | 187 | export interface GitPushTarget { | 186 | 188 | remoteName: string; | 187 | 189 | branchName: string; | | 190 | + /** The tracked upstream is current, yet pushes go to this configured push remote. */ | | 191 | + viaPushRemote: boolean; | 188 | 192 | } | 189 | 193 |
| 190 | 194 | export interface GitRangeContext { | |
Collapse file Copy file name to clipboardExpand all lines: apps/server/src/vcs/GitVcsDriverCore.test.ts +146Lines changed: 146 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -7998,6 +7998,152 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => { | 7998 | 7998 | assert.notEqual(originMain.exitCode, 0); | 7999 | 7999 | }), | 8000 | 8000 | ); | | 8001 | + | | 8002 | + it.effect.each(["branch.topic.pushRemote", "remote.pushDefault"] as const)( | | 8003 | + "pushes a branch tracking its upstream head to the %s remote", | | 8004 | + (configKey) => | | 8005 | + Effect.gen(function* () { | | 8006 | + const cwd = yield* makeTmpDir(); | | 8007 | + const upstreamRemote = yield* makeTmpDir("git-upstream-remote-"); | | 8008 | + const forkRemote = yield* makeTmpDir("git-fork-remote-"); | | 8009 | + yield* initRepoWithCommit(cwd); | | 8010 | + const driver = yield* GitVcsDriver.GitVcsDriver; | | 8011 | + yield* git(upstreamRemote, ["init", "--bare"]); | | 8012 | + yield* git(forkRemote, ["init", "--bare"]); | | 8013 | + yield* git(cwd, ["remote", "add", "upstream", upstreamRemote]); | | 8014 | + yield* git(cwd, ["remote", "add", "fork", forkRemote]); | | 8015 | + yield* git(cwd, ["checkout", "-b", "topic"]); | | 8016 | + yield* git(cwd, ["push", "upstream", "topic"]); | | 8017 | + yield* git(cwd, ["push", "fork", "topic"]); | | 8018 | + yield* git(cwd, ["branch", "--set-upstream-to=upstream/topic"]); | | 8019 | + yield* git(cwd, ["config", configKey, "fork"]); | | 8020 | + const upstreamTopicSha = yield* git(cwd, ["rev-parse", "HEAD"]); | | 8021 | + yield* writeTextFile(cwd, "fork.txt", "fork\n"); | | 8022 | + yield* git(cwd, ["add", "-A"]); | | 8023 | + yield* driver.commit(cwd, "Add fork update", ""); | | 8024 | + | | 8025 | + const pushed = yield* driver.pushCurrentBranch(cwd, null); | | 8026 | + | | 8027 | + assert.deepInclude(pushed, { | | 8028 | + status: "pushed", | | 8029 | + branch: "topic", | | 8030 | + upstreamBranch: "fork/topic", | | 8031 | + pushRemote: "fork", | | 8032 | + setUpstream: false, | | 8033 | + }); | | 8034 | + assert.equal( | | 8035 | + yield* git(forkRemote, ["--git-dir=.", "log", "-1", "--pretty=%s", "topic"]), | | 8036 | + "Add fork update", | | 8037 | + ); | | 8038 | + assert.equal( | | 8039 | + yield* git(upstreamRemote, ["--git-dir=.", "rev-parse", "topic"]), | | 8040 | + upstreamTopicSha, | | 8041 | + ); | | 8042 | + assert.equal( | | 8043 | + yield* git(cwd, ["rev-parse", "--abbrev-ref", "@{upstream}"]), | | 8044 | + "upstream/topic", | | 8045 | + ); | | 8046 | + }), | | 8047 | + ); | | 8048 | + | | 8049 | + it.effect.each(["deleted", "rewound"] as const)( | | 8050 | + "pushes an up-to-date tracked branch to the push remote when its branch there is %s", | | 8051 | + (forkState) => | | 8052 | + Effect.gen(function* () { | | 8053 | + const cwd = yield* makeTmpDir(); | | 8054 | + const upstreamRemote = yield* makeTmpDir("git-upstream-remote-"); | | 8055 | + const forkRemote = yield* makeTmpDir("git-fork-remote-"); | | 8056 | + yield* initRepoWithCommit(cwd); | | 8057 | + const driver = yield* GitVcsDriver.GitVcsDriver; | | 8058 | + yield* git(upstreamRemote, ["init", "--bare"]); | | 8059 | + yield* git(forkRemote, ["init", "--bare"]); | | 8060 | + yield* git(cwd, ["remote", "add", "upstream", upstreamRemote]); | | 8061 | + yield* git(cwd, ["remote", "add", "fork", forkRemote]); | | 8062 | + yield* git(cwd, ["checkout", "-b", "topic"]); | | 8063 | + yield* writeTextFile(cwd, "upstream.txt", "upstream\n"); | | 8064 | + yield* git(cwd, ["add", "-A"]); | | 8065 | + yield* driver.commit(cwd, "Add upstream update", ""); | | 8066 | + yield* git(cwd, ["push", "-u", "upstream", "topic"]); | | 8067 | + yield* git(cwd, ["config", "remote.pushDefault", "fork"]); | | 8068 | + // Another checkout changes the fork after this one last fetched it, | | 8069 | + // leaving a local fork/topic that still contains HEAD. | | 8070 | + yield* git(cwd, ["push", "fork", "topic"]); | | 8071 | + yield* git( | | 8072 | + forkRemote, | | 8073 | + forkState === "deleted" | | 8074 | + ? ["--git-dir=.", "update-ref", "-d", "refs/heads/topic"] | | 8075 | + : ["--git-dir=.", "update-ref", "refs/heads/topic", "topic~1"], | | 8076 | + ); | | 8077 | + | | 8078 | + const pushed = yield* driver.pushCurrentBranch(cwd, null); | | 8079 | + | | 8080 | + assert.deepInclude(pushed, { | | 8081 | + status: "pushed", | | 8082 | + upstreamBranch: "fork/topic", | | 8083 | + pushRemote: "fork", | | 8084 | + }); | | 8085 | + assert.equal( | | 8086 | + yield* git(forkRemote, ["--git-dir=.", "log", "-1", "--pretty=%s", "topic"]), | | 8087 | + "Add upstream update", | | 8088 | + ); | | 8089 | + assert.equal( | | 8090 | + yield* git(cwd, ["rev-parse", "--abbrev-ref", "@{upstream}"]), | | 8091 | + "upstream/topic", | | 8092 | + ); | | 8093 | + }), | | 8094 | + ); | | 8095 | + | | 8096 | + it.effect("skips an up-to-date tracked branch the push remote already has", () => | | 8097 | + Effect.gen(function* () { | | 8098 | + const cwd = yield* makeTmpDir(); | | 8099 | + const upstreamRemote = yield* makeTmpDir("git-upstream-remote-"); | | 8100 | + const forkRemote = yield* makeTmpDir("git-fork-remote-"); | | 8101 | + yield* initRepoWithCommit(cwd); | | 8102 | + const driver = yield* GitVcsDriver.GitVcsDriver; | | 8103 | + yield* git(upstreamRemote, ["init", "--bare"]); | | 8104 | + yield* git(forkRemote, ["init", "--bare"]); | | 8105 | + yield* git(cwd, ["remote", "add", "upstream", upstreamRemote]); | | 8106 | + yield* git(cwd, ["remote", "add", "fork", forkRemote]); | | 8107 | + yield* git(cwd, ["checkout", "-b", "topic"]); | | 8108 | + yield* git(cwd, ["push", "-u", "upstream", "topic"]); | | 8109 | + yield* git(cwd, ["push", "fork", "topic"]); | | 8110 | + yield* git(cwd, ["config", "remote.pushDefault", "fork"]); | | 8111 | + | | 8112 | + const pushed = yield* driver.pushCurrentBranch(cwd, null); | | 8113 | + | | 8114 | + assert.deepInclude(pushed, { | | 8115 | + status: "skipped_up_to_date", | | 8116 | + upstreamBranch: "fork/topic", | | 8117 | + pushRemote: "fork", | | 8118 | + }); | | 8119 | + }), | | 8120 | + ); | | 8121 | + | | 8122 | + it.effect("skips an up-to-date branch whose differently named upstream is its base", () => | | 8123 | + Effect.gen(function* () { | | 8124 | + const cwd = yield* makeTmpDir(); | | 8125 | + const upstreamRemote = yield* makeTmpDir("git-upstream-remote-"); | | 8126 | + const forkRemote = yield* makeTmpDir("git-fork-remote-"); | | 8127 | + yield* initRepoWithCommit(cwd); | | 8128 | + const driver = yield* GitVcsDriver.GitVcsDriver; | | 8129 | + yield* git(upstreamRemote, ["init", "--bare"]); | | 8130 | + yield* git(forkRemote, ["init", "--bare"]); | | 8131 | + yield* git(cwd, ["remote", "add", "upstream", upstreamRemote]); | | 8132 | + yield* git(cwd, ["remote", "add", "fork", forkRemote]); | | 8133 | + yield* git(cwd, ["push", "upstream", "HEAD:refs/heads/release"]); | | 8134 | + yield* git(cwd, ["fetch", "upstream"]); | | 8135 | + yield* git(cwd, ["checkout", "-b", "topic", "--track", "upstream/release"]); | | 8136 | + yield* git(cwd, ["config", "remote.pushDefault", "fork"]); | | 8137 | + | | 8138 | + const pushed = yield* driver.pushCurrentBranch(cwd, null); | | 8139 | + | | 8140 | + assert.deepInclude(pushed, { | | 8141 | + status: "skipped_up_to_date", | | 8142 | + upstreamBranch: "upstream/release", | | 8143 | + }); | | 8144 | + assert.equal(yield* git(forkRemote, ["--git-dir=.", "branch", "--list", "topic"]), ""); | | 8145 | + }), | | 8146 | + ); | 8001 | 8147 | }); | 8002 | 8148 | }); | 8003 | 8149 |
| |
|