-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Simplify vcs_support backend git by using GitPython #3839
Comments
Just want to note here that I'm starting to feel uncomfortable with I mentioned some of these problem at: #4318 (comment) I'd like to start thinking for better alternatives. Although, I don't have one in mind yet. |
We are only missing |
But not sure if we want to replace those, the code looks more complex with git python p: - code, _, _ = self.run('git', 'status', record=False)
- return code == 0
+ try:
+ git.Repo(self.working_dir)
+ except InvalidGitRepositoryError:
+ return False
+ return True - code, out, _ = self.run('git', 'submodule', 'status', record=False)
- return code == 0 and bool(out)
+ repo = git.Repo(self.working_dir)
+ return bool(repo.submodules) |
If you think that we are ok with git status and git submodule status, we can close this issue. |
I like the consistency: all The code maybe looks longer, but it's more Pythonic, I'd say and we are relying on an external library instead of a local and custom command. I'm 👍 on migrating them also. |
We already started using GitPython for some submodules pieces. We should continue porting some of our hand rolled logic to use GitPython instead.
Pieces of
readthedocs.vcs_support.backend.git
we should definitely port:parse_branches()
-- this supersedes a branch I started at Add support for unicode Git tags/branches #2997 to replace parsing this with a csvreaderparse_tags()
-- same silly code using a csvreaderfind_ref()
ref_exists()
repo_exists()
Maybe:
tags()
branches()
These would be good first targets to port over, as we are executing these commands to get data out of the repository. It's not important that these messages are surfaced to users in build command output.
I'm going to block on getting a feature out that executes these commands in docker first though, as we need to clone and submodule checkout inside the docker container to isolate these calls. I can't quite consider how relying on gitpython for some of these calls, but not all, works with regard to docker vcs checkouts.
The text was updated successfully, but these errors were encountered: