Skip to content

Commit

Permalink
Make tracked_refs optional
Browse files Browse the repository at this point in the history
If an edition has a tracked_refs key of None, then the GitHub link is
simply not shown.

An edition can have tracked_refs = None because it uses an alternative
tracking mode.

Also switch to using the edition's `slug` field instead of the
`git_refs` because the slug should always be present.
  • Loading branch information
jonathansick committed Jul 11, 2018
1 parent 67672bc commit 1ab457f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
24 changes: 19 additions & 5 deletions app/dashboard/render.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,14 @@ def _insert_github_ref_url(product, edition_dataset,
"""
base_repo_url = product['doc_repo'].rstrip('.git')
for k, d in edition_dataset.items():
git_ref = d[git_refs_key][0]
# Editions that don't use the git_refs tracking mode will have
# tracked_refs equal to None.
try:
git_ref = d[git_refs_key][0]
except TypeError:
# None is not indexable
continue

# https://github.com/lsst-sqre/ltd-dasher/tree/tickets/DM-9023
url = base_repo_url + '/tree/' + git_ref
d[key] = url
Expand All @@ -182,7 +189,14 @@ def _insert_jira_url(edition_dataset, git_refs_key='tracked_refs',
re-thought for multi-repo LTD products.
"""
for k, d in edition_dataset.items():
git_ref = d[git_refs_key][0]
# Editions that don't use the git_refs tracking mode will have
# tracked_refs equal to None.
try:
git_ref = d[git_refs_key][0]
except TypeError:
# None is not indexable
continue

match = TICKET_BRANCH_PATTERN.search(git_ref)
if match is not None:
ticket_name = match.group(1)
Expand Down Expand Up @@ -251,11 +265,11 @@ def _insert_is_release(editions,
Heuristic for guessing a release: edition slug begins with `v` and a digit.
"""
for k, d in editions.items():
git_ref = d['tracked_refs'][0]
match = RELEASE_PATTERN.search(git_ref)
slug = d['slug']
match = RELEASE_PATTERN.search(slug)
if match is not None:
d[is_release_key] = True
d[alt_title_key] = git_ref
d[alt_title_key] = slug
else:
d[is_release_key] = False

Expand Down
2 changes: 2 additions & 0 deletions app/dashboard/templates/_edition_item.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@
<span><span class="svg-icon svg-icon--left svg-icon--jira svg-baseline"><svg><use xlink:href="#icon-jira-blue" /></svg></span> <a href="{{ item.jira_url }}">{{ item.jira_ticket_name }}</a></span>
</div>
{% endif %}
{% if item.github_ref_url %}
<div class="inventory-item-metadata__github-branch-box">
{# FIXME could have an edition with multiple branches (multi-repo products)
For the MVP I'm ignoring this. #}
<span><span class="svg-icon svg-icon--left svg-baseline"><svg><use xlink:href="#octicon-mark-github" /></svg></span><a href="{{ item.github_ref_url }}">View source</a></span>
</div>
{% endif %}
</div>
</article>

0 comments on commit 1ab457f

Please sign in to comment.