diff --git a/cmd_airtable.go b/cmd_airtable.go index 5964750e0..643cce6d4 100644 --- a/cmd_airtable.go +++ b/cmd_airtable.go @@ -62,7 +62,7 @@ func airtableSync(opts *airtableOptions) error { if err != nil { return errors.Wrap(err, "failed to load issues") } - if err := issues.prepare(); err != nil { + if err := issues.prepare(true); err != nil { return errors.Wrap(err, "failed to prepare issues") } issues.filterByTargets(opts.Targets) diff --git a/cmd_run.go b/cmd_run.go index 525d904fb..53e98cd2f 100644 --- a/cmd_run.go +++ b/cmd_run.go @@ -81,7 +81,7 @@ func graphviz(opts *graphOptions) (string, error) { return "", errors.Wrap(err, "failed to load issues") } - if err := issues.prepare(); err != nil { + if err := issues.prepare(false); err != nil { return "", errors.Wrap(err, "failed to prepare issues") } diff --git a/issue.go b/issue.go index 1446e0089..60349a0af 100644 --- a/issue.go +++ b/issue.go @@ -437,7 +437,7 @@ func (i Issue) AddNodeToGraph(g *gographviz.Graph, parent string) error { ) } -func (issues Issues) prepare() error { +func (issues Issues) prepare(includePRs bool) error { var ( dependsOnRegex, _ = regexp.Compile(`(?i)(require|requires|blocked by|block by|depend on|depends on|parent of) ([a-z0-9:/_.-]+issues/[0-9]+|[a-z0-9:/_.-]+#[0-9]+|[a-z0-9/_-]*#[0-9]+)`) blocksRegex, _ = regexp.Compile(`(?i)(blocks|block|address|addresses|part of|child of|fix|fixes) ([a-z0-9:/_.-]+issues/[0-9]+|[a-z0-9:/_.-]+#[0-9]+|[a-z0-9/_-]*#[0-9]+)`) @@ -506,7 +506,7 @@ func (issues Issues) prepare() error { if len(issue.Duplicates) > 0 { issue.Hidden = true } - if issue.IsPR { + if !includePRs && issue.IsPR { issue.Hidden = true } } @@ -531,6 +531,14 @@ func (issues Issues) filterByTargets(targets []string) { } func (i Issue) MatchesWithATarget(targets []string) bool { + return i.matchesWithATarget(targets, 0) +} + +func (i Issue) matchesWithATarget(targets []string, depth int) bool { + if depth > 100 { + log.Printf("very high blocking depth (>100), do not continue. (issue=%s)", i) + return false + } issueParts := strings.Split(strings.TrimRight(i.URL, "/"), "/") for _, target := range targets { fullTarget := i.GetRelativeIssueURL(target) @@ -547,7 +555,7 @@ func (i Issue) MatchesWithATarget(targets []string) bool { } for _, parent := range i.Blocks { - if parent.MatchesWithATarget(targets) { + if parent.matchesWithATarget(targets, depth+1) { return true } }