mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-09-14 09:36:24 -04:00
Demonstrate that the recent repos menu shows ".invalid" for a reftable repo
A repo that keeps its refs in a reftable shows ".invalid" in the branch column. Git stores the real HEAD in a binary table there and leaves "ref: refs/heads/.invalid" in the HEAD file, so that anything still reading the HEAD file fails loudly instead of getting a stale answer. We read that file and take the placeholder for a branch name. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
93713b5401
commit
7b5c6f4e12
|
|
@ -66,6 +66,19 @@ func TestReadHeadInfo(t *testing.T) {
|
|||
expected: headInfo{branch: "mybranch"},
|
||||
expectedOk: true,
|
||||
},
|
||||
{
|
||||
name: "repo that keeps its refs in a reftable, so HEAD holds a placeholder",
|
||||
files: map[string]string{
|
||||
"repo/.git/HEAD": "ref: refs/heads/.invalid\n",
|
||||
},
|
||||
/* EXPECTED:
|
||||
repoPath: "repo",
|
||||
expectedOk: false,
|
||||
ACTUAL: */
|
||||
repoPath: "repo",
|
||||
expected: headInfo{branch: ".invalid"},
|
||||
expectedOk: true,
|
||||
},
|
||||
{
|
||||
name: "directory without a .git entry",
|
||||
repoPath: "notarepo",
|
||||
|
|
|
|||
40
pkg/integration/tests/misc/recent_repos_reftable_repo.go
Normal file
40
pkg/integration/tests/misc/recent_repos_reftable_repo.go
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
package misc
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
|
||||
"github.com/jesseduffield/lazygit/pkg/config"
|
||||
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
||||
)
|
||||
|
||||
var RecentReposReftableRepo = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Description: "The recent repositories menu shows the branch of a repo that keeps its refs in a reftable",
|
||||
ExtraCmdArgs: []string{},
|
||||
ExtraEnvVars: map[string]string{
|
||||
"SHOW_RECENT_REPOS": "true",
|
||||
},
|
||||
Skip: false,
|
||||
GitVersion: AtLeast("2.45.0"),
|
||||
SetupConfig: func(cfg *config.AppConfig) {
|
||||
// the first entry is the repo we're in, so it isn't offered
|
||||
current, _ := filepath.Abs(".")
|
||||
reftable, _ := filepath.Abs("../reftable")
|
||||
cfg.GetAppState().RecentRepos = []string{current, reftable}
|
||||
},
|
||||
SetupRepo: func(shell *Shell) {
|
||||
shell.EmptyCommit("one")
|
||||
shell.RunCommand([]string{"git", "clone", "--ref-format=reftable", ".", "../reftable"})
|
||||
},
|
||||
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||
t.ExpectPopup().Menu().
|
||||
Title(Equals("Recent repositories")).
|
||||
Lines(
|
||||
/* EXPECTED:
|
||||
Contains("reftable").Contains("master").IsSelected(),
|
||||
ACTUAL: */
|
||||
Contains("reftable").Contains(".invalid").IsSelected(),
|
||||
Contains("Cancel"),
|
||||
).
|
||||
Cancel()
|
||||
},
|
||||
})
|
||||
|
|
@ -368,6 +368,7 @@ var tests = []*components.IntegrationTest{
|
|||
misc.RecentReposBranchColumn,
|
||||
misc.RecentReposColumnWidths,
|
||||
misc.RecentReposOnLaunch,
|
||||
misc.RecentReposReftableRepo,
|
||||
misc.RecentReposWithLongNames,
|
||||
misc.StartInGitDir,
|
||||
patch_building.Apply,
|
||||
|
|
|
|||
Loading…
Reference in a new issue