summaryrefslogtreecommitdiff
path: root/rebase_test.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-12-16 17:50:57 -0600
committerJeff Carr <[email protected]>2024-12-16 17:50:57 -0600
commit530f3618a8f4c7d9c8d3981548112439b22e09e7 (patch)
tree30b529a83767648dd31c8bfa6fff6b6163174909 /rebase_test.go
parente65b1c188ccb9b4aa4863ec702c3985c382f53db (diff)
update to libgit2 version 1.8.4. dump old github and vendor stuff
go install go.wit.com/apps/go-clone@latest go install go.wit.com/apps/go-mod-clean@latest go-clone --recusive go.wit.com/lib/git2go Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'rebase_test.go')
-rw-r--r--rebase_test.go90
1 files changed, 45 insertions, 45 deletions
diff --git a/rebase_test.go b/rebase_test.go
index efe93cf..9c1b85e 100644
--- a/rebase_test.go
+++ b/rebase_test.go
@@ -19,73 +19,73 @@ func TestRebaseInMemoryWithConflict(t *testing.T) {
defer cleanupTestRepo(t, repo)
seedTestRepo(t, repo)
- // Create two branches with common history, where both modify "common-file"
- // in a conflicting way.
- _, err := commitSomething(repo, "common-file", "a\nb\nc\n", commitOptions{})
- checkFatal(t, err)
+ // Create two branches with common history, where both modify "common-file"
+ // in a conflicting way.
+ _, err := commitSomething(repo, "common-file", "a\nb\nc\n", commitOptions{})
+ checkFatal(t, err)
checkFatal(t, createBranch(repo, "branch-a"))
checkFatal(t, createBranch(repo, "branch-b"))
checkFatal(t, repo.SetHead("refs/heads/branch-a"))
- _, err = commitSomething(repo, "common-file", "1\nb\nc\n", commitOptions{})
- checkFatal(t, err)
+ _, err = commitSomething(repo, "common-file", "1\nb\nc\n", commitOptions{})
+ checkFatal(t, err)
checkFatal(t, repo.SetHead("refs/heads/branch-b"))
- _, err = commitSomething(repo, "common-file", "x\nb\nc\n", commitOptions{})
- checkFatal(t, err)
+ _, err = commitSomething(repo, "common-file", "x\nb\nc\n", commitOptions{})
+ checkFatal(t, err)
branchA, err := repo.LookupBranch("branch-a", BranchLocal)
- checkFatal(t, err)
+ checkFatal(t, err)
onto, err := repo.AnnotatedCommitFromRef(branchA.Reference)
- checkFatal(t, err)
+ checkFatal(t, err)
- // We then rebase "branch-b" onto "branch-a" in-memory, which should result
- // in a conflict.
- rebase, err := repo.InitRebase(nil, nil, onto, &RebaseOptions{InMemory: 1})
- checkFatal(t, err)
+ // We then rebase "branch-b" onto "branch-a" in-memory, which should result
+ // in a conflict.
+ rebase, err := repo.InitRebase(nil, nil, onto, &RebaseOptions{InMemory: 1})
+ checkFatal(t, err)
- _, err = rebase.Next()
+ _, err = rebase.Next()
checkFatal(t, err)
- index, err := rebase.InmemoryIndex()
+ index, err := rebase.InmemoryIndex()
checkFatal(t, err)
- // We simply resolve the conflict and commit the rebase.
- if !index.HasConflicts() {
- t.Fatal("expected index to have conflicts")
- }
+ // We simply resolve the conflict and commit the rebase.
+ if !index.HasConflicts() {
+ t.Fatal("expected index to have conflicts")
+ }
- conflict, err := index.Conflict("common-file")
- checkFatal(t, err)
+ conflict, err := index.Conflict("common-file")
+ checkFatal(t, err)
- resolvedBlobID, err := repo.CreateBlobFromBuffer([]byte("resolved contents"))
- checkFatal(t, err)
+ resolvedBlobID, err := repo.CreateBlobFromBuffer([]byte("resolved contents"))
+ checkFatal(t, err)
- resolvedEntry := *conflict.Our
- resolvedEntry.Id = resolvedBlobID
- checkFatal(t, index.Add(&resolvedEntry))
- checkFatal(t, index.RemoveConflict("common-file"))
+ resolvedEntry := *conflict.Our
+ resolvedEntry.Id = resolvedBlobID
+ checkFatal(t, index.Add(&resolvedEntry))
+ checkFatal(t, index.RemoveConflict("common-file"))
- var commitID Oid
- checkFatal(t, rebase.Commit(&commitID, signature(), signature(), "rebased message"))
- checkFatal(t, rebase.Finish())
+ var commitID Oid
+ checkFatal(t, rebase.Commit(&commitID, signature(), signature(), "rebased message"))
+ checkFatal(t, rebase.Finish())
- // And then assert that we can look up the new merge commit, and that the
- // "common-file" has the expected contents.
- commit, err := repo.LookupCommit(&commitID)
- checkFatal(t, err)
- if commit.Message() != "rebased message" {
- t.Fatalf("unexpected commit message %q", commit.Message())
- }
+ // And then assert that we can look up the new merge commit, and that the
+ // "common-file" has the expected contents.
+ commit, err := repo.LookupCommit(&commitID)
+ checkFatal(t, err)
+ if commit.Message() != "rebased message" {
+ t.Fatalf("unexpected commit message %q", commit.Message())
+ }
- tree, err := commit.Tree()
- checkFatal(t, err)
+ tree, err := commit.Tree()
+ checkFatal(t, err)
- blob, err := repo.LookupBlob(tree.EntryByName("common-file").Id)
- checkFatal(t, err)
- if string(blob.Contents()) != "resolved contents" {
- t.Fatalf("unexpected resolved blob contents %q", string(blob.Contents()))
- }
+ blob, err := repo.LookupBlob(tree.EntryByName("common-file").Id)
+ checkFatal(t, err)
+ if string(blob.Contents()) != "resolved contents" {
+ t.Fatalf("unexpected resolved blob contents %q", string(blob.Contents()))
+ }
}
func TestRebaseAbort(t *testing.T) {