-
-
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
Use gitpython for tags #4052
Use gitpython for tags #4052
Conversation
We may want to change all the class with gitpython in the future and have a repo object shared across methods. |
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.
Looks good so far. Perhaps it's better to use future's str
via from builtins import str
? I'm not sure what error you're hitting there otherwise.
Also, i might be good to look at #3839. #2997 is another. The attempt there is to support utf8 branches, which break because of the csvreader. The tests probably won't translate, but we should be trying to break the gitpython support in tests probably -- so perhaps throw some utf8 tags in?
This PR will translate pretty easily to parsing branches as well, that might be a good next target.
VCSVersion(self, str(tag.commit), str(tag)) | ||
for tag in repo.tags | ||
] | ||
return versions |
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.
❤️ so much cleaner and no csv parsing hacks!
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.
But no tests.
Shouldn't we have a new test for the new "parser". I mean, at least a test that check that given a valid repo it returns a list if VCSVersion objects? |
@humitos I hesitated to add a test here because basically, we would be testing an external library, but I'll try to add a test to check if we return VCSVersion objects. |
No problem at all, I'll try to do a manual build with a unicode tag. Test added (I took the unicode test from #2997 :) ) |
The Unicode test did not pass :/ on py2 |
Why it does fail in py2? I think we should support the unicode tags in py2. Is it to hard to make it work? Also, the test seems that doesn't pass in py3 either: https://travis-ci.org/rtfd/readthedocs.org/jobs/376123608 |
readthedocs/rtd_tests/utils.py
Outdated
chdir(path) | ||
return directory | ||
|
||
|
||
def create_tag(directory, tag, annotated=False): |
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.
create_git_tag
maybe?
and I think that directory
can be renamed to path
also, to keep the same wording.
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.
Directory makes reference to the tmp directory, and path is used for the cwd,
create_tag(repo_path, 'release-ünîø∂é') | ||
repo = self.project.vcs_repo() | ||
# Hack the repo path | ||
repo.working_dir = repo_path |
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.
Why do we need to do this here?
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.
Because we don't make the clone
part, so the vcs object will try to search the repo in /project/checkouts/...
. Sorry for the late reply, I was focused in fixin the unicode problem 😁
Not sure about that, tests are passing locally with py3, I'll push a test for py3 only |
The tests on py2 aren't passing because of the subprocess call, I was reading the docs, and didn't found anything useful. |
I tested gitpython on py2 and py3, in both versions gitpython work with unicode tags, the problem here is with the subprocess call on the tests, going to take a deep look there |
readthedocs/rtd_tests/utils.py
Outdated
env=env).communicate()[0] | ||
def check_output(l, env=None): | ||
output = subprocess.Popen( | ||
l, stdout=subprocess.PIPE, universal_newlines=True, env=env |
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.
Took te solution from https://stackoverflow.com/a/27775464/5689214
Well, at least tests are passing on py2 with unicode tags 😪 |
|
Also replicated on |
So, I tested this with python |
According to the docs the |
This looks like a solid step forward. I am a bit scared because we blew up projects previously with a similar change to this. @stsewd have you tested this locally on a few projects and confirmed it's working well? I'm definitely +1 on this change, but don't want to break tag updating again :) |
@ericholscher I going to do more manual tests and also with github integration and report back (I think the last time it broke was because the git version that was used in production, I'm testing with |
@ericholscher I did some manual tests, this fixes the |
@stsewd is there a good way for us to at least skip unicode tags, instead of breaking the build completely? That would at least be a good step forward, and less disruptive. |
@ericholscher I think we can catch the |
Not sure I'm following here. The tests do work on Travis, but they don't work on your local I could add more info here by testing it in my local instance to check for potential environment variable issues. Let me know what would be the steps to follow and test. |
@humitos they pass in tox, but manual QA fails in the same code that is tested. |
I don't think we should block this on unicode though, since it's already broken. We should follow up on unicode support in #3060, but I think I'm +1 on merging this. |
I wasn't able to make it work setting and unsetting some variables, I think we'll figure out on prod if we can use unicode tags p: |
I think unicode will break things downstream, so it is likely best to skip them for now. But we should discuss this more in #3060, and see if we can at least skip them gracefully. |
What is needed for this fix to be effective in the various projects' documentation that use readthedocs.org (e.g. https://restic.readthedocs.io/en/stable/ which has a broken Edit button)? |
@rawtaz just need to wait for the code to be deployed and then I think you probably need to rebuild your project too. |
@stsewd Thanks :) Any idea when the code will be deployed, or more specifically what should I keep an eye on to know when it happens? |
RTD is deployed from the https://docs.readthedocs.io/en/latest/faq.html#what-commit-of-read-the-docs-is-in-production |
@rawtaz today this was deployed, let us know if there is a problem |
Fix #1820
It has been previous attempts to fix the issue with annotated tags (#3302).
I'm using git python to get the tags, I tested this with a local repo with annotated and lightweight tags and it works as expected :).
I'm little worried about pyhon2 here since we need to use
str
to get the info. I did two builds using py2 (one with tags and other with no tags) and works as expected.Refs #3839