-
Notifications
You must be signed in to change notification settings - Fork 327
Remove git.properties
error log
#3179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. 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) | |
} | |
} | |
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for fixing this!
What does this PR do?
Do not
log.error
ifgit.properties
is not found, unless the user has explicitly attempted to setDD_GIT_PROPERTIES_FILE
Motivation
git.properties
file will often not be found, so logging an error if it isn't found is mostly noise.This PR changes the
log.error
logic to only show if the user has explicitly set aDD_GIT_PROPERTIES_FILE
env var, at which point the user is trying to leveragegit.properties
.