fix-integration-tests #403
|
@ -238,6 +238,22 @@ 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 {
|
||||
|
|
|
@ -4,7 +4,6 @@ import (
|
|||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
"text/template"
|
||||
|
@ -37,6 +36,8 @@ var recipeNewCommand = cli.Command{
|
|||
internal.DebugFlag,
|
||||
internal.NoInputFlag,
|
||||
internal.OfflineFlag,
|
||||
internal.GitUserFlag,
|
||||
internal.GitEmailFlag,
|
||||
},
|
||||
Before: internal.SubCommandBefore,
|
||||
Usage: "Create a new recipe",
|
||||
|
@ -92,14 +93,14 @@ recipe and domain in the sample environment config).
|
|||
logrus.Fatal(err)
|
||||
}
|
||||
|
||||
if err := ioutil.WriteFile(path, templated.Bytes(), 0644); err != nil {
|
||||
if err := os.WriteFile(path, templated.Bytes(), 0644); err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
newGitRepo := path.Join(config.RECIPES_DIR, recipeName)
|
||||
if err := git.Init(newGitRepo, true); err != nil {
|
||||
if err := git.Init(newGitRepo, true, internal.GitUser, internal.GitEmail); err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
|
||||
|
|
|
@ -2,13 +2,13 @@ package git
|
|||
|
||||
import (
|
||||
"github.com/go-git/go-git/v5"
|
||||
gitPkg "github.com/go-git/go-git/v5"
|
||||
"github.com/go-git/go-git/v5/plumbing/object"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
// Init inits a new repo and commits all the stuff if you want
|
||||
func Init(repoPath string, commit bool) error {
|
||||
if _, err := gitPkg.PlainInit(repoPath, false); err != nil {
|
||||
func Init(repoPath string, commit bool, gitUser, gitEmail string) error {
|
||||
p4u1 marked this conversation as resolved
Outdated
|
||||
if _, err := git.PlainInit(repoPath, false); err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
logrus.Debugf("initialised new git repo in %s", repoPath)
|
||||
|
@ -28,7 +28,12 @@ func Init(repoPath string, commit bool) error {
|
|||
return err
|
||||
}
|
||||
|
||||
if _, err = commitWorktree.Commit("init", &git.CommitOptions{}); err != nil {
|
||||
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 {
|
||||
return err
|
||||
}
|
||||
logrus.Debugf("init committed all files for new git repo in %s", repoPath)
|
||||
|
|
|
@ -23,14 +23,14 @@ teardown(){
|
|||
}
|
||||
|
||||
@test "create new recipe" {
|
||||
run $ABRA recipe new foobar
|
||||
run $ABRA recipe new foobar --git-user foo --git-email foo@example.com
|
||||
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
|
||||
run $ABRA recipe new foobar --git-user foo --git-email foo@example.com
|
||||
assert_success
|
||||
|
||||
run $ABRA app new foobar \
|
||||
|
|
Loading…
Reference in New Issue
This seems like a behaviour change, not a fix? What error were you facing?
I wouldn't mind erroring out here in the case people don't have a
~/.gitconfig
instead of implementing this as additional flags? According to https://pkg.go.dev/github.com/go-git/go-git/v5#CommitOptions 👉 "If Author is empty the Name and Email is read from the config".We could also additionally document to support people to know how to do this inside of Git and not in Abra?
Yeah this is a behavior change. It is for the case when no author is set in the
~/.gitconfig
. I think it is a nice addition but probably better to pull it out into a separate pull request@p4u1 yeh I'd say raise an issue and pull it out for now. We can loop back in another change.
Pulled it out into a seperate pull request #405
Also opened a issue coop-cloud/organising#580