o2sh / onefetch

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

Bare repository support #1299

Open walderich opened 7 months ago

walderich commented 7 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 7 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 7 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

halshar commented 2 months ago

do we have any updates on this or the bare support is still in draft?

spenserblack commented 2 months ago

No updates. I've been very slow on https://github.com/o2sh/onefetch/pull/1305, even though not much work is left :bow: If we ever support bare repos we'll need to make that switch, since I highly doubt that Tokei would ever behave in such a specialized manner.

So here's roughly what's left:

After that's done I think it will be pretty easy to support bare repositories for language detection (licenses and package manifests are a different story).

halshar commented 2 months ago

thank you for the update and please take your time and thanks again for your work :)

spenserblack commented 2 months ago

Thank you! If you're interested, you can help add language support to Gengo (https://github.com/spenserblack/gengo/issues/34). It's roughly 90% done -- it looks like I've slowed down the closer I got to the finish line :sweat_smile: :checkered_flag: :snail:

Contributing language support is pretty easy. If you're familiar with the language, great! If not, it just takes some quick research to find at least one popular file extensions and/or filename for the language. Besides that, there's just picking a primary color for the language.