Skip to content

Commit

Permalink
feat: include prs
Browse files Browse the repository at this point in the history
  • Loading branch information
moul committed Oct 7, 2018
1 parent e239e48 commit 7e77b19
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cmd_airtable.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion cmd_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}

Expand Down
14 changes: 11 additions & 3 deletions issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]+)`)
Expand Down Expand Up @@ -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
}
}
Expand All @@ -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)
Expand All @@ -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
}
}
Expand Down

0 comments on commit 7e77b19

Please sign in to comment.