feat: catalogue sync command
This commit is contained in:
@ -20,6 +20,24 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var CatalogueSyncCommand = &cobra.Command{
|
||||
Use: i18n.G("sync [flags]"),
|
||||
Aliases: []string{i18n.G("g")},
|
||||
Short: i18n.G("Sync recipe catalogue for latest changes"),
|
||||
Args: cobra.NoArgs,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
if err := catalogue.EnsureCatalogue(); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if err := catalogue.EnsureUpToDate(); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
log.Info(i18n.G("catalogue successfully synced"))
|
||||
},
|
||||
}
|
||||
|
||||
var CatalogueGenerateCommand = &cobra.Command{
|
||||
Use: i18n.G("generate [recipe] [flags]"),
|
||||
Aliases: []string{i18n.G("g")},
|
||||
|
@ -143,6 +143,7 @@ func Run(version, commit string) {
|
||||
|
||||
catalogue.CatalogueCommand.AddCommand(
|
||||
catalogue.CatalogueGenerateCommand,
|
||||
catalogue.CatalogueSyncCommand,
|
||||
)
|
||||
|
||||
server.ServerCommand.AddCommand(
|
||||
|
@ -47,3 +47,24 @@ setup(){
|
||||
assert_success
|
||||
assert_exists "$ABRA_DIR/recipes/gitea/.git"
|
||||
}
|
||||
|
||||
# bats test_tags=slow
|
||||
@test "sync latest changes" {
|
||||
_ensure_catalogue
|
||||
|
||||
latestHash=$(git -C "$ABRA_DIR/catalogue" show -s --format="%H")
|
||||
|
||||
wantHash=$(git -C "$ABRA_DIR/catalogue" show -s --format="%H" "HEAD~3")
|
||||
|
||||
run git -C "$ABRA_DIR/catalogue" reset --hard HEAD~3
|
||||
assert_success
|
||||
|
||||
currHash=$(git -C "$ABRA_DIR/catalogue" show -s --format="%H")
|
||||
assert_equal "$currHash" "$wantHash"
|
||||
|
||||
run $ABRA catalogue sync
|
||||
assert_success
|
||||
|
||||
syncHash=$(git -C "$ABRA_DIR/catalogue" show -s --format="%H")
|
||||
assert_equal "$syncHash" "$latestHash"
|
||||
}
|
||||
|
Reference in New Issue
Block a user