package thin import ( "context" "os" "os/exec" "path/filepath" "testing" "time" "amadan.net/oficina/equipo/internal/wire" ) // TestEmptyRepoFixRoundPublishes: in a repository with no commits, the // first round pushes the task branch's initial commit, and a fix round // (its base the task branch's tip, the default branch still unborn) // pushes again as a fast-forward of that tip (the remote refuses any // other), with no push_failed; the default branch stays unborn. func TestEmptyRepoFixRoundPublishes(t *testing.T) { old := pushBackoff pushBackoff = time.Millisecond t.Cleanup(func() { pushBackoff = old }) e, f, r, _ := hubRig(t) dir := filepath.Dir(f.dir) // An empty repository: no refs at all, HEAD naming an unborn main, // and only fast-forwards accepted. empty := filepath.Join(dir, "empty.git") gitOut(t, dir, "init", "-q", "--bare", "-b", "main", empty) gitOut(t, dir, "--git-dir="+empty, "config", "receive.denyNonFastForwards", "true") f.dir = empty r.Specialist, r.Branch = wire.SpecialistEngineering, "equipo/tk1-salon" work := filepath.Join(dir, "salon") os.MkdirAll(work, 0700) commit := func(gitDir, file, text string, parents ...string) string { env := []string{"--git-dir=" + gitDir, "--work-tree=" + work} os.WriteFile(filepath.Join(work, file), []byte(text), 0600) gitOut(t, work, append(env, "add", "-A")...) tree := gitOut(t, work, append(env, "write-tree")...) args := append(env, "commit-tree", tree, "-m", file) for _, p := range parents { args = append(args, "-p", p) } return gitOut(t, work, args...) } // Round 1: no base, the repository's initial commit. r1 := r r1.StepID, r1.Base = "s1", "" git1 := e.tree(r1, "").GitDir gitOut(t, dir, "init", "-q", "--bare", git1) r1.Candidate = commit(git1, "index.html", "