diff --git a/jira-dependency-graph.py b/jira-dependency-graph.py index c0dd9bc..0bd3a29 100755 --- a/jira-dependency-graph.py +++ b/jira-dependency-graph.py @@ -113,6 +113,11 @@ def process_link(fields, issue_key, link): linked_issue = link[direction + 'Issue'] linked_issue_key = get_key(linked_issue) + + if skip_issue(linked_issue_key, linked_issue['fields']): + # logging present in skip_issue(), hence bare return here + return + if linked_issue_key in issue_excludes: log('Skipping ' + linked_issue_key + ' - explicitly excluded') return @@ -159,12 +164,7 @@ def walk(issue_key, graph): fields = issue['fields'] seen.append(issue_key) - if ignore_closed and (fields['status']['name'] in 'Closed'): - log('Skipping ' + issue_key + ' - it is Closed') - return graph - - if not traverse and ((project_prefix + '-') not in issue_key): - log('Skipping ' + issue_key + ' - not traversing to a different project') + if skip_issue(issue_key, fields): return graph graph.append(create_node_text(issue_key, fields, islink=False)) @@ -175,11 +175,12 @@ def walk(issue_key, graph): for subtask in issues: subtask_key = get_key(subtask) log(subtask_key + ' => references epic => ' + issue_key) - node = '{}->{}[color=orange]'.format( - create_node_text(issue_key, fields), - create_node_text(subtask_key, subtask['fields'])) - graph.append(node) - children.append(subtask_key) + if not skip_issue(subtask_key, subtask['fields']): + node = '{}->{}[color=orange]'.format( + create_node_text(issue_key, fields), + create_node_text(subtask_key, subtask['fields'])) + graph.append(node) + children.append(subtask_key) if 'subtasks' in fields and not ignore_subtasks: for subtask in fields['subtasks']: subtask_key = get_key(subtask) @@ -203,6 +204,15 @@ def walk(issue_key, graph): walk(child, graph) return graph + def skip_issue(issue_key, fields): + if ignore_closed and (fields['status']['name'] in 'Closed'): + log('Skipping ' + issue_key + ' - it is Closed') + return True + if not traverse and ((project_prefix + '-') not in issue_key): + log('Skipping ' + issue_key + ' - not traversing to a different project') + return True + return False + project_prefix = start_issue_key.split('-', 1)[0] return walk(start_issue_key, [])