Skip to content

Commit 82259fe

Browse files
committed
fix: update logic to save changes only when score changes are detected
Signed-off-by: Sebastian Beltran <bjohansebas@gmail.com>
1 parent ad9dc47 commit 82259fe

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/action.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ async function run () {
106106
const { reportContent, issueContent, database: newDatabaseState, scores } = await generateScores({ scope, database, maxRequestInParallel, reportTagsEnabled, renderBadge, reportTool, positiveThreshold, negativeThreshold })
107107

108108
core.info('Checking database changes...')
109-
const hasChanges = isDifferent(database, newDatabaseState) || scores.filter(score => score.currentDiff !== undefined).length
109+
const hasChanges = isDifferent(database, newDatabaseState)
110110

111111
if (!hasChanges) {
112112
core.info('No changes to database, skipping the rest of the process')
@@ -115,8 +115,12 @@ async function run () {
115115

116116
// Save changes
117117
core.info('Saving changes to database and report')
118-
await writeFile(databasePath, JSON.stringify(newDatabaseState, null, 2))
119-
118+
const scoreChanges = scores.filter(score => score.currentDiff !== undefined)
119+
120+
if (scoreChanges.length) {
121+
await writeFile(databasePath, JSON.stringify(newDatabaseState, null, 2))
122+
}
123+
120124
if (reportContent) {
121125
await writeFile(reportPath, reportTagsEnabled
122126
? updateOrCreateSegment({

src/utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ const generateReportUrl = reportTool => (org, repo, commit, prevCommit) => {
5555
const generateReportContent = async ({ scores, reportTagsEnabled, renderBadge, reportTool }) => {
5656
core.debug('Generating report content')
5757
const scoresInScope = scores.filter(({ currentDiff }) => currentDiff)
58-
58+
5959
if (!scoresInScope.length) {
6060
core.debug('No score changes detected, skipping report generation')
6161
return null

0 commit comments

Comments
 (0)