Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

address review: pass --hostname for non-default GHES hosts; meaningful skip test

Adam Eivy6d5e9452ad52
diff --git a/server/services/git.js b/server/services/git.js
index 5ff6c63336..5ee692e8db 100644
--- a/server/services/git.js
+++ b/server/services/git.js
@@ -557,12 +557,19 @@ export async function requestCopilotReview(dir, prUrl) {
// so cleanupAgentWorktree doesn't emit a warning for every GitLab MR.
if (cli !== 'gh') return { success: true, skipped: true };
- const args = [
- 'api',
+ // Target the same GitHub instance the PR lives on. Without --hostname, gh uses
+ // its current default host, which is wrong for GHES installs or when the user
+ // has multiple gh hosts configured. github.com is gh's implicit default so we
+ // only need to set it explicitly for non-default hosts.
+ const args = ['api'];
+ if (parsed.host && parsed.host !== 'github.com') {
+ args.push('--hostname', parsed.host);
+ }
+ args.push(
`repos/${parsed.owner}/${parsed.repo}/pulls/${parsed.number}/requested_reviewers`,
'-X', 'POST',
'-f', 'reviewers[]=copilot-pull-request-reviewer[bot]'
- ];
+ );
return new Promise((resolve) => {
const child = spawn(cli, args, { cwd: dir, env, shell: false, windowsHide: true });
diff --git a/server/services/git.test.js b/server/services/git.test.js
index 6506bcbda1..a7874b0e5c 100644
--- a/server/services/git.test.js
+++ b/server/services/git.test.js
@@ -180,17 +180,21 @@ describe('requestCopilotReview', () => {
if (!result.success) expect(typeof result.error).toBe('string');
});
- it('non-GitHub forge result shape: success=true with skipped=true (callers treat as successful non-event)', async () => {
- // resolveForgeForRepo is internal to git.js so we cannot mock it directly.
- // Instead, verify the result-shape contract: when success is true, callers
- // (cleanupAgentWorktree) only need to distinguish a real review request from
- // a no-op via the `skipped` flag. Here we just assert the function never
- // throws on a GitLab URL and returns a structured result the caller can
- // branch on. The behavior assertion (info-not-warning logging) is covered
- // in cleanupAgentWorktree.test.js once we plumb the skipped flag through.
- const result = await requestCopilotReview('/nonexistent-path-for-test', 'https://gitlab.com/group/proj/-/merge_requests/1');
- expect(result).toHaveProperty('success');
- expect(typeof result.success).toBe('boolean');
+ it('returns { success: true, skipped: true } when the repo origin is a non-GitHub forge', async () => {
+ // resolveForgeForRepo reads `git remote get-url origin` from `dir`, so we set up a
+ // throwaway git repo with a gitlab.com remote — this exercises the real cli !== 'gh'
+ // skip path end-to-end without mocking. Without this, a nonexistent dir would fall
+ // back to cli: 'gh' and the test would silently pass even if the skip path broke.
+ const { mkdtempSync } = await import('fs');
+ const { tmpdir } = await import('os');
+ const { execSync } = await import('child_process');
+ const path = await import('path');
+ const repo = mkdtempSync(path.join(tmpdir(), 'portos-git-skip-'));
+ execSync('git init -q', { cwd: repo });
+ execSync('git remote add origin [email protected]:group/proj.git', { cwd: repo });
+
+ const result = await requestCopilotReview(repo, 'https://gitlab.com/group/proj/-/merge_requests/1');
+ expect(result).toEqual({ success: true, skipped: true });
});
});