Skip to content

Commit

Permalink
Fix errors when target config dir is not a git dir (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
LinuxSuRen committed Mar 17, 2021
1 parent 7d9c73b commit 46bfc8b
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions cmd/fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"github.com/spf13/cobra"
"os"
"path"
"strings"
)

func newFetchCmd() (cmd *cobra.Command) {
Expand Down Expand Up @@ -42,5 +43,11 @@ func fetchHomeConfig() (err error) {
err = execCommand("git", "clone", "https://github.com/LinuxSuRen/hd-home", configDir)
}
}

if err != nil && strings.Contains(err.Error(), "exit status 128") {
// target directory was created accidentally, remove it then try again
_ = os.RemoveAll(configDir)
return fetchHomeConfig()
}
return
}

0 comments on commit 46bfc8b

Please sign in to comment.