Remove git.properties error log#3179
Conversation
Overall package sizeSelf size: 4.17 MB Dependency sizes
🤖 This report was automatically generated by heaviest-objects-in-the-universe |
Codecov Report
@@ Coverage Diff @@
## master #3179 +/- ##
==========================================
+ Coverage 86.54% 86.57% +0.02%
==========================================
Files 333 333
Lines 11892 11895 +3
Branches 33 33
==========================================
+ Hits 10292 10298 +6
+ Misses 1600 1597 -3
... and 2 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
| let gitPropertiesString | ||
| try { | ||
| gitPropertiesString = fs.readFileSync(DD_GIT_PROPERTIES_FILE, 'utf8') | ||
| } catch (e) { | ||
| // Only log error if the user has set a git.properties path | ||
| if (process.env.DD_GIT_PROPERTIES_FILE) { | ||
| log.error(e) | ||
| } | ||
| } |
There was a problem hiding this comment.
| let gitPropertiesString | |
| try { | |
| gitPropertiesString = fs.readFileSync(DD_GIT_PROPERTIES_FILE, 'utf8') | |
| } catch (e) { | |
| // Only log error if the user has set a git.properties path | |
| if (process.env.DD_GIT_PROPERTIES_FILE) { | |
| log.error(e) | |
| } | |
| } | |
| let gitPropertiesString | |
| if (process.env.DD_GIT_PROPERTIES_FILE) { | |
| gitPropertiesString = maybeFile(DD_GIT_PROPERTIES_FILE); | |
| } |
How about this? It'd still delegate to maybeFile so we aren't duplicating much of its code here. You could even preserve this being const if you replaced the if with ?: but that's secondary (so sad if isn't an expression but a statement…)
There was a problem hiding this comment.
ignore this, I realized it's resulting in different behavior. You still want to opportunistically load the file when it's present even if it isn't requested.
There was a problem hiding this comment.
indeed. It isn't great but I don't want to pass DD_GIT_PROPERTIES_FILE to maybeFile, so this is what we're left with
What does this PR do?
Do not
log.errorifgit.propertiesis not found, unless the user has explicitly attempted to setDD_GIT_PROPERTIES_FILEMotivation
git.propertiesfile will often not be found, so logging an error if it isn't found is mostly noise.This PR changes the
log.errorlogic to only show if the user has explicitly set aDD_GIT_PROPERTIES_FILEenv var, at which point the user is trying to leveragegit.properties.