<commit_before>import { setupEmptyRepository } from '../../helpers/repositories'
import { listWorktrees } from '../../../src/lib/git/worktree'

describe('git/worktree', () => {
  describe('list', () => {
    describe('for an unborn repository', () => {
      it('returns one entry', async () => {
        const repository = await setupEmptyRepository()
        const result = await listWorktrees(repository)
        expect(result).toHaveLength(1)
      })

      it('contains the head and path of the main repository', async () => {
        const repository = await setupEmptyRepository()
        const { path } = repository
        const result = await listWorktrees(repository)
        const first = result[0]
        expect(first.head).toBe('0000000000000000000000000000000000000000')

        // You might be wondering why this isn't a `.toBe` comparsion.
        // Well, on macOS the path emitted by Git may start with a `/private`
        // which is super-annoying and also different to what NodeJS returns,
        // so we need to manage and reconcile these two cases
        const endsWith = first.path.endsWith(path)
        expect(endsWith).toBe(true)
      })
    })
  })
})
<commit_msg>add test for another case<commit_after>import { setupEmptyRepository } from '../../helpers/repositories'
import { listWorktrees } from '../../../src/lib/git/worktree'
import { Repository } from '../../../src/models/repository'
import { GitProcess } from 'dugite'

describe('git/worktree', () => {
  describe('list', () => {
    describe('for an unborn repository', () => {
      let repository: Repository

      beforeEach(async () => {
        repository = await setupEmptyRepository()
      })

      it('returns one entry', async () => {
        const result = await listWorktrees(repository)
        expect(result).toHaveLength(1)
      })

      it('contains the head and path of the main repository', async () => {
        const { path } = repository
        const result = await listWorktrees(repository)
        const first = result[0]
        expect(first.head).toBe('0000000000000000000000000000000000000000')

        // You might be wondering why this isn't a `.toBe` comparsion.
        // Well, on macOS the path emitted by Git may start with a `/private`
        // which is super-annoying and also different to what NodeJS returns,
        // so we need to manage and reconcile these two cases
        const endsWith = first.path.endsWith(path)
        expect(endsWith).toBe(true)
      })
    })

    describe('for a repository containing commits', () => {
      let repository: Repository
      let currentHeadSha: string

      beforeEach(async () => {
        repository = await setupEmptyRepository()
        await GitProcess.exec(
          ['commit', '--allow-empty', '-m', '"first commit!"'],
          repository.path
        )
        await GitProcess.exec(
          ['commit', '--allow-empty', '-m', '"second commit!"'],
          repository.path
        )

        const result = await GitProcess.exec(
          ['rev-parse', 'HEAD'],
          repository.path
        )
        currentHeadSha = result.stdout.trim()
      })

      it('the head points to the right commit', async () => {
        const result = await listWorktrees(repository)
        const first = result[0]
        expect(first.head).toBe(currentHeadSha)
      })
    })
  })
})

{'fraction_non_alphanumeric': 0.12810650887573966, 'fraction_numerical': 0.02514792899408284, 'mean_word_length': 2.439471007121058, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3726471', 'n_tokens_mistral': 972, 'n_tokens_neox': 876, 'n_words': 265}