diff options
Diffstat (limited to 'doPatch.go')
| -rw-r--r-- | doPatch.go | 15 |
1 files changed, 12 insertions, 3 deletions
@@ -108,11 +108,16 @@ func doPatchList() error { } if newId != patch.PatchId { log.Info(patch.PatchId, "probably duplicate subject", patch.Comment) + // try this. it should compute every patch id in the repo + // os.Chdir(repo.FullPath) + // newNewId, err := searchAllCommits(targetPatchID string) (string, error) { } log.Info("new patch", patch.PatchId, patch.Comment) if !argv.Fix { log.Info("use --fix to attempt to apply new patches") } else { + log.Info(string(patch.Data)) + log.Info("repo:", repo.FullPath, "patch header:", patch.Comment, patch.CommitHash) if fhelp.QuestionUser("apply this patch?") { newhash, err := applyPatch(repo, patch) log.Info("apply results:", newhash, err) @@ -208,7 +213,7 @@ func isPatchIdApplied(repo *gitpb.Repo, patch *forgepb.Patch) (string, string, e comment := cleanSubject(patch.Comment) os.Chdir(repo.GetFullPath()) - newhash, err := findCommitBySubject(comment) + newhash, err := findCommitBySubject(repo, comment, patch) if err != nil { return "", "", ErrorGitPullOnDirty } @@ -260,7 +265,7 @@ func cleanSubject(line string) string { // 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) { +func findCommitBySubject(repo *gitpb.Repo, subject string, newpatch *forgepb.Patch) (string, error) { cmd := exec.Command("git", "log", "--pretty=format:%H %s", "--grep="+subject, "-i") var out bytes.Buffer cmd.Stdout = &out @@ -272,7 +277,11 @@ func findCommitBySubject(subject string) (string, error) { 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 + parts := strings.Fields(line) + patchId, _ := repo.FindPatchIdByHash(parts[0]) + if patchId == newpatch.PatchId { + return strings.Fields(line)[0], nil // return the commit hash + } } } return "", fmt.Errorf("no commit found for subject: %s", subject) |
