Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: include prs #105

Merged
merged 1 commit into from
Oct 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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