-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add BareRepoWorktreeConfig integration test
- Loading branch information
Showing
2 changed files
with
94 additions
and
0 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
93 changes: 93 additions & 0 deletions
93
pkg/integration/tests/worktree/bare_repo_worktree_config.go
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,93 @@ | ||
package worktree | ||
|
||
import ( | ||
"github.com/jesseduffield/lazygit/pkg/config" | ||
. "github.com/jesseduffield/lazygit/pkg/integration/components" | ||
) | ||
|
||
// This case is identical to dotfile_bare_repo.go, except | ||
// that it invokes lazygit with $GIT_DIR set but not | ||
// $GIT_WORK_TREE. Instead, the repo uses the core.worktree | ||
// config to identify the main worktre. | ||
|
||
var BareRepoWorktreeConfig = NewIntegrationTest(NewIntegrationTestArgs{ | ||
Description: "Open lazygit in the worktree of a vcsh-style bare repo and add a file and commit", | ||
ExtraCmdArgs: []string{"--git-dir={{.actualPath}}/.bare"}, | ||
Skip: false, | ||
// passing this because we're explicitly passing --git-dir and --work-tree args | ||
UseCustomPath: true, | ||
SetupConfig: func(config *config.AppConfig) {}, | ||
SetupRepo: func(shell *Shell) { | ||
// we're going to have a directory structure like this: | ||
// project | ||
// - .bare | ||
// - . (a worktree at the same path as .bare) | ||
// | ||
// | ||
// 'repo' is the repository/directory that all lazygit tests start in | ||
|
||
shell.CreateFileAndAdd("a/b/c/blah", "blah") | ||
shell.Commit("initial commit") | ||
|
||
shell.CreateFileAndAdd(".gitignore", ".bare/\n") | ||
shell.Commit("add .gitignore") | ||
|
||
shell.Chdir("..") | ||
|
||
// configure this "fake bare"" repo using the vcsh convention | ||
// of core.bare=false and core.worktree set to the actual | ||
// worktree path (a homedir root). This allows $GIT_DIR | ||
// alone to make this repo "self worktree identifying" | ||
shell.RunCommand([]string{"git", "--git-dir=./.bare", "init", "--shared=false"}) | ||
shell.RunCommand([]string{"git", "--git-dir=./.bare", "config", "core.bare", "false"}) | ||
shell.RunCommand([]string{"git", "--git-dir=./.bare", "config", "core.worktree", ".."}) | ||
shell.RunCommand([]string{"git", "--git-dir=./.bare", "remote", "add", "origin", "./repo"}) | ||
shell.RunCommand([]string{"git", "--git-dir=./.bare", "checkout", "-b", "main"}) | ||
shell.RunCommand([]string{"git", "--git-dir=./.bare", "config", "branch.main.remote", "origin"}) | ||
shell.RunCommand([]string{"git", "--git-dir=./.bare", "config", "branch.main.merge", "refs/heads/master"}) | ||
shell.RunCommand([]string{"git", "--git-dir=./.bare", "fetch", "origin", "master"}) | ||
shell.RunCommand([]string{"git", "--git-dir=./.bare", "-c", "merge.ff=true", "merge", "origin/master"}) | ||
|
||
// we no longer need the original repo so remove it | ||
shell.DeleteFile("repo") | ||
|
||
shell.UpdateFile("a/b/c/blah", "updated content\n") | ||
shell.Chdir("a/b/c") | ||
}, | ||
Run: func(t *TestDriver, keys config.KeybindingConfig) { | ||
t.Views().Branches(). | ||
Lines( | ||
Contains("main"), | ||
) | ||
|
||
t.Views().Commits(). | ||
Lines( | ||
Contains("add .gitignore"), | ||
Contains("initial commit"), | ||
) | ||
|
||
t.Views().Files(). | ||
IsFocused(). | ||
Lines( | ||
Contains(" a/b/c"), // shows as modified | ||
Contains(" M blah"), // shows as modified | ||
). | ||
PressPrimaryAction(). | ||
Press(keys.Files.CommitChanges) | ||
|
||
t.ExpectPopup().CommitMessagePanel(). | ||
Title(Equals("Commit summary")). | ||
Type("Add blah"). | ||
Confirm() | ||
|
||
t.Views().Files(). | ||
IsEmpty() | ||
|
||
t.Views().Commits(). | ||
Lines( | ||
Contains("Add blah"), | ||
Contains("add .gitignore"), | ||
Contains("initial commit"), | ||
) | ||
}, | ||
}) |