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.

2.3 KB
Raw Blame
import { execFileSync } from 'node:child_process'
import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs'
import { tmpdir } from 'node:os'
import { dirname, join, resolve } from 'node:path'
import { expect, it } from 'vitest'

const projectDir = resolve(import.meta.dirname, '../..')

it('keeps byte-compared artifacts and source LF in an autocrlf checkout', () => {
  const root = mkdtempSync(join(tmpdir(), 'orca-line-ending-checkout-'))
  const lf = 'first\nsecond\n'
  const crlf = 'first\r\nsecond\r\n'
  const paths = new Map([
    ['resources/skills/current-manifest.json', lf],
    ['src/main/__snapshots__/example.test.ts.snap', lf],
    ['src/renderer/src/example.tsx', lf],
    ['src/main/example.ts', lf],
    ['config/scripts/example.mjs', lf],
    ['config/scripts/nested/deeper/example.mjs', lf],
    ['skill-guides/example.md', lf],
    ['skill-stubs/example.md', lf],
    ['skill-stubs/_shared/example.md', lf],
    ['skills/example/SKILL.md', lf],
    ['src/cli/bundled-skill-guides.ts', lf],
    ...['cmd', 'bat', 'ps1', 'nsh'].map((extension) => [`config/example.${extension}`, crlf]),
    ['resources/skills-extra/example.json', crlf],
    ['vendor/resources/skills/example.json', crlf],
    ['scripts/example.mjs', crlf],
    ['config/scripts-extra/example.mjs', crlf],
    ['vendor/config/scripts/example.mjs', crlf],
    ['config/scripts/example.mjsx', crlf],
    ['src/main/runtime/__fixtures__/example.txt', crlf],
    ['src/main/daemon/__fixtures__/pty-transcripts/example.txt', crlf]
  ])
  const git = (args) => execFileSync('git', args, { cwd: root, stdio: 'pipe' })

  try {
    git(['init', '--quiet'])
    writeFileSync(join(root, '.gitattributes'), readFileSync(join(projectDir, '.gitattributes')))
    for (const path of paths.keys()) {
      mkdirSync(dirname(join(root, path)), { recursive: true })
      writeFileSync(join(root, path), path.includes('__fixtures__') ? crlf : lf)
    }
    git(['-c', 'core.autocrlf=input', 'add', '--', '.'])
    for (const path of paths.keys()) {
      rmSync(join(root, path))
    }
    git(['-c', 'core.autocrlf=true', 'checkout-index', '--all', '--force'])

    for (const [path, expected] of paths) {
      expect(readFileSync(join(root, path), 'utf8'), path).toBe(expected)
    }
  } finally {
    rmSync(root, { recursive: true, force: true })
  }
})