-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
407 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright 2024 Aviator Technologies, Inc. | ||
// SPDX-License-Identifier: MIT | ||
|
||
package cmd | ||
|
||
import ( | ||
"net/http" | ||
|
||
nichegit "github.com/aviator-co/niche-git" | ||
) | ||
|
||
func SquashPush(args nichegit.SquashPushArgs) nichegit.SquashPushOutput { | ||
client := &http.Client{Transport: &authnRoundtripper{}} | ||
return nichegit.SquashPush(client, args) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
// Copyright 2024 Aviator Technologies, Inc. | ||
// SPDX-License-Identifier: MIT | ||
|
||
package e2e_tests | ||
|
||
import ( | ||
"testing" | ||
|
||
nichegit "github.com/aviator-co/niche-git" | ||
"github.com/aviator-co/niche-git/cmd" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestSquashCherryPick_Resolve_Conflict(t *testing.T) { | ||
repo := NewTempRepo(t) | ||
|
||
baseHash := repo.CommitFile(t, "file1", ` | ||
def foo(): | ||
return 1 | ||
def bar(): | ||
return 1 | ||
def baz(): | ||
return 1 | ||
`) | ||
|
||
repo.Git(t, "checkout", "main", "-b", "feature1") | ||
feature1Hash := repo.CommitFile(t, "file1", ` | ||
def foo(): | ||
return 1 | ||
def bar(): | ||
return 2 | ||
def baz(): | ||
return 1 | ||
`) | ||
|
||
repo.Git(t, "checkout", "main", "-b", "feature2") | ||
feature2Hash := repo.CommitFile(t, "file1", ` | ||
def foo(): | ||
return 1 | ||
def bar(): | ||
return 1 | ||
def baz(): | ||
return 2 | ||
`) | ||
|
||
repo.Git(t, "checkout", "main") | ||
baseHash2 := repo.CommitFile(t, "file1", ` | ||
def foo(): | ||
return 2 | ||
def bar(): | ||
return 1 | ||
def baz(): | ||
return 1 | ||
`) | ||
|
||
output := cmd.SquashPush( | ||
nichegit.SquashPushArgs{ | ||
RepoURL: "file://" + repo.RepoDir, | ||
BaseCommitHash: baseHash2.String(), | ||
SquashCommands: []nichegit.SquashCommand{ | ||
{ | ||
CommitHashStart: baseHash.String(), | ||
CommitHashEnd: feature1Hash.String(), | ||
CommitMessage: "feature1", | ||
Committer: "aviator-bot", | ||
CommitterEmail: "aviator-bot@nonexistent", | ||
CommitterTime: "2024-08-22T00:00:00Z", | ||
Author: "aviator-bot", | ||
AuthorEmail: "aviator-bot@nonexistent", | ||
AuthorTime: "2024-08-22T00:00:00Z", | ||
}, | ||
{ | ||
CommitHashStart: baseHash.String(), | ||
CommitHashEnd: feature2Hash.String(), | ||
CommitMessage: "feature2", | ||
Committer: "aviator-bot", | ||
CommitterEmail: "aviator-bot@nonexistent", | ||
CommitterTime: "2024-08-22T00:00:00Z", | ||
Author: "aviator-bot", | ||
AuthorEmail: "aviator-bot@nonexistent", | ||
AuthorTime: "2024-08-22T00:00:00Z", | ||
}, | ||
}, | ||
Ref: "refs/heads/mq-tmp-branch", | ||
CurrentRefHash: "", | ||
}, | ||
) | ||
require.Equal(t, "", output.Error) | ||
require.Equal(t, 2, len(output.CommandResults)) | ||
|
||
repo.Git(t, "checkout", "mq-tmp-branch") | ||
require.Equal(t, ` | ||
def foo(): | ||
return 2 | ||
def bar(): | ||
return 2 | ||
def baz(): | ||
return 2 | ||
` + "\n", | ||
repo.ReadFile(t, "file1")) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.