} // hacky: figure out the blob oid of the file above var blobOid string blobOid, err = util.HashBlob(repo, contents) if err != nil { return fmt.Errorf("could not figure out blob oid: %s", err) } tagName := "0.0.0" branchName := "brooklyn" // create a single commit err = util.GitExecMany(repo, []string{"add", "--all"}, []string{"commit", "-a", "-m", "\"First and only commit\""}, []string{"tag", "-a", tagName, "-m", "\"My tag!\""}, []string{"branch", branchName}, ) if err != nil { return fmt.Errorf("could not commit to repo: %s", err) } // get the output data info := &InfoDerefs{ TagName: tagName, BranchName: branchName, CommitOid: util.RevOid(repo, "HEAD"), TreeOid: util.RevOid(repo, "HEAD^{tree}"), TagOid: util.RevOid(repo, tagName), BlobOid: blobOid, ObjectsN: 4,
for i := 0; i < n; i++ { name := fmt.Sprintf("%d.txt", i) err = util.TestFile(repo, name, string(i)) if err != nil { return errors.New("could not create test file for repo: " + err.Error()) } var ( branchName = fmt.Sprintf("branch_%d", i) tagName = fmt.Sprintf("tag_%d", i) commitMsg = fmt.Sprintf("\"Commit: %d\"", i) ) // create a commits err = util.GitExecMany(repo, []string{"add", "--all"}, []string{"commit", "-a", "-m", commitMsg}, []string{"branch", branchName}, []string{"tag", "-a", tagName, "-m", commitMsg}, ) if err != nil { return fmt.Errorf("could not commit to repo: %s", err) } // get the output data var ( parentOid = "" oid = util.RevOid(repo, "HEAD") tagOid = util.RevOid(repo, tagName) ) if i != 0 { parentOid = util.RevOid(repo, "HEAD^") }
symbolicRef1 = "symbolic1" symbolicRef2 = "symbolic2" ) // create a single commit err = util.GitExecMany(repo, // add a commit, the one and only []string{"add", "--all"}, []string{"commit", "-a", "-m", "\"First and only commit\""}, // add an annotated and lightweight tag []string{"tag", "-a", annTagName, "-m", "\"My tag!\""}, []string{"tag", lightTagName}, // add a branch pointing to master []string{"branch", branchName}, // add a symbolic ref, 1 level deep []string{"symbolic-ref", symbolicRef1, "refs/heads/" + branchName}, // add a symbolic ref, 2 levels deep []string{"symbolic-ref", symbolicRef2, symbolicRef1}, // pack the refs []string{"pack-refs"}, ) if err != nil { return err } // get the output data
// ================================================================= // // TEST CASE: BUNCHES OF BLOBS // ================================================================= // type InfoLinearPacked struct { InfoLinear } var LinearPacked = NewRepoTestCase( "__linear_packed", func(testCase *RepoTestCase) error { err := Linear.builder(testCase) if err != nil { return err } // pack all that shit and remove loose shit err = util.GitExecMany(testCase.Repo(), []string{"repack", "-a"}, []string{"prune-packed"}, ) testCase.info = &InfoLinearPacked{ *testCase.info.(*InfoLinear), } return err }, )