forked from coop-cloud/abra
fix: better error handling in EnsureUpToDate
This commit is contained in:
parent
7ccc4b4c08
commit
7c541ffdfa
|
@ -584,7 +584,7 @@ func EnsureUpToDate(recipeName string) error {
|
|||
|
||||
isClean, err := gitPkg.IsClean(recipeDir)
|
||||
if err != nil {
|
||||
return err
|
||||
return fmt.Errorf("unable to check git clean status in %s: %s", recipeDir, err)
|
||||
}
|
||||
|
||||
if !isClean {
|
||||
|
@ -594,12 +594,12 @@ func EnsureUpToDate(recipeName string) error {
|
|||
|
||||
repo, err := git.PlainOpen(recipeDir)
|
||||
if err != nil {
|
||||
return err
|
||||
return fmt.Errorf("unable to open %s: %s", recipeDir, err)
|
||||
}
|
||||
|
||||
remotes, err := repo.Remotes()
|
||||
if err != nil {
|
||||
return err
|
||||
return fmt.Errorf("unable to read remotes in %s: %s", recipeDir, err)
|
||||
}
|
||||
|
||||
if len(remotes) == 0 {
|
||||
|
@ -609,12 +609,12 @@ func EnsureUpToDate(recipeName string) error {
|
|||
|
||||
worktree, err := repo.Worktree()
|
||||
if err != nil {
|
||||
return err
|
||||
return fmt.Errorf("unable to open git work tree in %s: %s", recipeDir, err)
|
||||
}
|
||||
|
||||
branch, err := gitPkg.CheckoutDefaultBranch(repo, recipeDir)
|
||||
if err != nil {
|
||||
return err
|
||||
return fmt.Errorf("unable to check out default branch in %s: %s", recipeDir, err)
|
||||
}
|
||||
|
||||
fetchOpts := &git.FetchOptions{
|
||||
|
@ -625,7 +625,7 @@ func EnsureUpToDate(recipeName string) error {
|
|||
}
|
||||
if err := repo.Fetch(fetchOpts); err != nil {
|
||||
if !strings.Contains(err.Error(), "already up-to-date") {
|
||||
return err
|
||||
return fmt.Errorf("unable to fetch tags in %s: %s", recipeDir, err)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -636,7 +636,7 @@ func EnsureUpToDate(recipeName string) error {
|
|||
|
||||
if err := worktree.Pull(opts); err != nil {
|
||||
if !strings.Contains(err.Error(), "already up-to-date") {
|
||||
return err
|
||||
return fmt.Errorf("unable to git pull in %s: %s", recipeDir, err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue