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

Method CreateReferencedOrphan

internal/testutils/repoutils.go:238–265  ·  view source on GitHub ↗

CreateReferencedOrphan creates a simple new orphan commit and points the reference with name `refname` at it. This can be run in a bare or non-bare repository.

(t *testing.T, refname string)

Source from the content-addressed store, hash-verified

236// points the reference with name `refname` at it. This can be run in
237// a bare or non-bare repository.
238func (repo *TestRepo) CreateReferencedOrphan(t *testing.T, refname string) {
239 t.Helper()
240
241 oid := repo.CreateObject(t, "blob", func(w io.Writer) error {
242 _, err := fmt.Fprintf(w, "%s\n", refname)
243 return err
244 })
245
246 oid = repo.CreateObject(t, "tree", func(w io.Writer) error {
247 _, err := fmt.Fprintf(w, "100644 a.txt\x00%s", oid.Bytes())
248 return err
249 })
250
251 oid = repo.CreateObject(t, "commit", func(w io.Writer) error {
252 _, err := fmt.Fprintf(
253 w,
254 "tree %s\n"+
255 "author Example <example@example.com> 1112911993 -0700\n"+
256 "committer Example <example@example.com> 1112911993 -0700\n"+
257 "\n"+
258 "Commit for reference %s\n",
259 oid, refname,
260 )
261 return err
262 })
263
264 repo.UpdateRef(t, refname, oid)
265}
266
267// AddAuthorInfo adds environment variables to `cmd.Env` that set the
268// Git author and committer to known values and set the timestamp to

Callers 2

TestRefSelectionsFunction · 0.95
TestRefgroupsFunction · 0.95

Calls 3

CreateObjectMethod · 0.95
UpdateRefMethod · 0.95
BytesMethod · 0.65

Tested by 2

TestRefSelectionsFunction · 0.76
TestRefgroupsFunction · 0.76