summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2020-10-12 19:04:20 +1100
committerJesse Duffield <jessedduffield@gmail.com>2020-10-12 19:07:40 +1100
commit031e97ef91654a53e7e534e7d4aa032e06eee319 (patch)
treeebd41bc2f974e84ab01dee70f2413b688c6e6371
parent3df0a9f1322c5bb0e76967ee4b6ec3507ec41894 (diff)
more password checks on commands that talk to the remote
-rw-r--r--pkg/commands/remotes.go7
-rw-r--r--pkg/commands/tags.go7
-rw-r--r--pkg/gui/remote_branches_panel.go5
-rw-r--r--pkg/gui/remotes_panel.go1
-rw-r--r--pkg/gui/tags_panel.go10
-rw-r--r--pkg/i18n/english.go2
6 files changed, 20 insertions, 12 deletions
diff --git a/pkg/commands/remotes.go b/pkg/commands/remotes.go
index 6d69b37cd..779ce9e2b 100644
--- a/pkg/commands/remotes.go
+++ b/pkg/commands/remotes.go
@@ -1,6 +1,8 @@
package commands
import (
+ "fmt"
+
"github.com/jesseduffield/lazygit/pkg/commands/models"
)
@@ -20,8 +22,9 @@ func (c *GitCommand) UpdateRemoteUrl(remoteName string, updatedUrl string) error
return c.OSCommand.RunCommand("git remote set-url %s %s", remoteName, updatedUrl)
}
-func (c *GitCommand) DeleteRemoteBranch(remoteName string, branchName string) error {
- return c.OSCommand.RunCommand("git push %s --delete %s", remoteName, branchName)
+func (c *GitCommand) DeleteRemoteBranch(remoteName string, branchName string, promptUserForCredential func(string) string) error {
+ command := fmt.Sprintf("git push %s --delete %s", remoteName, branchName)
+ return c.OSCommand.DetectUnamePass(command, promptUserForCredential)
}
// CheckRemoteBranchExists Returns remote branch
diff --git a/pkg/commands/tags.go b/pkg/commands/tags.go
index f7b26d8df..121637311 100644
--- a/pkg/commands/tags.go
+++ b/pkg/commands/tags.go
@@ -1,5 +1,7 @@
package commands
+import "fmt"
+
func (c *GitCommand) CreateLightweightTag(tagName string, commitSha string) error {
return c.OSCommand.RunCommand("git tag %s %s", tagName, commitSha)
}
@@ -8,6 +10,7 @@ func (c *GitCommand) DeleteTag(tagName string) error {
return c.OSCommand.RunCommand("git tag -d %s", tagName)
}
-func (c *GitCommand) PushTag(remoteName string, tagName string) error {
- return c.OSCommand.RunCommand("git push %s %s", remoteName, tagName)
+func (c *GitCommand) PushTag(remoteName string, tagName string, promptUserForCredential func(string) string) error {
+ command := fmt.Sprintf("git push %s %s", remoteName, tagName)
+ return c.OSCommand.DetectUnamePass(command, promptUserForCredential)
}
diff --git a/pkg/gui/remote_branches_panel.go b/pkg/gui/remote_branches_panel.go
index 1155529ce..582ed749d 100644
--- a/pkg/gui/remote_branches_panel.go
+++ b/pkg/gui/remote_branches_panel.go
@@ -60,9 +60,8 @@ func (gui *Gui) handleDeleteRemoteBranch(g *gocui.Gui, v *gocui.View) error {
prompt: message,
handleConfirm: func() error {
return gui.WithWaitingStatus(gui.Tr.DeletingStatus, func() error {
- if err := gui.GitCommand.DeleteRemoteBranch(remoteBranch.RemoteName, remoteBranch.Name); err != nil {
- return err
- }
+ err := gui.GitCommand.DeleteRemoteBranch(remoteBranch.RemoteName, remoteBranch.Name, gui.promptUserForCredential)
+ gui.handleCredentialsPopup(err)
return gui.refreshSidePanels(refreshOptions{scope: []int{BRANCHES, REMOTES}})
})
diff --git a/pkg/gui/remotes_panel.go b/pkg/gui/remotes_panel.go
index f3c984d78..76ca536cb 100644
--- a/pkg/gui/remotes_panel.go
+++ b/pkg/gui/remotes_panel.go
@@ -166,7 +166,6 @@ func (gui *Gui) handleFetchRemote(g *gocui.Gui, v *gocui.View) error {
gui.Mutexes.FetchMutex.Lock()
defer gui.Mutexes.FetchMutex.Unlock()
- // TODO: test this
err := gui.GitCommand.FetchRemote(remote.Name, gui.promptUserForCredential)
gui.handleCredentialsPopup(err)
diff --git a/pkg/gui/tags_panel.go b/pkg/gui/tags_panel.go
index 6478dc016..6f9004e4d 100644
--- a/pkg/gui/tags_panel.go
+++ b/pkg/gui/tags_panel.go
@@ -98,10 +98,12 @@ func (gui *Gui) handlePushTag(g *gocui.Gui, v *gocui.View) error {
)
return gui.prompt(title, "origin", func(response string) error {
- if err := gui.GitCommand.PushTag(response, tag.Name); err != nil {
- return gui.surfaceError(err)
- }
- return nil
+ return gui.WithWaitingStatus(gui.Tr.PushingTagStatus, func() error {
+ err := gui.GitCommand.PushTag(response, tag.Name, gui.promptUserForCredential)
+ gui.handleCredentialsPopup(err)
+
+ return nil
+ })
})
}
diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go
index 98d15574e..30548cc0d 100644
--- a/pkg/i18n/english.go
+++ b/pkg/i18n/english.go
@@ -427,6 +427,7 @@ type TranslationSet struct {
SubCommitsTitle string
SubmodulesTitle string
NavigationTitle string
+ PushingTagStatus string
}
const englishReleaseNotes = `## lazygit 0.23.2 Release Notes
@@ -924,5 +925,6 @@ func englishTranslationSet() TranslationSet {
SubCommitsTitle: "Sub-commits",
SubmodulesTitle: "Submodules",
NavigationTitle: "List Panel Navigation",
+ PushingTagStatus: "pushing tag",
}
}