Skip to content

Commit

Permalink
Fix the case where only a single file changed. (#17)
Browse files Browse the repository at this point in the history
If only a single file changed, then the shortstat will
contain the phrase 'file' instead of 'files', which our
regex didn't pick up properly.

Once we have that in place, we should then also present
it as 'file' properly in the HTML.

This commit fixes both of those problems.

Signed-off-by: Chris Lalancette <[email protected]>
  • Loading branch information
clalancette authored Sep 18, 2023
1 parent 11cf819 commit a5f56bc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
12 changes: 9 additions & 3 deletions pages/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ <h1 id="head"></h1>
return "DETACHED"
}

if (row.release_delta.shortstat.files_changed == 0 &&
if (row.release_delta.shortstat.files_changed == 0 &&
row.release_delta.shortstat.insertions == 0 &&
row.release_delta.shortstat.deletions == 0
)
Expand All @@ -164,11 +164,17 @@ <h1 id="head"></h1>
name = name.replace('/', '_')

ret = ''
ret += '<span>' + row.release_delta.shortstat.files_changed + ' files changed</span><br/>'
if (row.release_delta.shortstat.files_changed == 1) {
files_changed_text = ' file changed'
} else {
files_changed_text = ' files changed'
}

ret += '<span>' + row.release_delta.shortstat.files_changed + files_changed_text + '</span><br/>'
ret += '<span style="color: green">' + row.release_delta.shortstat.insertions+ ' insertions(+)</span><br/>'
ret += '<span style="color: red">' + row.release_delta.shortstat.deletions+ ' deletions(-)</span>'

ret += '<div class="modal" tabindex="-1" role="dialog" id="modal_' + name + '">' +
ret += '<div class="modal" tabindex="-1" role="dialog" id="modal_' + name + '">' +
' <div class="modal-dialog modal-lg" role="document">' +
' <div class="modal-content">' +
' <div class="modal-header">' +
Expand Down
2 changes: 1 addition & 1 deletion src/osr_dashboard/command/compute.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def compute_repo_stats(repo: Repository, generation_time: datetime.datetime):
}
)

match = re.search(r"(\d+) files changed", shortstat)
match = re.search(r"(\d+) files? changed", shortstat)
files_changed = match.groups()[0] if match else 0

match = re.search(r"(\d+) insertions", shortstat)
Expand Down

0 comments on commit a5f56bc

Please sign in to comment.