package e2e import ( "os/exec" "strings" "testing" ) // Chapter 40.1 lists what a mirror clone takes, and a promise about leaving must be exact. func TestAMirrorCloneTakesEverythingChapter40Lists(t *testing.T) { if _, err := exec.LookPath("git"); err != nil { t.Skip("git is not installed") } in := newInstance(t) john := in.account("john") mark := in.account("mark") work := seed(t, in, john, "john", "johnbot") run(t, work, "git", "tag", "-a", "v1.0.0", "-m", "the first release") run(t, work, "git", "push", "-q", in.url(john, "/john/johnbot"), "v1.0.0") // A proposal, then a rewrite of it, so there is a retained revision to take as well. mine := clone(t, in, mark, "/john/johnbot") commit(t, mine, "package main\n\nfunc main() {}\n", "a first attempt") run(t, mine, "git", "push", "-q", in.url(mark, "/john/johnbot"), "HEAD:refs/proposals/new") commit(t, mine, "package main\n\nfunc main() { println(1) }\n", "a second attempt") run(t, mine, "git", "push", "-q", "-f", in.url(mark, "/john/johnbot"), "HEAD:refs/proposals/1") // A build result, because chapter 40.1 promises those come too and they live in a note. sha := strings.TrimSpace(run(t, work, "git", "rev-parse", "HEAD")) passRun(t, in, "john", "john/johnbot", sha, "build") away := t.TempDir() run(t, away, "git", "clone", "--mirror", "-q", in.url(john, "/john/johnbot"), "johnbot.git") took := run(t, away+"/johnbot.git", "git", "for-each-ref", "--format=%(refname)") // Every kind chapter 40.1 names, and the revisions comments are anchored to. 43.5. for _, want := range []string{ "refs/heads/master", "refs/tags/v1.0.0", "refs/proposals/1", "refs/notes/threads/1", "refs/revisions/1/", "refs/notes/runs", } { if !strings.Contains(took, want) { t.Errorf("a mirror clone left %s behind:\n%s", want, took) } } }