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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
test: drop gitForge describe blocks duplicated in git.test.js (#12975) (#13023)
[._.]/a9f365d3fabe
diff --git a/server/services/git.test.js b/server/services/git.test.jsindex 77ce396e4c..d8ba053cd6 100644--- a/server/services/git.test.js+++ b/server/services/git.test.js@@ -1,88 +1,5 @@import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';-import { createPR, extractAgentSummary, parseGitHubOwnerFromRemote, pickGhAccountForOwner, parseGitRemote, detectForgeCli, parsePullRequestUrl, requestCopilotReview } from './git.js';--describe('parseGitRemote', () => {- it('parses GitHub SSH urls', () => {- expect(parseGitRemote('[email protected]:atomantic/PortOS.git')).toEqual({ host: 'github.com', owner: 'atomantic' });- expect(parseGitRemote('[email protected]:atomantic/PortOS')).toEqual({ host: 'github.com', owner: 'atomantic' });- });-- it('parses GitHub HTTPS urls', () => {- expect(parseGitRemote('https://github.com/atomantic/PortOS.git')).toEqual({ host: 'github.com', owner: 'atomantic' });- expect(parseGitRemote('https://github.com/atomantic/PortOS')).toEqual({ host: 'github.com', owner: 'atomantic' });- });-- it('parses GitLab SSH and HTTPS urls (including subgroup paths)', () => {- expect(parseGitRemote('[email protected]:my-group/my-project.git')).toEqual({ host: 'gitlab.com', owner: 'my-group' });- expect(parseGitRemote('https://gitlab.com/my-group/sub/proj.git')).toEqual({ host: 'gitlab.com', owner: 'my-group' });- expect(parseGitRemote('[email protected]:team/repo.git')).toEqual({ host: 'gitlab.example.com', owner: 'team' });- });-- it('returns null for empty, null, or malformed input', () => {- expect(parseGitRemote('')).toBeNull();- expect(parseGitRemote(null)).toBeNull();- expect(parseGitRemote(undefined)).toBeNull();- expect(parseGitRemote('github.com:atomantic/PortOS')).toBeNull();- expect(parseGitRemote('[email protected]:noslash')).toBeNull();- });-});--describe('parseGitHubOwnerFromRemote (back-compat wrapper)', () => {- it('returns owner only for github.com hosts', () => {- expect(parseGitHubOwnerFromRemote('[email protected]:atomantic/PortOS.git')).toBe('atomantic');- expect(parseGitHubOwnerFromRemote('https://github.com/atomantic/PortOS')).toBe('atomantic');- });-- it('returns null for non-github hosts', () => {- expect(parseGitHubOwnerFromRemote('[email protected]:foo/bar.git')).toBeNull();- expect(parseGitHubOwnerFromRemote('https://bitbucket.org/foo/bar')).toBeNull();- });-- it('returns null for empty or malformed input', () => {- expect(parseGitHubOwnerFromRemote('')).toBeNull();- expect(parseGitHubOwnerFromRemote(null)).toBeNull();- expect(parseGitHubOwnerFromRemote('[email protected]:noslash')).toBeNull();- });-});--describe('detectForgeCli', () => {- it('routes github.com to gh', () => {- expect(detectForgeCli('github.com')).toBe('gh');- });-- it('routes gitlab.com and self-hosted gitlab to glab', () => {- expect(detectForgeCli('gitlab.com')).toBe('glab');- expect(detectForgeCli('gitlab.example.com')).toBe('glab');- expect(detectForgeCli('GitLab.Internal.Co')).toBe('glab');- });-- it('defaults to gh for unknown non-empty hosts, returns unknown for falsy hosts', () => {- expect(detectForgeCli('bitbucket.org')).toBe('gh');- expect(detectForgeCli(null)).toBe('unknown');- expect(detectForgeCli(undefined)).toBe('unknown');- expect(detectForgeCli('')).toBe('unknown');- });-});--describe('pickGhAccountForOwner', () => {- it('matches owner to account case-insensitively', () => {- expect(pickGhAccountForOwner('atomantic', ['atomantic', 'ClawedCode'])).toBe('atomantic');- expect(pickGhAccountForOwner('Atomantic', ['atomantic', 'ClawedCode'])).toBe('atomantic');- expect(pickGhAccountForOwner('clawedcode', ['atomantic', 'ClawedCode'])).toBe('ClawedCode');- expect(pickGhAccountForOwner('CLAWEDCODE', ['atomantic', 'ClawedCode'])).toBe('ClawedCode');- });-- it('returns null when no account matches the owner', () => {- expect(pickGhAccountForOwner('someorg', ['atomantic', 'ClawedCode'])).toBeNull();- });-- it('returns null with empty inputs', () => {- expect(pickGhAccountForOwner('atomantic', [])).toBeNull();- expect(pickGhAccountForOwner('atomantic', null)).toBeNull();- expect(pickGhAccountForOwner(null, ['atomantic'])).toBeNull();- expect(pickGhAccountForOwner('', ['atomantic'])).toBeNull();- });-});+import { createPR, extractAgentSummary, requestCopilotReview } from './git.js';describe('createPR', () => {beforeEach(() => {@@ -116,77 +33,6 @@ describe('createPR', () => {});});-describe('parsePullRequestUrl', () => {- it('parses GitHub PR URLs', () => {- expect(parsePullRequestUrl('https://github.com/atomantic/PortOS/pull/185')).toEqual({- host: 'github.com', owner: 'atomantic', repo: 'PortOS', number: 185- });- expect(parsePullRequestUrl('http://github.example.com/org/repo/pull/1')).toEqual({- host: 'github.example.com', owner: 'org', repo: 'repo', number: 1- });- });-- it('parses GitLab MR URLs', () => {- expect(parsePullRequestUrl('https://gitlab.com/group/project/-/merge_requests/42')).toEqual({- host: 'gitlab.com', owner: 'group', repo: 'project', number: 42- });- });-- it('parses GitLab MR URLs with subgroups (owner = full group path)', () => {- expect(parsePullRequestUrl('https://gitlab.com/group/subgroup/project/-/merge_requests/7')).toEqual({- host: 'gitlab.com', owner: 'group/subgroup', repo: 'project', number: 7- });- expect(parsePullRequestUrl('https://gitlab.example.com/g1/g2/g3/proj/-/merge_requests/100')).toEqual({- host: 'gitlab.example.com', owner: 'g1/g2/g3', repo: 'proj', number: 100- });- });-- it('tolerates trailing path segments and query/hash fragments', () => {- expect(parsePullRequestUrl('https://github.com/atomantic/PortOS/pull/186/files')).toEqual({- host: 'github.com', owner: 'atomantic', repo: 'PortOS', number: 186- });- expect(parsePullRequestUrl('https://github.com/atomantic/PortOS/pull/186/commits/abc')).toEqual({- host: 'github.com', owner: 'atomantic', repo: 'PortOS', number: 186- });- expect(parsePullRequestUrl('https://github.com/atomantic/PortOS/pull/186?diff=split')).toEqual({- host: 'github.com', owner: 'atomantic', repo: 'PortOS', number: 186- });- expect(parsePullRequestUrl('https://gitlab.com/group/sub/proj/-/merge_requests/9/diffs')).toEqual({- host: 'gitlab.com', owner: 'group/sub', repo: 'proj', number: 9- });- });-- it('returns null for invalid input', () => {- expect(parsePullRequestUrl(null)).toBeNull();- expect(parsePullRequestUrl('')).toBeNull();- expect(parsePullRequestUrl(undefined)).toBeNull();- expect(parsePullRequestUrl('https://github.com/atomantic/PortOS')).toBeNull();- expect(parsePullRequestUrl('not a url')).toBeNull();- expect(parsePullRequestUrl('https://github.com/atomantic/PortOS/pull/notanumber')).toBeNull();- expect(parsePullRequestUrl('https://github.com/atomantic/PortOS/pull/0')).toBeNull();- });-- it('rejects GitHub URLs with extra path segments before /pull/ (no silent mis-parse)', () => {- // GitHub PR URLs are strictly /<owner>/<repo>/pull/<n>. Anything with extra- // segments before `pull` (e.g. /owner/repo/extra/pull/1) is invalid; we must- // return null rather than silently picking the wrong segment as `repo`.- expect(parsePullRequestUrl('https://github.com/owner/repo/extra/pull/1')).toBeNull();- expect(parsePullRequestUrl('https://github.com/owner/repo/extra/more/pull/1')).toBeNull();- });-- it('rejects non-http(s) protocols, empty hosts, and explicit ports', () => {- // file:// has an empty host — would yield host="" and route gh to nowhere.- expect(parsePullRequestUrl('file:///atomantic/PortOS/pull/1')).toBeNull();- // Other non-web schemes are never valid PR URLs.- expect(parsePullRequestUrl('ftp://github.com/atomantic/PortOS/pull/1')).toBeNull();- expect(parsePullRequestUrl('javascript:alert(1)')).toBeNull();- // Custom ports get silently dropped by `parsed.hostname`; reject so we- // don't target the wrong server.- expect(parsePullRequestUrl('https://github.com:8443/atomantic/PortOS/pull/1')).toBeNull();- expect(parsePullRequestUrl('http://gitlab.example.com:9000/group/proj/-/merge_requests/1')).toBeNull();- });-});-describe('requestCopilotReview', () => {it('returns structured failure for unparseable URL without invoking gh', async () => {const result = await requestCopilotReview('/nonexistent-path-for-test', 'not a url');@@ -282,6 +128,10 @@ describe('extractAgentSummary', () => {describe('git.js exports the helpers the agent resume path calls', () => {it('exposes every function agentWorktreeCleanup.resolveResumePointer uses', async () => {const git = await vi.importActual('./git.js');+ const gitForge = await vi.importActual('../lib/gitForge.js');+ for (const name of ['parseGitRemote', 'parseGitHubOwnerFromRemote', 'pickGhAccountForOwner', 'detectForgeCli', 'parsePullRequestUrl']) {+ expect(git[name], `git.${name} must re-export gitForge.${name}`).toBe(gitForge[name]);+ }expect(git.isBranchMergedInto).toBe(git.hasBranchMergeEvidence);for (const name of ['getBranch', 'getStatusPorcelain', 'getBranchComparison',