MCPcopy
hub / github.com/github/git-sizer / newGitBomb

Function newGitBomb

git_sizer_test.go:54–99  ·  view source on GitHub ↗
(t *testing.T, repo *testutils.TestRepo, depth, breadth int, body string)

Source from the content-addressed store, hash-verified

52}
53
54func 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.

Callers 1

TestBombFunction · 0.85

Calls 3

CreateObjectMethod · 0.80
UpdateRefMethod · 0.80
BytesMethod · 0.65

Tested by

no test coverage detected