openlawlibrary/stelae

Reverse parsing revisions?

Closed this issue · 1 comments

tombh commented

This isn't so much a Rust-specific issue. Although it did arise from a consideration of Rust types.

The Actix URI path for the current main entrypoint to the API is:
#[get("/{namespace}/{name}/{commitish}{remainder:(/[^{}]*)?}")]

I'm continuously surprised by the things Rust has types for, and my first thought at seeing the {commitish}{remainder:(/[^{}]*)?} part was whether there was a type for it. I did a bit of googling and saw that there's a project called gitoxide that's attempting a pure Rust implementation of Git. I supposed that if any project was to have a type for {commitish}{remainder:(/[^{}]*)?}, it would be that. Which I think it does, and indeed a lot more, consider its Revision trait.

But then I realised that maybe what this current Actix server here is doing is actually equivalent to:
git cat-file -p $(git rev-parse 3b18e512d:a/b/c.html)?

If that's the case then git2 actually already supports it, see this cat-file.rs function.

And if you're curious about gitoxide, it also already has a function for dumping the output of commitish-expressed objects.

I don't know what the advantages of gitoxide are over git2, apparently it claims to be faster in some cases. But I think switching over to it is another discussion, seeing as git2 already supports this object dumping behaviour.

resolved in 64970b3 by moving to repository.revparse_single.