Skip to content

Commit 9eec993

Browse files
committed
action: List both branches and tags a commit is pointed to
Not only branches, but tags can also point to the new SHA, and that is relevant information that should be displayed. Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
1 parent 375c392 commit 9eec993

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

action.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,11 +182,12 @@ def fmt_rev(repo, rev):
182182

183183
try:
184184
if is_sha(rev):
185-
branches = [f'`{b.name}`' for b in repo.get_branches() if rev ==
186-
b.commit.sha]
185+
all_refs = [b for b in repo.get_branches()] + \
186+
[t for t in repo.get_tags()]
187+
refs = [f'`{r.name}`' for r in all_refs if rev == b.commit.sha]
187188
s = repo.get_commit(rev).html_url
188189
# commits get formatted nicely by GitHub itself
189-
return s + f' ({",".join(branches)})' if len(branches) else s
190+
return s + f' ({",".join(refs)})' if len(refs) else s
190191
elif rev in [t.name for t in repo.get_tags()]:
191192
# For some reason there's no way of getting the URL via API
192193
s = f'{repo.html_url}/releases/tag/{rev}'

0 commit comments

Comments
 (0)