Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fail when there is no remote in git repo #832

Closed
forieux opened this issue Oct 24, 2022 · 6 comments
Closed

Fail when there is no remote in git repo #832

forieux opened this issue Oct 24, 2022 · 6 comments
Assignees
Labels
bug Something isn't working stale

Comments

@forieux
Copy link

forieux commented Oct 24, 2022

When I execute onefetch in a local git repo where no remote is set I have a failure. onefetch is installed with cargo and updated to the last version

thread 'main' panicked at 'non-empty path', ~/.cargo/registry/src/github.heygears.com-1ecc6299db9ec823/onefetch-2.13.1/src/info/repo/project.rs:31:10
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

@spenserblack
Copy link
Collaborator

spenserblack commented Oct 24, 2022

Thanks for raising this! Since onefetch is supposed to work without fetching any remote data, it makes sense to me that we should support repositories that don't even have a remote.

Perhaps as a reasonable fallback, we can use the name of the directory as the project's name when there is no remote URL.

TBH I was a bit surprised that the error occurred here instead of somewhere before.

Digging into the code, it's because we just use an empty string when there are no remotes. I think it makes sense to avoid converting None into "", though some refactoring may be in order to achieve that to None an actual expected possible value without it being an error).

I guess this counts as an enhancement since we don't have any intended behavior for repos without remotes as far as I remember 🤷

@spenserblack spenserblack added the enhancement New feature or request label Oct 24, 2022
@o2sh
Copy link
Owner

o2sh commented Oct 24, 2022

Sadly, it seems to be a regression

v2.12.0
image

v2.13.1
image

@spenserblack spenserblack added bug Something isn't working and removed enhancement New feature or request labels Oct 24, 2022
@spenserblack
Copy link
Collaborator

Thanks for pointing that out, @o2sh! Didn't realize we had previously supported remoteless repositories. Updated labels to match.

@o2sh
Copy link
Owner

o2sh commented Oct 30, 2022

Should be fixed in the latest release

@o2sh
Copy link
Owner

o2sh commented Nov 1, 2022

Perhaps as a reasonable fallback, we can use the name of the directory as the project's name when there is no remote URL.

I think it makes sense to avoid converting None into "", though some refactoring may be in order to achieve that to None an actual expected possible value without it being an error).

Do we keep this open to implement @spenserblack's suggestion?

@o2sh
Copy link
Owner

o2sh commented Feb 5, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@o2sh o2sh added the stale label Feb 5, 2023
@o2sh o2sh closed this as not planned Won't fix, can't repro, duplicate, stale Feb 12, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working stale
Projects
None yet
Development

No branches or pull requests

3 participants