diff options
Diffstat (limited to 'patch.Make.go')
| -rw-r--r-- | patch.Make.go | 22 |
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) |
