-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add RepoClient as wrapper that auto-detects and supports both git & hg #6
Conversation
I wonder if we could have the "apply black formatting" as a completely separate PRs? It makes reviewing unnecessarily hard, even with separate commits. I'd be OK with you landing that change directly without review, since that's the standard we use all over the place. |
Done, and rebased also this PR. |
Rebased as #5 was merged. Also exposed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed this and nothing stands out to me so approving. Next time there's a migration ready I'll attempt a test with this.
import hglib | ||
|
||
|
||
def git(root: str, *args: str) -> str: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you considered (and discarded) the idea of using a library similar to hglib for git?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. This way we avoid a layer of indirection in needing to refer to an external definition for what git()
does, and have instead this minimal six-line function that's sufficient for our purposes.
Co-authored-by: Eemeli Aro <eemeli@mozilla.com>
This builds on top of #5, so at least currently these are the only proper changes here.A new
RepoClient
class is added, with a minimal set of methods as required by the rest of the library for repository operations. A Mercurial repo is detected from the presence of a.hg
directory, and for Git we look for.git
and check thatgit rev-parse --is-inside-work-tree
returnstrue
.The
hglib
stuff should work just as before; for git we don't need any wrapper library as the command line is plenty. For the blame I did need to write a minimal parser, but that was only about 10 lines of code.The
Blame().handleFile()
function signature changed a bit through all this, but AFAIK that has no external users.