o2sh/onefetch

Bare repository support

Opened this issue ยท 6 comments

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).

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. #1152 (comment)).

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

  • Manifests (package.json, Cargo.toml)
  • License files

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:

onefetch/src/info/mod.rs

Lines 113 to 120 in 3cdc171

let mut repo = gix::ThreadSafeRepository::discover_opts(
&cli_options.input,
gix::discover::upwards::Options {
dot_git_only: true,
..Default::default()
},
Mapping::default(),
)?

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

No updates. I've been very slow on #1305, even though not much work is left ๐Ÿ™‡ 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:

  • Support remaining few languages in Gengo that Onefetch needs to not throw a compiler error (or at least have a very good reason to drop a language's support)
  • Release a new version of Gengo (this part's trivial)

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).

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

Thank you! If you're interested, you can help add language support to Gengo (spenserblack/gengo#34). It's roughly 90% done -- it looks like I've slowed down the closer I got to the finish line ๐Ÿ˜…
๐Ÿ ๐ŸŒ

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.