(t *testing.T, repo *testutils.TestRepo, depth, breadth int, body string)
| 52 | } |
| 53 | |
| 54 | func newGitBomb(t *testing.T, repo *testutils.TestRepo, depth, breadth int, body string) { |
| 55 | t.Helper() |
| 56 | |
| 57 | oid := repo.CreateObject(t, "blob", func(w io.Writer) error { |
| 58 | _, err := io.WriteString(w, body) |
| 59 | return err |
| 60 | }) |
| 61 | |
| 62 | digits := len(fmt.Sprintf("%d", breadth-1)) |
| 63 | |
| 64 | mode := "100644" |
| 65 | prefix := "f" |
| 66 | |
| 67 | for ; depth > 0; depth-- { |
| 68 | oid = repo.CreateObject(t, "tree", func(w io.Writer) error { |
| 69 | for i := 0; i < breadth; i++ { |
| 70 | _, err := fmt.Fprintf( |
| 71 | w, "%s %s%0*d\x00%s", |
| 72 | mode, prefix, digits, i, oid.Bytes(), |
| 73 | ) |
| 74 | if err != nil { |
| 75 | return err |
| 76 | } |
| 77 | } |
| 78 | return nil |
| 79 | }) |
| 80 | |
| 81 | mode = "40000" |
| 82 | prefix = "d" |
| 83 | } |
| 84 | |
| 85 | oid = repo.CreateObject(t, "commit", func(w io.Writer) error { |
| 86 | _, err := fmt.Fprintf( |
| 87 | w, |
| 88 | "tree %s\n"+ |
| 89 | "author Example <example@example.com> 1112911993 -0700\n"+ |
| 90 | "committer Example <example@example.com> 1112911993 -0700\n"+ |
| 91 | "\n"+ |
| 92 | "Test git bomb\n", |
| 93 | oid, |
| 94 | ) |
| 95 | return err |
| 96 | }) |
| 97 | |
| 98 | repo.UpdateRef(t, "refs/heads/master", oid) |
| 99 | } |
| 100 | |
| 101 | // TestRefSelections tests various combinations of reference selection |
| 102 | // options. |
no test coverage detected