mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-06-15 00:15:32 +02:00
Removed a lot of useless code
This commit is contained in:
@ -63,7 +63,6 @@ type GitCommand struct {
|
||||
Worktree *gogit.Worktree
|
||||
Repo *gogit.Repository
|
||||
Tr *i18n.Localizer
|
||||
SavedCredentials SavedCredentials
|
||||
getGlobalGitConfig func(string) (string, error)
|
||||
getLocalGitConfig func(string) (string, error)
|
||||
removeFile func(string) error
|
||||
@ -94,19 +93,12 @@ func NewGitCommand(log *logrus.Entry, osCommand *OSCommand, tr *i18n.Localizer)
|
||||
}
|
||||
}
|
||||
|
||||
credentials := SavedCredentials{
|
||||
Username: "",
|
||||
Password: "",
|
||||
HasAsked: false,
|
||||
}
|
||||
|
||||
return &GitCommand{
|
||||
Log: log,
|
||||
OSCommand: osCommand,
|
||||
Tr: tr,
|
||||
Worktree: worktree,
|
||||
Repo: repo,
|
||||
SavedCredentials: credentials,
|
||||
getGlobalGitConfig: gitconfig.Global,
|
||||
getLocalGitConfig: gitconfig.Local,
|
||||
removeFile: os.RemoveAll,
|
||||
@ -255,43 +247,14 @@ func (c *GitCommand) RenameCommit(name string) error {
|
||||
return c.OSCommand.RunCommand(fmt.Sprintf("git commit --allow-empty --amend -m %s", c.OSCommand.Quote(name)))
|
||||
}
|
||||
|
||||
// SavedCredentials are the user's git login credentials
|
||||
type SavedCredentials struct {
|
||||
Username string
|
||||
Password string
|
||||
HasAsked bool
|
||||
}
|
||||
|
||||
// Fetch fetch git repo
|
||||
func (c *GitCommand) Fetch(unamePassQuestion func(string) string, runDry bool) error {
|
||||
newCredentials := SavedCredentials{
|
||||
Username: c.SavedCredentials.Username,
|
||||
Password: c.SavedCredentials.Password,
|
||||
}
|
||||
cmd := "git fetch"
|
||||
if runDry {
|
||||
cmd += " --dry-run"
|
||||
}
|
||||
|
||||
err := c.OSCommand.DetectUnamePass(cmd, func(question string) string {
|
||||
if question == "username" && len(c.SavedCredentials.Username) != 0 {
|
||||
return c.SavedCredentials.Username
|
||||
func (c *GitCommand) Fetch(unamePassQuestion func(string) string, canSskForCredentials bool) error {
|
||||
return c.OSCommand.DetectUnamePass("git fetch", func(question string) string {
|
||||
if canSskForCredentials {
|
||||
return unamePassQuestion(question)
|
||||
}
|
||||
if question == "password" && len(c.SavedCredentials.Password) != 0 {
|
||||
return c.SavedCredentials.Password
|
||||
}
|
||||
output := unamePassQuestion(question)
|
||||
if question == "password" {
|
||||
newCredentials.Password = output
|
||||
} else {
|
||||
newCredentials.Username = output
|
||||
}
|
||||
return output
|
||||
return "-"
|
||||
})
|
||||
if err == nil {
|
||||
c.SavedCredentials = newCredentials
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
// ResetToCommit reset to commit
|
||||
|
Reference in New Issue
Block a user