diff --git a/pkg/commands/git_commands/remote_loader.go b/pkg/commands/git_commands/remote_loader.go index 71dc41b80..1b0db49e0 100644 --- a/pkg/commands/git_commands/remote_loader.go +++ b/pkg/commands/git_commands/remote_loader.go @@ -45,7 +45,7 @@ func (self *RemoteLoader) GetRemotes() ([]*models.Remote, error) { remotes := slices.Map(goGitRemotes, func(goGitRemote *gogit.Remote) *models.Remote { remoteName := goGitRemote.Config().Name - re := regexp.MustCompile(fmt.Sprintf(`(?m)^\s*%s\/([\S]+)`, remoteName)) + re := regexp.MustCompile(fmt.Sprintf(`(?m)^\s*%s\/([\S]+)`, regexp.QuoteMeta(remoteName))) matches := re.FindAllStringSubmatch(remoteBranchesStr, -1) branches := slices.Map(matches, func(match []string) *models.RemoteBranch { return &models.RemoteBranch{ diff --git a/pkg/integration/components/shell.go b/pkg/integration/components/shell.go index 95b601783..409a17bc6 100644 --- a/pkg/integration/components/shell.go +++ b/pkg/integration/components/shell.go @@ -125,3 +125,8 @@ func (s *Shell) StashWithMessage(message string) *Shell { s.RunCommand(fmt.Sprintf(`git stash -m "%s"`, message)) return s } + +func (s *Shell) SetConfig(key string, value string) *Shell { + s.RunCommand(fmt.Sprintf(`git config --local "%s" %s`, key, value)) + return s +} diff --git a/pkg/integration/tests/config/remote_named_star.go b/pkg/integration/tests/config/remote_named_star.go new file mode 100644 index 000000000..3082c594f --- /dev/null +++ b/pkg/integration/tests/config/remote_named_star.go @@ -0,0 +1,26 @@ +package config + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var RemoteNamedStar = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Having a config remote.*", + ExtraCmdArgs: "", + Skip: false, + SetupRepo: func(shell *Shell) { + shell. + SetConfig("remote.*.prune", "true"). + CreateNCommits(2) + }, + SetupConfig: func(cfg *config.AppConfig) {}, + Run: func( + shell *Shell, + input *Input, + assert *Assert, + keys config.KeybindingConfig, + ) { + assert.AtLeastOneCommit() + }, +}) diff --git a/pkg/integration/tests/tests.go b/pkg/integration/tests/tests.go index 1ed99a47c..f097b032d 100644 --- a/pkg/integration/tests/tests.go +++ b/pkg/integration/tests/tests.go @@ -14,6 +14,7 @@ import ( "github.com/jesseduffield/lazygit/pkg/integration/tests/branch" "github.com/jesseduffield/lazygit/pkg/integration/tests/cherry_pick" "github.com/jesseduffield/lazygit/pkg/integration/tests/commit" + "github.com/jesseduffield/lazygit/pkg/integration/tests/config" "github.com/jesseduffield/lazygit/pkg/integration/tests/custom_commands" "github.com/jesseduffield/lazygit/pkg/integration/tests/file" "github.com/jesseduffield/lazygit/pkg/integration/tests/interactive_rebase" @@ -45,6 +46,7 @@ var tests = []*components.IntegrationTest{ stash.Rename, stash.Stash, stash.StashIncludingUntrackedFiles, + config.RemoteNamedStar, } func GetTests() []*components.IntegrationTest { diff --git a/test/integration_new/config/remote_named_star/expected/repo/.git_keep/COMMIT_EDITMSG b/test/integration_new/config/remote_named_star/expected/repo/.git_keep/COMMIT_EDITMSG new file mode 100644 index 000000000..4a78b0618 --- /dev/null +++ b/test/integration_new/config/remote_named_star/expected/repo/.git_keep/COMMIT_EDITMSG @@ -0,0 +1 @@ +commit 02 diff --git a/test/integration_new/config/remote_named_star/expected/repo/.git_keep/FETCH_HEAD b/test/integration_new/config/remote_named_star/expected/repo/.git_keep/FETCH_HEAD new file mode 100644 index 000000000..e69de29bb diff --git a/test/integration_new/config/remote_named_star/expected/repo/.git_keep/HEAD b/test/integration_new/config/remote_named_star/expected/repo/.git_keep/HEAD new file mode 100644 index 000000000..cb089cd89 --- /dev/null +++ b/test/integration_new/config/remote_named_star/expected/repo/.git_keep/HEAD @@ -0,0 +1 @@ +ref: refs/heads/master diff --git a/test/integration_new/config/remote_named_star/expected/repo/.git_keep/config b/test/integration_new/config/remote_named_star/expected/repo/.git_keep/config new file mode 100644 index 000000000..b485809ad --- /dev/null +++ b/test/integration_new/config/remote_named_star/expected/repo/.git_keep/config @@ -0,0 +1,14 @@ +[core] + repositoryformatversion = 0 + filemode = true + bare = false + logallrefupdates = true +[user] + email = CI@example.com + name = CI +[commit] + gpgSign = false +[protocol "file"] + allow = always +[remote "*"] + prune = true diff --git a/test/integration_new/config/remote_named_star/expected/repo/.git_keep/description b/test/integration_new/config/remote_named_star/expected/repo/.git_keep/description new file mode 100644 index 000000000..498b267a8 --- /dev/null +++ b/test/integration_new/config/remote_named_star/expected/repo/.git_keep/description @@ -0,0 +1 @@ +Unnamed repository; edit this file 'description' to name the repository. diff --git a/test/integration_new/config/remote_named_star/expected/repo/.git_keep/index b/test/integration_new/config/remote_named_star/expected/repo/.git_keep/index new file mode 100644 index 000000000..3931f762e Binary files /dev/null and b/test/integration_new/config/remote_named_star/expected/repo/.git_keep/index differ diff --git a/test/integration_new/config/remote_named_star/expected/repo/.git_keep/info/exclude b/test/integration_new/config/remote_named_star/expected/repo/.git_keep/info/exclude new file mode 100644 index 000000000..a5196d1be --- /dev/null +++ b/test/integration_new/config/remote_named_star/expected/repo/.git_keep/info/exclude @@ -0,0 +1,6 @@ +# git ls-files --others --exclude-from=.git/info/exclude +# Lines that start with '#' are comments. +# For a project mostly in C, the following would be a good set of +# exclude patterns (uncomment them if you want to use them): +# *.[oa] +# *~ diff --git a/test/integration_new/config/remote_named_star/expected/repo/.git_keep/logs/HEAD b/test/integration_new/config/remote_named_star/expected/repo/.git_keep/logs/HEAD new file mode 100644 index 000000000..d1a05666d --- /dev/null +++ b/test/integration_new/config/remote_named_star/expected/repo/.git_keep/logs/HEAD @@ -0,0 +1,2 @@ +0000000000000000000000000000000000000000 4fa4f5e427373ac4ac0a6e11ff97293649959859 CI 1669295719 +0000 commit (initial): commit 01 +4fa4f5e427373ac4ac0a6e11ff97293649959859 ddb8365ff4c367dbd7d49b965ab4b43c865b99cf CI 1669295719 +0000 commit: commit 02 diff --git a/test/integration_new/config/remote_named_star/expected/repo/.git_keep/logs/refs/heads/master b/test/integration_new/config/remote_named_star/expected/repo/.git_keep/logs/refs/heads/master new file mode 100644 index 000000000..d1a05666d --- /dev/null +++ b/test/integration_new/config/remote_named_star/expected/repo/.git_keep/logs/refs/heads/master @@ -0,0 +1,2 @@ +0000000000000000000000000000000000000000 4fa4f5e427373ac4ac0a6e11ff97293649959859 CI 1669295719 +0000 commit (initial): commit 01 +4fa4f5e427373ac4ac0a6e11ff97293649959859 ddb8365ff4c367dbd7d49b965ab4b43c865b99cf CI 1669295719 +0000 commit: commit 02 diff --git a/test/integration_new/config/remote_named_star/expected/repo/.git_keep/objects/06/47fe4b7302efbfb235b8f0681b592cc3389d36 b/test/integration_new/config/remote_named_star/expected/repo/.git_keep/objects/06/47fe4b7302efbfb235b8f0681b592cc3389d36 new file mode 100644 index 000000000..a8a2b586d Binary files /dev/null and b/test/integration_new/config/remote_named_star/expected/repo/.git_keep/objects/06/47fe4b7302efbfb235b8f0681b592cc3389d36 differ diff --git a/test/integration_new/config/remote_named_star/expected/repo/.git_keep/objects/47/d78ad7a27fc7fe483389512ebf7ea34c5514bc b/test/integration_new/config/remote_named_star/expected/repo/.git_keep/objects/47/d78ad7a27fc7fe483389512ebf7ea34c5514bc new file mode 100644 index 000000000..c562d38cc Binary files /dev/null and b/test/integration_new/config/remote_named_star/expected/repo/.git_keep/objects/47/d78ad7a27fc7fe483389512ebf7ea34c5514bc differ diff --git a/test/integration_new/config/remote_named_star/expected/repo/.git_keep/objects/4f/a4f5e427373ac4ac0a6e11ff97293649959859 b/test/integration_new/config/remote_named_star/expected/repo/.git_keep/objects/4f/a4f5e427373ac4ac0a6e11ff97293649959859 new file mode 100644 index 000000000..431f11b99 Binary files /dev/null and b/test/integration_new/config/remote_named_star/expected/repo/.git_keep/objects/4f/a4f5e427373ac4ac0a6e11ff97293649959859 differ diff --git a/test/integration_new/config/remote_named_star/expected/repo/.git_keep/objects/55/3197193920043fb04f3e39e825916990955204 b/test/integration_new/config/remote_named_star/expected/repo/.git_keep/objects/55/3197193920043fb04f3e39e825916990955204 new file mode 100644 index 000000000..ac90c394a Binary files /dev/null and b/test/integration_new/config/remote_named_star/expected/repo/.git_keep/objects/55/3197193920043fb04f3e39e825916990955204 differ diff --git a/test/integration_new/config/remote_named_star/expected/repo/.git_keep/objects/a0/2c4b36b68df7081152282cf1aabcab7b24e69b b/test/integration_new/config/remote_named_star/expected/repo/.git_keep/objects/a0/2c4b36b68df7081152282cf1aabcab7b24e69b new file mode 100644 index 000000000..85866acd8 Binary files /dev/null and b/test/integration_new/config/remote_named_star/expected/repo/.git_keep/objects/a0/2c4b36b68df7081152282cf1aabcab7b24e69b differ diff --git a/test/integration_new/config/remote_named_star/expected/repo/.git_keep/objects/dd/b8365ff4c367dbd7d49b965ab4b43c865b99cf b/test/integration_new/config/remote_named_star/expected/repo/.git_keep/objects/dd/b8365ff4c367dbd7d49b965ab4b43c865b99cf new file mode 100644 index 000000000..fc4abfe75 --- /dev/null +++ b/test/integration_new/config/remote_named_star/expected/repo/.git_keep/objects/dd/b8365ff4c367dbd7d49b965ab4b43c865b99cf @@ -0,0 +1,2 @@ +x; +1@sL"V{I`e+^]z @XXbd3b T*%U6} M| )zV"ƉE86ei4_#}}.# GcvO 3`|O: \ No newline at end of file diff --git a/test/integration_new/config/remote_named_star/expected/repo/.git_keep/refs/heads/master b/test/integration_new/config/remote_named_star/expected/repo/.git_keep/refs/heads/master new file mode 100644 index 000000000..4dcaa7e6b --- /dev/null +++ b/test/integration_new/config/remote_named_star/expected/repo/.git_keep/refs/heads/master @@ -0,0 +1 @@ +ddb8365ff4c367dbd7d49b965ab4b43c865b99cf diff --git a/test/integration_new/config/remote_named_star/expected/repo/file01.txt b/test/integration_new/config/remote_named_star/expected/repo/file01.txt new file mode 100644 index 000000000..47d78ad7a --- /dev/null +++ b/test/integration_new/config/remote_named_star/expected/repo/file01.txt @@ -0,0 +1 @@ +file01 content \ No newline at end of file diff --git a/test/integration_new/config/remote_named_star/expected/repo/file02.txt b/test/integration_new/config/remote_named_star/expected/repo/file02.txt new file mode 100644 index 000000000..0647fe4b7 --- /dev/null +++ b/test/integration_new/config/remote_named_star/expected/repo/file02.txt @@ -0,0 +1 @@ +file02 content \ No newline at end of file