From a44549117d444d5cec7d55ace39962f681db59a0 Mon Sep 17 00:00:00 2001 From: p4u1 Date: Thu, 7 Mar 2024 17:48:42 +0100 Subject: [PATCH] Revert "fix tests/integration/recipe_new.bats" This reverts commit 0aac464ded6b43afb3ec37ade2f64d6191b9838f. --- cli/internal/cli.go | 16 ---------------- cli/recipe/new.go | 7 +++---- pkg/git/init.go | 13 ++++--------- tests/integration/recipe_new.bats | 4 ++-- 4 files changed, 9 insertions(+), 31 deletions(-) diff --git a/cli/internal/cli.go b/cli/internal/cli.go index c80a3082..b7555bdc 100644 --- a/cli/internal/cli.go +++ b/cli/internal/cli.go @@ -238,22 +238,6 @@ var RemoteUserFlag = &cli.StringFlag{ Destination: &RemoteUser, } -var GitUser string -var GitUserFlag = &cli.StringFlag{ - Name: "git-user, gu", - Value: "", - Usage: "Git user name to do commits with", - Destination: &GitUser, -} - -var GitEmail string -var GitEmailFlag = &cli.StringFlag{ - Name: "git-email, ge", - Value: "", - Usage: "Git email name to do commits with", - Destination: &GitEmail, -} - // SubCommandBefore wires up pre-action machinery (e.g. --debug handling). func SubCommandBefore(c *cli.Context) error { if Debug { diff --git a/cli/recipe/new.go b/cli/recipe/new.go index 3c109def..87e84d87 100644 --- a/cli/recipe/new.go +++ b/cli/recipe/new.go @@ -4,6 +4,7 @@ import ( "bytes" "errors" "fmt" + "io/ioutil" "os" "path" "text/template" @@ -36,8 +37,6 @@ var recipeNewCommand = cli.Command{ internal.DebugFlag, internal.NoInputFlag, internal.OfflineFlag, - internal.GitUserFlag, - internal.GitEmailFlag, }, Before: internal.SubCommandBefore, Usage: "Create a new recipe", @@ -93,14 +92,14 @@ recipe and domain in the sample environment config). logrus.Fatal(err) } - if err := os.WriteFile(path, templated.Bytes(), 0644); err != nil { + if err := ioutil.WriteFile(path, templated.Bytes(), 0644); err != nil { logrus.Fatal(err) } } newGitRepo := path.Join(config.RECIPES_DIR, recipeName) - if err := git.Init(newGitRepo, true, internal.GitUser, internal.GitEmail); err != nil { + if err := git.Init(newGitRepo, true); err != nil { logrus.Fatal(err) } diff --git a/pkg/git/init.go b/pkg/git/init.go index 851c2e5c..d0af92b0 100644 --- a/pkg/git/init.go +++ b/pkg/git/init.go @@ -2,13 +2,13 @@ package git import ( "github.com/go-git/go-git/v5" - "github.com/go-git/go-git/v5/plumbing/object" + gitPkg "github.com/go-git/go-git/v5" "github.com/sirupsen/logrus" ) // Init inits a new repo and commits all the stuff if you want -func Init(repoPath string, commit bool, gitUser, gitEmail string) error { - if _, err := git.PlainInit(repoPath, false); err != nil { +func Init(repoPath string, commit bool) error { + if _, err := gitPkg.PlainInit(repoPath, false); err != nil { logrus.Fatal(err) } logrus.Debugf("initialised new git repo in %s", repoPath) @@ -28,12 +28,7 @@ func Init(repoPath string, commit bool, gitUser, gitEmail string) error { return err } - var author *object.Signature - if gitUser != "" && gitEmail != "" { - author = &object.Signature{Name: gitUser, Email: gitEmail} - } - - if _, err = commitWorktree.Commit("init", &git.CommitOptions{Author: author}); err != nil { + if _, err = commitWorktree.Commit("init", &git.CommitOptions{}); err != nil { return err } logrus.Debugf("init committed all files for new git repo in %s", repoPath) diff --git a/tests/integration/recipe_new.bats b/tests/integration/recipe_new.bats index 7b14201c..6149f053 100644 --- a/tests/integration/recipe_new.bats +++ b/tests/integration/recipe_new.bats @@ -23,14 +23,14 @@ teardown(){ } @test "create new recipe" { - run $ABRA recipe new foobar --git-user foo --git-email foo@example.com + run $ABRA recipe new foobar assert_success assert_output --partial 'Your new foobar recipe has been created' assert_exists "$ABRA_DIR/recipes/foobar" } @test "create new app from new recipe" { - run $ABRA recipe new foobar --git-user foo --git-email foo@example.com + run $ABRA recipe new foobar assert_success run $ABRA app new foobar \