FindCommitForStory searches the git log for a commit whose subject line matches the chief commit format "feat: - ". Both the story ID and title are required to avoid false positives from previous PRD runs that may reuse the same story IDs. Returns the commit hash if found, empty str
(dir, storyID, title string)
| 153 | // previous PRD runs that may reuse the same story IDs. |
| 154 | // Returns the commit hash if found, empty string otherwise. |
| 155 | func FindCommitForStory(dir, storyID, title string) (string, error) { |
| 156 | cmd := exec.Command("git", "log", "--fixed-strings", "--grep=feat: "+storyID+" - "+title, "--format=%H", "-1") |
| 157 | cmd.Dir = dir |
| 158 | output, err := cmd.Output() |
| 159 | if err != nil { |
| 160 | return "", err |
| 161 | } |
| 162 | hash := strings.TrimSpace(string(output)) |
| 163 | return hash, nil |
| 164 | } |
| 165 | |
| 166 | // getMergeBase returns the merge base commit between two refs. |
| 167 | func getMergeBase(dir, ref1, ref2 string) (string, error) { |