From 45c32bc7fc00fd43b1b54d36f96671368323d238 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sun, 29 Dec 2024 21:36:39 -0600 Subject: [PATCH] add git author and email --- send.go | 21 +++++++++++++++++---- structs.go | 3 +++ windowMain.go | 12 ++++++++++++ windowPatches.go | 20 +++++--------------- 4 files changed, 37 insertions(+), 19 deletions(-) diff --git a/send.go b/send.go index f1f5dd4..a534d1a 100644 --- a/send.go +++ b/send.go @@ -3,6 +3,7 @@ package main import ( + "fmt" "os" "path/filepath" "strings" @@ -95,15 +96,27 @@ func getPatch(pbfile string) error { return nil } -func sendDevelDiff(name string) { +func sendDevelDiff(name string) error { pset, err := me.forge.MakeDevelPatchSet() if err != nil { - badExit(err) + return err } pset.Name = name - if err := sendPatches(pset); err != nil { - badExit(err) + if os.Getenv("GIT_AUTHOR_NAME") == "" { + return fmt.Errorf("GIT_AUTHOR_NAME not set") + } else { + pset.GitAuthorName = os.Getenv("GIT_AUTHOR_NAME") } + if os.Getenv("GIT_AUTHOR_EMAIL") == "" { + return fmt.Errorf("GIT_AUTHOR_EMAIL not set") + } else { + pset.GitAuthorEmail = os.Getenv("GIT_AUTHOR_EMAIL") + } + + if err := sendPatches(pset); err != nil { + return err + } + return nil } func sendMasterDiff() { diff --git a/structs.go b/structs.go index b5f5ee0..f079bc5 100644 --- a/structs.go +++ b/structs.go @@ -56,6 +56,9 @@ type mainType struct { // what is being used as ~/go/src goSrcPwd *gadgets.OneLiner + // ENV GIT_AUTHOR NAME and EMAIL + gitAuthor *gadgets.OneLiner + // displays a summary of all the repos // has total dirty, total read-only // total patches, etc diff --git a/windowMain.go b/windowMain.go index 5f7a71b..eb55656 100644 --- a/windowMain.go +++ b/windowMain.go @@ -65,6 +65,18 @@ func globalBuildOptions(vbox *gui.Node) { srcDir := filepath.Join(homeDir, "go/src") me.goSrcPwd.SetText(srcDir) + // use ENV GIT_AUTHOR + me.gitAuthor = gadgets.NewOneLiner(grid, "Git Author") + grid.NextRow() + + if os.Getenv("GIT_AUTHOR_NAME") == "" { + me.gitAuthor.SetText("ENV GIT_AUTHOR_NAME is unset") + } else { + author := os.Getenv("GIT_AUTHOR_NAME") + author += " <" + os.Getenv("GIT_AUTHOR_EMAIL") + ">" + me.gitAuthor.SetText(author) + } + // select the branch you want to test, build and develop against // this lets you select your user branch, but, when you are happy // you can merge everything into the devel branch and make sure it actually diff --git a/windowPatches.go b/windowPatches.go index 4685561..f0e5d6d 100644 --- a/windowPatches.go +++ b/windowPatches.go @@ -157,21 +157,11 @@ func submitPatchesBox(box *gui.Node) *patchSummary { } } s.submitB = s.grid.NewButton("Submit", func() { - sendDevelDiff(s.reason.String()) - /* - dirname := "submit-patchset.quilt" - patchdir := filepath.Join(me.userHomePwd.String(), dirname) - if shell.Exists(patchdir) { - log.Info("patchset dir already exists", patchdir) - shell.PathRun(me.userHomePwd.String(), []string{"rm", "-rf", dirname}) - } - os.MkdirAll(patchdir, os.ModeDir) - if !shell.Exists(patchdir) { - log.Info("something went wrong making", patchdir) - return - } - me.repos.View.MakePatchset(patchdir) - */ + if err := sendDevelDiff(s.reason.String()); err != nil { + log.Info("sending patches failed", err) + } else { + log.Info("sent patch set ok") + } }) s.grid.NewButton("Show Patchsets", func() { listPatches()