o2sh / onefetch

Command-line Git information tool
https://onefetch.dev
MIT License
9.48k stars 269 forks source link

Bare repository support #1299

Open walderich opened 3 months ago

walderich commented 3 months ago

Summary 💡

Would it be possible to read repository information from a bare git repository? Currently only an error is printed that no repository can be found.

Motivation 🔦

I have a server running where all of my Git repositories are stored for synchronization. These are only bare repositories and it would be really helpful to get the statistics without cloning them or installing onefetch on every machine (I am developing on Windows, Linux and Mac).

spenserblack commented 3 months ago

Would it be possible to read repository information from a bare git repository?

Not as long as we use tokei, since that uses the actual files in the repository's directory, not the files in the git history. Though we might switch to a tool that can read bare repos.

Though we're still figuring out what the "source" for the files should be after the switch (e.g. https://github.com/o2sh/onefetch/pull/1152#discussion_r1313880761).

spenserblack commented 3 months ago

Sorry, I got a bit tunnel-visioned, I just realized, besides building language stats, onefetch reads files from "non-bare" repositories for

So, besides #1305 (supersedes #1152), we'd have to update those utilities to read from a git commit/index. I don't think these stats will break, but they won't be included until those are updated as well.

Also, if I'm not mistaken, our call to gix::ThreadSafeRepository::discover_opts doesn't currently support bare repos and would need to be updated: https://github.com/o2sh/onefetch/blob/3cdc171fad328e4423bb61211924156bc9451418/src/info/mod.rs#L113-L120