summaryrefslogtreecommitdiff
path: root/doPatch.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-10-07 03:49:41 -0500
committerJeff Carr <[email protected]>2025-10-07 03:49:41 -0500
commit530219215af236fd1a3d38ad45d6a4b47a7f8f96 (patch)
tree3c9406ae2d0edc80ecb85c9ad9e44ff1a1fd98fa /doPatch.go
parent7d18cc9a9046bf889aeba24aa73d75755bdf6b7d (diff)
remove old codev0.25.64
Diffstat (limited to 'doPatch.go')
-rw-r--r--doPatch.go75
1 files changed, 56 insertions, 19 deletions
diff --git a/doPatch.go b/doPatch.go
index 08f148a..5b7a5e6 100644
--- a/doPatch.go
+++ b/doPatch.go
@@ -4,9 +4,14 @@
package main
import (
+ "bytes"
"errors"
+ "fmt"
"os"
+ "os/exec"
"path/filepath"
+ "regexp"
+ "strings"
"go.wit.com/lib/fhelp"
"go.wit.com/lib/protobuf/forgepb"
@@ -26,25 +31,6 @@ func isPatchingSafe() bool {
return false
}
-// submit's current working patches
-func doPatchSubmit() error {
- pset, err := me.forge.MakeDevelPatchSet("testing")
- if err != nil {
- return err
- }
- if pset.Patches == nil {
- log.Info("pset.Patches == nil")
- return err
- }
- if pset.Patches.Len() == 0 {
- log.Info("did not find any patches")
- return nil
- }
- pset.PrintTable()
- _, _, err = pset.HttpPost(myServer(), "new")
- return err
-}
-
func doPatch() error {
if argv.Patch.Submit != nil {
return doPatchSubmit()
@@ -76,6 +62,25 @@ func doPatch() error {
return err
}
+// submit's current working patches
+func doPatchSubmit() error {
+ pset, err := me.forge.MakeDevelPatchSet("testing")
+ if err != nil {
+ return err
+ }
+ if pset.Patches == nil {
+ log.Info("pset.Patches == nil")
+ return err
+ }
+ if pset.Patches.Len() == 0 {
+ log.Info("did not find any patches")
+ return nil
+ }
+ pset.PrintTable()
+ _, _, err = pset.HttpPost(myServer(), "new")
+ return err
+}
+
func doPatchList() error {
curpatches := forgepb.NewPatches()
curpatches.Filename = "/tmp/curpatches.pb"
@@ -241,3 +246,35 @@ func showWorkRepos() bool {
}
return true
}
+
+func cleanSubject(line string) string {
+ // Regular expression to remove "Subject:" and "[PATCH...]" patterns
+ re := regexp.MustCompile(`(?i)^Subject:\s*(\[\s*PATCH[^\]]*\]\s*)?`)
+ cleaned := re.ReplaceAllString(line, "")
+ return strings.TrimSpace(cleaned)
+}
+
+// jcarr@framebook:~/go/src/go.wit.com/lib/protobuf/forgepb$ git branch --contains 4a27e7702b9b975b066ec9d2ee7ac932d86552e3
+// * jcarr
+// jcarr@framebook:~/go/src/go.wit.com/lib/protobuf/forgepb$ git merge-base --is-ancestor "4a27e7702b9b975b066ec9d2ee7ac932d86552e3" "devel" ; echo $?
+// 1
+// jcarr@framebook:~/go/src/go.wit.com/lib/protobuf/forgepb$ git merge-base --is-ancestor "4a27e7702b9b975b066ec9d2ee7ac932d86552e3" "jcarr" ; echo $?
+// 0
+
+func findCommitBySubject(subject string) (string, error) {
+ cmd := exec.Command("git", "log", "--pretty=format:%H %s", "--grep="+subject, "-i")
+ var out bytes.Buffer
+ cmd.Stdout = &out
+ err := cmd.Run()
+ if err != nil {
+ return "", err
+ }
+
+ lines := strings.Split(out.String(), "\n")
+ for _, line := range lines {
+ if strings.Contains(strings.ToLower(line), strings.ToLower(subject)) {
+ return strings.Fields(line)[0], nil // return the commit hash
+ }
+ }
+ return "", fmt.Errorf("no commit found for subject: %s", subject)
+}