GeezerVison is showing github.com — fix(server): status reads the upstream's configured remote before fet… · pingdotgg/t3code@7368460
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/server/src/vcs/GitVcsDriverCore.test.ts +3Lines changed: 3 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -1350,7 +1350,10 @@ it.effect("does not fetch for status when the branch tracks a local branch", () | 1350 | 1350 | Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, spawner), | 1351 | 1351 | ); | 1352 | 1352 | const cwd = yield* makeTmpDir(); | | 1353 | + const remote = yield* makeTmpDir("git-vcs-driver-remote-"); | 1353 | 1354 | yield* initRepoWithCommit(cwd); | | 1355 | + yield* git(remote, ["init", "--bare"]); | | 1356 | + yield* git(cwd, ["remote", "add", "feature", remote]); | 1354 | 1357 | yield* git(cwd, ["branch", "feature/base"]); | 1355 | 1358 | yield* git(cwd, ["checkout", "-b", "stacked", "--track", "feature/base"]); | 1356 | 1359 |
| |
Collapse file Copy file name to clipboardExpand all lines: apps/server/src/vcs/GitVcsDriverCore.ts +16-13Lines changed: 16 additions & 13 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -1643,22 +1643,25 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function* | 1643 | 1643 | const refreshStatusUpstreamIfStale = Effect.fn("refreshStatusUpstreamIfStale")(function* ( | 1644 | 1644 | cwd: string, | 1645 | 1645 | ) { | 1646 | | - const upstreamRef = yield* readCurrentUpstreamRef(cwd); | 1647 | | - if (upstreamRef === null) return; | 1648 | | - const remoteNames = yield* runGitStdout("GitVcsDriver.listRemoteNames", cwd, ["remote"]).pipe( | 1649 | | - Effect.map(parseRemoteNames), | 1650 | | - Effect.orElseSucceed((): ReadonlyArray<string> => []), | 1651 | | - ); | 1652 | | - // An upstream on no configured remote is a local branch (`branch.<name>.remote = .`). | 1653 | | - const upstream = parseUpstreamRefWithRemoteNames(upstreamRef, remoteNames); | 1654 | | - if (!upstream) return; | | 1646 | + const headRef = yield* runGitStdout( | | 1647 | + "GitVcsDriver.refreshStatusUpstreamIfStale.headRef", | | 1648 | + cwd, | | 1649 | + ["symbolic-ref", "--quiet", "HEAD"], | | 1650 | + true, | | 1651 | + ).pipe(Effect.map((stdout) => stdout.trim())); | | 1652 | + if (headRef.length === 0) return; | | 1653 | + const remoteName = yield* runGitStdout( | | 1654 | + "GitVcsDriver.refreshStatusUpstreamIfStale.upstreamRemote", | | 1655 | + cwd, | | 1656 | + ["for-each-ref", "--format=%(upstream:remotename)", headRef], | | 1657 | + true, | | 1658 | + ).pipe(Effect.map((stdout) => stdout.trim())); | | 1659 | + // Empty means no upstream; `.` means the upstream is a local branch. | | 1660 | + if (remoteName.length === 0 || remoteName === ".") return; | 1655 | 1661 | const gitCommonDir = yield* resolveGitCommonDir(cwd); | 1656 | 1662 | yield* Cache.get( | 1657 | 1663 | statusRemoteRefreshCache, | 1658 | | - new StatusRemoteRefreshCacheKey({ | 1659 | | - gitCommonDir, | 1660 | | - remoteName: upstream.remoteName, | 1661 | | - }), | | 1664 | + new StatusRemoteRefreshCacheKey({ gitCommonDir, remoteName }), | 1662 | 1665 | ).pipe(Effect.ignore); | 1663 | 1666 | }); | 1664 | 1667 |
| |
|