fix: use struct data for HEAD retrieval
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
See ce7dda1eaea5665da7155b4fc2d0a5f885237b1a
This commit is contained in:
parent
c5724d56f8
commit
ff90b43929
@ -12,7 +12,6 @@ import (
|
||||
"coopcloud.tech/abra/pkg/client"
|
||||
"coopcloud.tech/abra/pkg/dns"
|
||||
"coopcloud.tech/abra/pkg/formatter"
|
||||
"coopcloud.tech/abra/pkg/git"
|
||||
"coopcloud.tech/abra/pkg/lint"
|
||||
"coopcloud.tech/abra/pkg/log"
|
||||
"coopcloud.tech/abra/pkg/upstream/stack"
|
||||
@ -135,7 +134,7 @@ EXAMPLE:
|
||||
log.Fatal(err)
|
||||
}
|
||||
} else {
|
||||
head, err := git.GetRecipeHead(app.Recipe.Name)
|
||||
head, err := app.Recipe.Head()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
@ -4,35 +4,15 @@ import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/user"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"coopcloud.tech/abra/pkg/config"
|
||||
"coopcloud.tech/abra/pkg/log"
|
||||
"github.com/go-git/go-git/v5"
|
||||
gitConfigPkg "github.com/go-git/go-git/v5/config"
|
||||
"github.com/go-git/go-git/v5/plumbing"
|
||||
"github.com/go-git/go-git/v5/plumbing/format/gitignore"
|
||||
)
|
||||
|
||||
// GetRecipeHead retrieves latest HEAD metadata.
|
||||
func GetRecipeHead(recipeName string) (*plumbing.Reference, error) {
|
||||
recipeDir := path.Join(config.RECIPES_DIR, recipeName)
|
||||
|
||||
repo, err := git.PlainOpen(recipeDir)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
head, err := repo.Head()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return head, nil
|
||||
}
|
||||
|
||||
// IsClean checks if a repo has unstaged changes
|
||||
func IsClean(repoPath string) (bool, error) {
|
||||
repo, err := git.PlainOpen(repoPath)
|
||||
|
@ -228,7 +228,7 @@ func (r Recipe) EnsureUpToDate() error {
|
||||
func (r Recipe) ChaosVersion() (string, error) {
|
||||
var version string
|
||||
|
||||
head, err := gitPkg.GetRecipeHead(r.Name)
|
||||
head, err := r.Head()
|
||||
if err != nil {
|
||||
return version, err
|
||||
}
|
||||
@ -379,3 +379,18 @@ func (r Recipe) GetRecipeVersions() (RecipeVersions, error) {
|
||||
|
||||
return versions, nil
|
||||
}
|
||||
|
||||
// Head retrieves latest HEAD metadata.
|
||||
func (r Recipe) Head() (*plumbing.Reference, error) {
|
||||
repo, err := git.PlainOpen(r.Dir)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
head, err := repo.Head()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return head, nil
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user