summaryrefslogtreecommitdiff
path: root/patch.Make.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-01-05 04:54:31 -0600
committerJeff Carr <[email protected]>2025-01-05 04:54:31 -0600
commitb0662fb61a824b39c9a11b3bbc05b2543841ae74 (patch)
treef1505da65b14c1243c28259f8207ecbcfbd805a9 /patch.Make.go
parentac57825c107b84a8728cea425a1f3f639ab146a8 (diff)
add commit hash and diff file list to the protobuf
Diffstat (limited to 'patch.Make.go')
-rw-r--r--patch.Make.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/patch.Make.go b/patch.Make.go
index 0920fdf..f43d9be 100644
--- a/patch.Make.go
+++ b/patch.Make.go
@@ -5,6 +5,7 @@ import (
"fmt"
"os"
"path/filepath"
+ "strings"
"go.wit.com/lib/protobuf/gitpb"
"go.wit.com/log"
@@ -136,6 +137,7 @@ func (p *Patchs) addPatchFiles(repo *gitpb.Repo) error {
patch := new(Patch)
patch.Filename, _ = filepath.Rel(p.TmpDir, path)
patch.Data = data
+ patch.parseData()
patch.StartHash = repo.DevelHash()
p.Patchs = append(p.Patchs, patch)
log.Info("ADDED PATCH FILE", path)
@@ -144,6 +146,26 @@ func (p *Patchs) addPatchFiles(repo *gitpb.Repo) error {
return baderr
}
+// looks at the git format-patch output
+// saves the commit Hash
+// saves the diff lines
+func (p *Patch) parseData() string {
+ lines := strings.Split(string(p.Data), "\n")
+ for _, line := range lines {
+ fields := strings.Fields(line)
+ if len(fields) < 2 {
+ continue
+ }
+ switch fields[0] {
+ case "From":
+ p.CommitHash = fields[1]
+ case "diff":
+ p.Files = append(p.Files, line)
+ }
+ }
+ return ""
+}
+
// just an example of how to walk only directories
func onlyWalkDirs(pDir string) error {
log.Info("DIR", pDir)