forked from toolshed/abra
@ -1,6 +1,7 @@
|
||||
package catalogue
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"path"
|
||||
@ -8,6 +9,7 @@ import (
|
||||
|
||||
"coopcloud.tech/abra/pkg/config"
|
||||
gitPkg "coopcloud.tech/abra/pkg/git"
|
||||
"coopcloud.tech/abra/pkg/i18n"
|
||||
"coopcloud.tech/abra/pkg/log"
|
||||
"github.com/go-git/go-git/v5"
|
||||
)
|
||||
@ -16,7 +18,7 @@ import (
|
||||
func EnsureCatalogue() error {
|
||||
catalogueDir := path.Join(config.ABRA_DIR, "catalogue")
|
||||
if _, err := os.Stat(catalogueDir); err != nil && os.IsNotExist(err) {
|
||||
log.Debugf("catalogue is missing, retrieving now")
|
||||
log.Debug(i18n.G("catalogue is missing, retrieving now"))
|
||||
|
||||
url := fmt.Sprintf("%s/%s.git", config.REPOS_BASE_URL, config.CATALOGUE_JSON_REPO_NAME)
|
||||
if err := gitPkg.Clone(catalogueDir, url); err != nil {
|
||||
@ -35,8 +37,7 @@ func EnsureIsClean() error {
|
||||
}
|
||||
|
||||
if !isClean {
|
||||
msg := "%s has locally unstaged changes? please commit/remove your changes before proceeding"
|
||||
return fmt.Errorf(msg, config.CATALOGUE_DIR)
|
||||
return errors.New(i18n.G("%s has locally unstaged changes? please commit/remove your changes before proceeding", config.CATALOGUE_DIR))
|
||||
}
|
||||
|
||||
return nil
|
||||
@ -55,8 +56,7 @@ func EnsureUpToDate() error {
|
||||
}
|
||||
|
||||
if len(remotes) == 0 {
|
||||
msg := "cannot ensure %s is up-to-date, no git remotes configured"
|
||||
log.Debugf(msg, config.CATALOGUE_DIR)
|
||||
log.Debug(i18n.G("cannot ensure %s is up-to-date, no git remotes configured", config.CATALOGUE_DIR))
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -81,7 +81,7 @@ func EnsureUpToDate() error {
|
||||
}
|
||||
}
|
||||
|
||||
log.Debugf("fetched latest git changes for %s", config.CATALOGUE_DIR)
|
||||
log.Debug(i18n.G("fetched latest git changes for %s", config.CATALOGUE_DIR))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user