diff --git a/cmd/stacks/stacks.go b/cmd/stacks/stacks.go
index bc70189..37d3524 100644
--- a/cmd/stacks/stacks.go
+++ b/cmd/stacks/stacks.go
@@ -435,7 +435,8 @@
issue.Number, err, block)
continue
}
- issue.predicate = pred
+ issue.predicate = block
+ issue.matches = pred
}
}
@@ -569,7 +570,7 @@
byPredicate := false
if strings.Contains(issue.Body, id) {
// nop
- } else if issue.predicate != nil && issue.predicate(stack) {
+ } else if issue.matches != nil && issue.matches(stack) {
byPredicate = true
} else {
continue
@@ -605,7 +606,16 @@
// Add a comment to the existing issue listing all its new stacks.
// (Save the ID of each stack for the second step.)
+ //
+ // We record the predicate expression at the time of
+ // the match, as the predicate in the issue body will
+ // evolve as users edit it and we need to leave a
+ // record of its history.
comment := new(bytes.Buffer)
+ if issue.predicate != "" {
+ fmt.Fprintf(comment, "\n\nFound new stacks for predicate:\n")
+ fmt.Fprintf(comment, "```\n#!stacks\n%s\n```\n\n", strings.TrimSpace(issue.predicate))
+ }
var newStackIDs []string
for _, stack := range issue.newStacks {
id := stackID(stack)
@@ -638,7 +648,7 @@
continue
}
- log.Printf("added stacks %s to issue #%d", newStackIDs, issue.Number)
+ log.Printf("added stacks %s to issue #%d (%s)", newStackIDs, issue.Number, issue.Title)
}
}
@@ -1156,7 +1166,8 @@
Milestone *Milestone
// Set by readIssues.
- predicate func(string) bool // matching predicate over stack text
+ predicate string // predicate source expression
+ matches func(string) bool // reports whether predicate over stack text
// Set by claimIssues.
newStacks []string // new stacks to add to existing issue (comments and IDs)