mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-09-10 15:46:26 -04:00
Turn the ForceShowUntracked field of GetStatusFileOptions into an enum
This commit is contained in:
parent
bb5d5f2deb
commit
cf491d1b5b
|
|
@ -30,20 +30,37 @@ func NewFileLoader(gitCommon *GitCommon, cmd oscommands.ICmdObjBuilder, config F
|
|||
}
|
||||
}
|
||||
|
||||
type ShowUntrackedMode int
|
||||
|
||||
const (
|
||||
// Use the value from git config (show all if not set)
|
||||
ShowUntrackedModeAuto ShowUntrackedMode = iota
|
||||
// Show untracked files regardless of git config. Useful for users with bare
|
||||
// repos for dotfiles who default to hiding untracked files, but want to
|
||||
// occasionally see them to `git add` a new file.
|
||||
ShowUntrackedModeOn
|
||||
// Hide untracked files regardless of git config.
|
||||
ShowUntrackedModeOff
|
||||
)
|
||||
|
||||
type GetStatusFileOptions struct {
|
||||
NoRenames bool
|
||||
// If true, we'll show untracked files even if the user has set the config to hide them.
|
||||
// This is useful for users with bare repos for dotfiles who default to hiding untracked files,
|
||||
// but want to occasionally see them to `git add` a new file.
|
||||
ForceShowUntracked bool
|
||||
NoRenames bool
|
||||
ShowUntracked ShowUntrackedMode
|
||||
}
|
||||
|
||||
func (self *FileLoader) GetStatusFiles(opts GetStatusFileOptions) []*models.File {
|
||||
// check if config wants us ignoring untracked files
|
||||
untrackedFilesSetting := self.config.GetShowUntrackedFiles()
|
||||
|
||||
if opts.ForceShowUntracked || untrackedFilesSetting == "" {
|
||||
switch opts.ShowUntracked {
|
||||
case ShowUntrackedModeOn:
|
||||
untrackedFilesSetting = "all"
|
||||
case ShowUntrackedModeOff:
|
||||
untrackedFilesSetting = "no"
|
||||
default: // ShowUntrackedModeAuto
|
||||
if untrackedFilesSetting == "" {
|
||||
untrackedFilesSetting = "all"
|
||||
}
|
||||
}
|
||||
untrackedFilesArg := fmt.Sprintf("--untracked-files=%s", untrackedFilesSetting)
|
||||
|
||||
|
|
|
|||
|
|
@ -599,9 +599,13 @@ func (self *RefreshHelper) refreshStateFiles() error {
|
|||
}
|
||||
}
|
||||
|
||||
showUntracked := git_commands.ShowUntrackedModeAuto
|
||||
if self.c.Contexts().Files.ForceShowUntracked() {
|
||||
showUntracked = git_commands.ShowUntrackedModeOn
|
||||
}
|
||||
files := self.c.Git().Loaders.FileLoader.
|
||||
GetStatusFiles(git_commands.GetStatusFileOptions{
|
||||
ForceShowUntracked: self.c.Contexts().Files.ForceShowUntracked(),
|
||||
ShowUntracked: showUntracked,
|
||||
})
|
||||
|
||||
conflictFileCount := 0
|
||||
|
|
|
|||
Loading…
Reference in a new issue