summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pkg/commands/oscommands/os.go6
-rw-r--r--pkg/commands/submodules.go19
2 files changed, 21 insertions, 4 deletions
diff --git a/pkg/commands/oscommands/os.go b/pkg/commands/oscommands/os.go
index 45effa94d..8a0e1654e 100644
--- a/pkg/commands/oscommands/os.go
+++ b/pkg/commands/oscommands/os.go
@@ -97,7 +97,11 @@ func (c *OSCommand) RunCommandWithOutput(formatString string, formatArgs ...inte
}
c.Log.WithField("command", command).Info("RunCommand")
cmd := c.ExecutableFromString(command)
- return sanitisedCommandOutput(cmd.CombinedOutput())
+ output, err := sanitisedCommandOutput(cmd.CombinedOutput())
+ if err != nil {
+ c.Log.WithField("command", command).Error(err)
+ }
+ return output, err
}
// RunExecutableWithOutput runs an executable file and returns its output
diff --git a/pkg/commands/submodules.go b/pkg/commands/submodules.go
index 41ea3bbbf..06abd9bb6 100644
--- a/pkg/commands/submodules.go
+++ b/pkg/commands/submodules.go
@@ -5,6 +5,7 @@ import (
"os"
"path/filepath"
"regexp"
+ "strings"
"github.com/jesseduffield/lazygit/pkg/commands/models"
)
@@ -84,10 +85,22 @@ func (c *GitCommand) SubmoduleDelete(submodule *models.SubmoduleConfig) error {
// based on https://gist.github.com/myusuf3/7f645819ded92bda6677
if err := c.OSCommand.RunCommand("git submodule deinit --force %s", submodule.Path); err != nil {
- return err
+ if strings.Contains(err.Error(), "did not match any file(s) known to git") {
+ if err := c.OSCommand.RunCommand("git config --file .gitmodules --remove-section submodule.%s", submodule.Name); err != nil {
+ return err
+ }
+
+ if err := c.OSCommand.RunCommand("git config --remove-section submodule.%s", submodule.Name); err != nil {
+ return err
+ }
+
+ // if there's an error here about it not existing then we'll just continue to do `git rm`
+ } else {
+ return err
+ }
}
- if err := c.OSCommand.RunCommand("git rm --force %s", submodule.Path); err != nil {
+ if err := c.OSCommand.RunCommand("git rm --force -r %s", submodule.Path); err != nil {
return err
}
@@ -109,6 +122,6 @@ func (c *GitCommand) SubmoduleUpdateUrl(name string, path string, newUrl string)
return err
}
- return c.OSCommand.RunCommand("git submodule sync -- %s", path)
+ return c.OSCommand.RunCommand("git submodule sync %s", path)
}