| 1 | # go-git-fixtures [](https://pkg.go.dev/github.com/go-git/go-git-fixtures/v6) [](https://github.com/go-git/go-git-fixtures/actions?query=workflow%3ATest) [](https://scorecard.dev/viewer/?uri=github.com/go-git/go-git-fixtures) |
| 2 | |
| 3 | git repository fixtures used by [go-git](https://github.com/go-git/go-git) |
| 4 | |
| 5 | ## Adding new Fixtures |
| 6 | |
| 7 | ### Adding new pack fixtures |
| 8 | |
| 9 | 1. Get the `.idx`, `.rev` and `.pack` files from the repository: |
| 10 | |
| 11 | ```sh |
| 12 | git clone https://<repository> |
| 13 | cd <repository_name> |
| 14 | git checkout <REF> |
| 15 | git gc |
| 16 | |
| 17 | ls .git/objects/pack/ |
| 18 | ``` |
| 19 | |
| 20 | 2. Copy them into `/data`. |
| 21 | 3. Add a new entry in `fixtures.go`: |
| 22 | |
| 23 | ``` |
| 24 | { |
| 25 | Tags: []string{"packfile", "<TAG_TO_REFER_TO>"}, |
| 26 | PackfileHash: "<PACK_HASH>", |
| 27 | } |
| 28 | ``` |
| 29 | |
| 30 | ### Adding new dot fixtures |
| 31 | |
| 32 | 1. Tarball the contents of .git from a git repository: |
| 33 | |
| 34 | ```sh |
| 35 | git clone https://<repository> |
| 36 | cd <repository_name> |
| 37 | git checkout <REF> |
| 38 | git gc |
| 39 | |
| 40 | tar -czf git.tgz -C .git . |
| 41 | ``` |
| 42 | |
| 43 | 2. Get the sha1/sha256 of the file: `sha1sum < git.tgz`. |
| 44 | 3. Move the file using the checksum to `data/git-<checksum>.tgz` |
| 45 | 4. Add a new entry in `fixtures.go`: |
| 46 | |
| 47 | ``` |
| 48 | { |
| 49 | Tags: []string{".git", "<TAG_TO_REFER_TO>"}, |
| 50 | DotGitHash: "<GIT_TAR_HASH>", |
| 51 | } |
| 52 | ``` |
| 53 | |
| 54 | |
| 55 | |
| 56 | ### Adding new worktree fixtures |
| 57 | |
| 58 | 1. Tarball the contents of the cloned repository: |
| 59 | |
| 60 | ```sh |
| 61 | git clone https://<repository> <repository_name> |
| 62 | |
| 63 | tar -czf worktree.tgz -C <repository_name> . |
| 64 | ``` |
| 65 | |
| 66 | 2. Get the sha1/sha256 of the file: `sha256sum < worktree.tgz`. |
| 67 | 3. Move the file using the checksum to `data/worktree-<checksum>.tgz` |
| 68 | 4. Add a new entry in `fixtures.go`: |
| 69 | |
| 70 | ``` |
| 71 | { |
| 72 | Tags: []string{"worktree", "<TAG_TO_REFER_TO>"}, |
| 73 | WorktreeHash: "<WORKTREE_TAR_HASH>", |
| 74 | } |
| 75 | ``` |