-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(stack branch-commit): Differentiate -a/-A flags (#133)
Fixes #129. Technically (but not practically) breaking: `--all` is now equivalent to `av stack branch-commit -A` (before it was equivalent to `-a`).
- Loading branch information
Showing
3 changed files
with
83 additions
and
4 deletions.
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,43 @@ | ||
package e2e_tests | ||
|
||
import ( | ||
"github.com/aviator-co/av/internal/git" | ||
"github.com/aviator-co/av/internal/git/gittest" | ||
"github.com/stretchr/testify/require" | ||
"os" | ||
"testing" | ||
) | ||
|
||
func TestStackBranchCommit(t *testing.T) { | ||
repo := gittest.NewTempRepo(t) | ||
Chdir(t, repo.Dir()) | ||
|
||
t.Run("FlagAll", func(t *testing.T) { | ||
require.NoError(t, os.WriteFile("myfile.txt", []byte("hello\n"), 0644)) | ||
RequireAv(t, "stack", "branch-commit", "--all", "-m", "branch one") | ||
clean, err := repo.CheckCleanWorkdir() | ||
require.NoError(t, err) | ||
require.True(t, clean) | ||
}) | ||
|
||
t.Run("FlagAllModified", func(t *testing.T) { | ||
require.NoError(t, os.WriteFile("myfile.txt", []byte("hello\nworld\n"), 0644)) | ||
require.NoError(t, os.WriteFile("yourfile.txt", []byte("bonjour\n"), 0644)) | ||
RequireAv(t, "stack", "branch-commit", "--all-modified", "-m", "branch two") | ||
|
||
clean, err := repo.CheckCleanWorkdir() | ||
require.NoError(t, err) | ||
require.False(t, clean, "workdir should not be clean since yourfile.txt should not be committed") | ||
|
||
diff, err := repo.Diff(&git.DiffOpts{ | ||
Quiet: true, | ||
Paths: []string{"myfile.txt"}, | ||
}) | ||
require.NoError(t, err) | ||
require.True(t, diff.Empty, "myfile.txt should be committed and not have a diff") | ||
|
||
lsout, err := repo.Git("ls-files", "yourfile.txt") | ||
require.NoError(t, err) | ||
require.Empty(t, lsout, "yourfile.txt should not be committed") | ||
}) | ||
} |
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