Skip to content

Commit ea2ce22

Browse files
authored
Add better error handling for init step (#201)
1 parent ff49eb5 commit ea2ce22

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

cmd/plural/init.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import (
77
"time"
88

99
"github.com/pkg/browser"
10+
"github.com/urfave/cli"
11+
1012
"github.com/pluralsh/plural/pkg/api"
1113
"github.com/pluralsh/plural/pkg/config"
1214
"github.com/pluralsh/plural/pkg/crypto"
@@ -16,7 +18,6 @@ import (
1618
"github.com/pluralsh/plural/pkg/utils"
1719
"github.com/pluralsh/plural/pkg/utils/pathing"
1820
"github.com/pluralsh/plural/pkg/wkspace"
19-
"github.com/urfave/cli"
2021
)
2122

2223
func handleInit(c *cli.Context) error {
@@ -37,7 +38,6 @@ func handleInit(c *cli.Context) error {
3738
}
3839
defer func(prov provider.Provider) {
3940
_ = prov.Flush()
40-
4141
}(prov)
4242

4343
if !git && affirm("you're attempting to setup plural outside a git repository. would you like us to set one up for you here?") {

pkg/wkspace/validator.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,12 @@ func Preflight() (bool, error) {
2323

2424
cmd = exec.Command("git", "rev-parse", "--abbrev-ref", "HEAD")
2525
if _, err := cmd.CombinedOutput(); err != nil {
26-
return false, utils.HighlightError(fmt.Errorf("Repository has no initial commit, you can simply commit a blank readme and push to start working"))
26+
return true, utils.HighlightError(fmt.Errorf("repository has no initial commit, you can simply commit a blank readme and push to start working"))
27+
}
28+
29+
cmd = exec.Command("git", "ls-remote", "--exit-code")
30+
if _, err := cmd.CombinedOutput(); err != nil {
31+
return true, utils.HighlightError(fmt.Errorf("repository has no remotes set, make sure that at least one remote is set"))
2732
}
2833

2934
return true, nil

0 commit comments

Comments
 (0)