Skip to content
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

fix: dir no longer panics when HOME and XDG_CONFIG_HOME are not set #451

Merged
merged 1 commit into from
Sep 5, 2024

Conversation

Two-Hearts
Copy link
Contributor

This PR is for release-1.2 branch only.

This PR cherry picks the fix of issue #446 from main.

The fix:

  • Removed the init() function from dir/path
  • When userConfigDir() returns an error, instead of panic(err), default to the current directory instead
  • Split loadUserPath() into two new functions used to setup and return the values for UserConfigDir and UserLibexecDir
  • Added additional unit tests for the two new functions and to test the default directory is used when HOME is set to ""

…otaryproject#449)

This PR addresses the issue notaryproject#446

In this PR I:

- I removed the `init()` function from `dir/path`
- When `userConfigDir()` returns an error, instead of `panic(err)` I
default to the current directory instead
- Split `loadUserPath()` into two new functions used to setup and return
the values for `UserConfigDir` and `UserLibexecDir`
- Added additional unit tests for the two new functions and to test the
default directory is used when `HOME` is set to `""`

---------

Signed-off-by: Jason <[email protected]>
Signed-off-by: JasonTheDeveloper <[email protected]>
Signed-off-by: Patrick Zheng <[email protected]>
Co-authored-by: Shiwei Zhang <[email protected]>
Co-authored-by: Patrick Zheng <[email protected]>
Copy link

codecov bot commented Sep 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.34%. Comparing base (07b2508) to head (0e4fbf0).
Report is 1 commits behind head on release-1.2.

Additional details and impacted files
@@               Coverage Diff               @@
##           release-1.2     #451      +/-   ##
===============================================
+ Coverage        81.21%   81.34%   +0.12%     
===============================================
  Files               32       32              
  Lines             2279     2283       +4     
===============================================
+ Hits              1851     1857       +6     
+ Misses             299      298       -1     
+ Partials           129      128       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@JeyJeyGao JeyJeyGao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@shizhMSFT shizhMSFT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@priteshbandi priteshbandi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Two-Hearts Two-Hearts merged commit f31b896 into notaryproject:release-1.2 Sep 5, 2024
9 checks passed
@Two-Hearts Two-Hearts deleted the release-1.2 branch September 5, 2024 00:50
@Two-Hearts Two-Hearts mentioned this pull request Sep 5, 2024
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants