Skip to content

armgit / orca

Public Imported from GitHub
0

Orca is the place for working with a fleet of agents (e.g. Grok Bot, Claude Code). Run any coding agent with your own subscription. Available on desktop, mobile and remote runtime.

1.7 KB
Raw Blame
import { describe, expect, it } from 'vitest'
import { isSafeGitRefName, isSafeGitStatusUpstreamRef } from './git-status-upstream-ref'

describe('git status upstream refs', () => {
  it.each([
    'refs/heads/feature./valid',
    'refs/heads/feature./运动记录',
    'refs/remotes/origin./main'
  ])('accepts a trailing dot in an intermediate component: %s', (ref) => {
    expect(isSafeGitRefName(ref)).toBe(true)
  })

  it.each(['refs/heads/feature.', 'refs/heads/.hidden/valid', 'refs/heads/feature.lock/valid'])(
    'rejects an unsafe dot placement: %s',
    (ref) => {
      expect(isSafeGitRefName(ref)).toBe(false)
    }
  )

  it('accepts exact remote and custom upstream namespaces', () => {
    expect(isSafeGitStatusUpstreamRef('refs/remotes/team/fork/feature/nested')).toBe(true)
    expect(isSafeGitStatusUpstreamRef('refs/custom/origin/main')).toBe(true)
    expect(isSafeGitStatusUpstreamRef('refs/tracking/main')).toBe(true)
    expect(isSafeGitStatusUpstreamRef('refs/tracked-main')).toBe(true)
  })

  it('recognizes local branch refs without accepting them for dynamic status polling', () => {
    expect(isSafeGitRefName('refs/heads/feature/base')).toBe(true)
    expect(isSafeGitStatusUpstreamRef('refs/heads/feature/base')).toBe(false)
    expect(isSafeGitStatusUpstreamRef('refs/worktree/feature/base')).toBe(false)
  })

  it.each([
    'refs/heads/main',
    '/refs/remotes/origin/main',
    'refs/remotes/origin/../main',
    'refs/remotes/origin/main.lock',
    'refs/remotes/origin/feature\\escape',
    'refs/remotes/origin/@{upstream}'
  ])('rejects unsafe or non-remote ref %s', (ref) => {
    expect(isSafeGitStatusUpstreamRef(ref)).toBe(false)
  })
})