GeezerVison is showing github.com — refactor(git): remove runtime facade wrappers (#21982) · ainformatico/opencode@fe4dfb9
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: packages/opencode/src/cli/cmd/github.ts +8-4Lines changed: 8 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -29,6 +29,7 @@ import { Provider } from "../../provider/provider" | 29 | 29 | import { Bus } from "../../bus" | 30 | 30 | import { MessageV2 } from "../../session/message-v2" | 31 | 31 | import { SessionPrompt } from "@/session/prompt" | | 32 | +import { AppRuntime } from "@/effect/app-runtime" | 32 | 33 | import { Git } from "@/git" | 33 | 34 | import { setTimeout as sleep } from "node:timers/promises" | 34 | 35 | import { Process } from "@/util/process" | @@ -258,7 +259,9 @@ export const GithubInstallCommand = cmd({ | 258 | 259 | } | 259 | 260 |
| 260 | 261 | // Get repo info | 261 | | - const info = (await Git.run(["remote", "get-url", "origin"], { cwd: Instance.worktree })).text().trim() | | 262 | + const info = await AppRuntime.runPromise( | | 263 | + Git.Service.use((git) => git.run(["remote", "get-url", "origin"], { cwd: Instance.worktree })), | | 264 | + ).then((x) => x.text().trim()) | 262 | 265 | const parsed = parseGitHubRemote(info) | 263 | 266 | if (!parsed) { | 264 | 267 | prompts.log.error(`Could not find git repository. Please run this command from a git repository.`) | @@ -497,20 +500,21 @@ export const GithubRunCommand = cmd({ | 497 | 500 | : "issue" | 498 | 501 | : undefined | 499 | 502 | const gitText = async (args: string[]) => { | 500 | | - const result = await Git.run(args, { cwd: Instance.worktree }) | | 503 | + const result = await AppRuntime.runPromise(Git.Service.use((git) => git.run(args, { cwd: Instance.worktree }))) | 501 | 504 | if (result.exitCode !== 0) { | 502 | 505 | throw new Process.RunFailedError(["git", ...args], result.exitCode, result.stdout, result.stderr) | 503 | 506 | } | 504 | 507 | return result.text().trim() | 505 | 508 | } | 506 | 509 | const gitRun = async (args: string[]) => { | 507 | | - const result = await Git.run(args, { cwd: Instance.worktree }) | | 510 | + const result = await AppRuntime.runPromise(Git.Service.use((git) => git.run(args, { cwd: Instance.worktree }))) | 508 | 511 | if (result.exitCode !== 0) { | 509 | 512 | throw new Process.RunFailedError(["git", ...args], result.exitCode, result.stdout, result.stderr) | 510 | 513 | } | 511 | 514 | return result | 512 | 515 | } | 513 | | - const gitStatus = (args: string[]) => Git.run(args, { cwd: Instance.worktree }) | | 516 | + const gitStatus = (args: string[]) => | | 517 | + AppRuntime.runPromise(Git.Service.use((git) => git.run(args, { cwd: Instance.worktree }))) | 514 | 518 | const commitChanges = async (summary: string, actor?: string) => { | 515 | 519 | const args = ["commit", "-m", summary] | 516 | 520 | if (actor) args.push("-m", `Co-authored-by: ${actor} <${actor}@users.noreply.github.com>`) | |
Collapse file Copy file name to clipboardExpand all lines: packages/opencode/src/cli/cmd/pr.ts +18-7Lines changed: 18 additions & 7 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | import { UI } from "../ui" | 2 | 2 | import { cmd } from "./cmd" | | 3 | +import { AppRuntime } from "@/effect/app-runtime" | 3 | 4 | import { Git } from "@/git" | 4 | 5 | import { Instance } from "@/project/instance" | 5 | 6 | import { Process } from "@/util/process" | @@ -67,19 +68,29 @@ export const PrCommand = cmd({ | 67 | 68 | const remoteName = forkOwner | 68 | 69 |
| 69 | 70 | // Check if remote already exists | 70 | | - const remotes = (await Git.run(["remote"], { cwd: Instance.worktree })).text().trim() | | 71 | + const remotes = await AppRuntime.runPromise( | | 72 | + Git.Service.use((git) => git.run(["remote"], { cwd: Instance.worktree })), | | 73 | + ).then((x) => x.text().trim()) | 71 | 74 | if (!remotes.split("\n").includes(remoteName)) { | 72 | | - await Git.run(["remote", "add", remoteName, `https://github.com/${forkOwner}/${forkName}.git`], { | 73 | | - cwd: Instance.worktree, | 74 | | - }) | | 75 | + await AppRuntime.runPromise( | | 76 | + Git.Service.use((git) => | | 77 | + git.run(["remote", "add", remoteName, `https://github.com/${forkOwner}/${forkName}.git`], { | | 78 | + cwd: Instance.worktree, | | 79 | + }), | | 80 | + ), | | 81 | + ) | 75 | 82 | UI.println(`Added fork remote: ${remoteName}`) | 76 | 83 | } | 77 | 84 |
| 78 | 85 | // Set upstream to the fork so pushes go there | 79 | 86 | const headRefName = prInfo.headRefName | 80 | | - await Git.run(["branch", `--set-upstream-to=${remoteName}/${headRefName}`, localBranchName], { | 81 | | - cwd: Instance.worktree, | 82 | | - }) | | 87 | + await AppRuntime.runPromise( | | 88 | + Git.Service.use((git) => | | 89 | + git.run(["branch", `--set-upstream-to=${remoteName}/${headRefName}`, localBranchName], { | | 90 | + cwd: Instance.worktree, | | 91 | + }), | | 92 | + ), | | 93 | + ) | 83 | 94 | } | 84 | 95 |
| 85 | 96 | // Check for opencode session link in PR body | |
Collapse file Copy file name to clipboardExpand all lines: packages/opencode/src/git/index.ts -11Lines changed: 0 additions & 11 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | import * as CrossSpawnSpawner from "@/effect/cross-spawn-spawner" | 2 | 2 | import { Effect, Layer, Context, Stream } from "effect" | 3 | 3 | import { ChildProcess, ChildProcessSpawner } from "effect/unstable/process" | 4 | | -import { makeRuntime } from "@/effect/run-service" | 5 | 4 |
| 6 | 5 | export namespace Git { | 7 | 6 | const cfg = [ | @@ -258,14 +257,4 @@ export namespace Git { | 258 | 257 | ) | 259 | 258 |
| 260 | 259 | export const defaultLayer = layer.pipe(Layer.provide(CrossSpawnSpawner.defaultLayer)) | 261 | | - | 262 | | - const { runPromise } = makeRuntime(Service, defaultLayer) | 263 | | - | 264 | | - export async function run(args: string[], opts: Options) { | 265 | | - return runPromise((git) => git.run(args, opts)) | 266 | | - } | 267 | | - | 268 | | - export async function defaultBranch(cwd: string) { | 269 | | - return runPromise((git) => git.defaultBranch(cwd)) | 270 | | - } | 271 | 260 | } |
|