fix(server): scheduled tasks start from the default branch, not always main #27983
Mergedtuanvumaihuynh(GitHub profile, opens in a new tab)merged 4 commits into
main fromrefs/pull/27983/headmerged by maria-rcks View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
- apps/server/src/mcp/OrchestratorMcpService.ts line 1802OutdatedResolvedby tuanvumaihuynh(GitHub profile, opens in a new tab)@@ -1793,3 +1785,18 @@17931785 effect.pipe(Effect.timeoutOption(Duration.millis(timeoutMs)), Effect.map(Option.flatten)),17941786 );179517871788+ const refExists = (cwd: string, revision: string) =>1789+ gitDriver.resolveCommit({ cwd, revision }).pipe(1790+ Effect.as(true),1791+ Effect.orElseSucceed(() => false),1792+ );1793+1794+ const resolveScheduledTaskBaseRef = Effect.fn(1795+ "OrchestratorMcpService.resolveScheduledTaskBaseRef",1796+ )(function* (cwd: string) {1797+ const remoteName = yield* gitDriver1798+ .resolvePrimaryRemoteName(cwd)1799+ .pipe(Effect.orElseSucceed(() => null));1800+ // Launch fetches a bare name from `origin` only, so any other remote must be named.1801+ const onRemote = (branch: string) =>1802+ remoteName === "origin" ? branch : `${remoteName}/${branch}`;
- apps/server/src/mcp/OrchestratorMcpService.ts line 1802OutdatedResolvedby tuanvumaihuynh(GitHub profile, opens in a new tab)@@ -1793,3 +1785,18 @@17931785 effect.pipe(Effect.timeoutOption(Duration.millis(timeoutMs)), Effect.map(Option.flatten)),17941786 );179517871788+ const refExists = (cwd: string, revision: string) =>1789+ gitDriver.resolveCommit({ cwd, revision }).pipe(1790+ Effect.as(true),1791+ Effect.orElseSucceed(() => false),1792+ );1793+1794+ const resolveScheduledTaskBaseRef = Effect.fn(1795+ "OrchestratorMcpService.resolveScheduledTaskBaseRef",1796+ )(function* (cwd: string) {1797+ const remoteName = yield* gitDriver1798+ .resolvePrimaryRemoteName(cwd)1799+ .pipe(Effect.orElseSucceed(() => null));1800+ // Launch fetches a bare name from `origin` only, so any other remote must be named.1801+ const onRemote = (branch: string) =>1802+ remoteName === "origin" ? branch : `${remoteName}/${branch}`;@@ -1795,0 +1789,21 @@1789+ gitDriver.resolveCommit({ cwd, revision }).pipe(1790+ Effect.as(true),1791+ Effect.orElseSucceed(() => false),1792+ );1793+1794+ const resolveScheduledTaskBaseRef = Effect.fn(1795+ "OrchestratorMcpService.resolveScheduledTaskBaseRef",1796+ )(function* (cwd: string) {1797+ const remoteName = yield* gitDriver1798+ .resolvePrimaryRemoteName(cwd)1799+ .pipe(Effect.orElseSucceed(() => null));1800+ // Launch fetches a bare name from `origin` only, so any other remote must be named.1801+ const onRemote = (branch: string) =>1802+ remoteName === "origin" ? branch : `${remoteName}/${branch}`;1803+ const remoteDefault =1804+ remoteName === null1805+ ? null1806+ : yield* gitDriver1807+ .resolveDefaultBranchName(cwd, remoteName)1808+ .pipe(Effect.orElseSucceed(() => null));1809+ if (remoteDefault !== null) return onRemote(remoteDefault);apps/server/src/mcp/OrchestratorMcpService.ts lines 1811 to 1815OutdatedResolvedby tuanvumaihuynh(GitHub profile, opens in a new tab)@@ -1795,0 +1795,21 @@1795+ "OrchestratorMcpService.resolveScheduledTaskBaseRef",1796+ )(function* (cwd: string) {1797+ const remoteName = yield* gitDriver1798+ .resolvePrimaryRemoteName(cwd)1799+ .pipe(Effect.orElseSucceed(() => null));1800+ // Launch fetches a bare name from `origin` only, so any other remote must be named.1801+ const onRemote = (branch: string) =>1802+ remoteName === "origin" ? branch : `${remoteName}/${branch}`;1803+ const remoteDefault =1804+ remoteName === null1805+ ? null1806+ : yield* gitDriver1807+ .resolveDefaultBranchName(cwd, remoteName)1808+ .pipe(Effect.orElseSucceed(() => null));1809+ if (remoteDefault !== null) return onRemote(remoteDefault);1810+ // Local-only repositories and remotes without a recorded HEAD report no default.1811+ for (const branch of ["main", "master"]) {1812+ if (remoteName !== null && (yield* refExists(cwd, `refs/remotes/${remoteName}/${branch}`))) {1813+ return onRemote(branch);1814+ }1815+ if (yield* refExists(cwd, `refs/heads/${branch}`)) return branch;
- @@ -1795,0 +1791,21 @@1791+ Effect.orElseSucceed(() => false),1792+ );1793+1794+ const resolveScheduledTaskBaseRef = Effect.fn(1795+ "OrchestratorMcpService.resolveScheduledTaskBaseRef",1796+ )(function* (cwd: string) {1797+ const remoteName = yield* gitDriver1798+ .resolvePrimaryRemoteName(cwd)1799+ .pipe(Effect.orElseSucceed(() => null));1800+ const conventional = ["main", "master"];1801+ if (remoteName !== null) {1802+ const remoteDefault = yield* gitDriver1803+ .resolveDefaultBranchName(cwd, remoteName)1804+ .pipe(Effect.orElseSucceed(() => null));1805+ // Fetch does not update a recorded HEAD, so it can outlive the branch it names.1806+ for (const branch of remoteDefault === null1807+ ? conventional1808+ : [remoteDefault, ...conventional]) {1809+ // Launch resolves a bare name through a local branch's upstream, or else assumes `origin`.1810+ if (yield* refExists(cwd, `refs/remotes/${remoteName}/${branch}`)) {1811+ return `${remoteName}/${branch}`;@@ -1795,0 +1796,21 @@1796+ )(function* (cwd: string) {1797+ const remoteName = yield* gitDriver1798+ .resolvePrimaryRemoteName(cwd)1799+ .pipe(Effect.orElseSucceed(() => null));1800+ const conventional = ["main", "master"];1801+ if (remoteName !== null) {1802+ const remoteDefault = yield* gitDriver1803+ .resolveDefaultBranchName(cwd, remoteName)1804+ .pipe(Effect.orElseSucceed(() => null));1805+ // Fetch does not update a recorded HEAD, so it can outlive the branch it names.1806+ for (const branch of remoteDefault === null1807+ ? conventional1808+ : [remoteDefault, ...conventional]) {1809+ // Launch resolves a bare name through a local branch's upstream, or else assumes `origin`.1810+ if (yield* refExists(cwd, `refs/remotes/${remoteName}/${branch}`)) {1811+ return `${remoteName}/${branch}`;1812+ }1813+ }1814+ }1815+ // Local-only repositories, or a remote with neither a usable HEAD nor a conventional branch.1816+ for (const branch of conventional) {
maria-rcks merged this4773ab7
maria-rcks closed this
Sign in to join this conversation.


Codex Review Summary#
This comment shows the latest Codex review activity on this pull request.
We couldn’t complete this review. Comment
@codex reviewto try again.f8081a4ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.