-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Sync versions: filter by type on update #9019
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
Conversation
If two versions share the same verbose name (a branch named 2.0 and a tag named 2.0), then we will be updating both, instead of just one and changing its type from branch to tag. Later when running this same code, it will see the branch as new, since isn't included in our queryset that filters by type=branch. This wasn't happening before because this check was true https://github.com/readthedocs/readthedocs.org/blob/2e3f208c4906de649a9b5b9e33afee6cc20b86bc/readthedocs/api/v2/utils.py#L74-L74 Since a branch would never change its identifier (origin/name), but once lsremote was enabled, the identifier didn't included the 'origin/' part. So, when doing a full build the branches would be changed to (origin/name) and when doing a syn they would be changed to (name), and so on. Ref #8992 (comment)
We still need to fix the problem of lsremote and gitpython returning different identifiers (origin/name vs name) |
readthedocs/api/v2/utils.py
Outdated
Version.objects.filter( | ||
project=project, | ||
verbose_name=version_name, | ||
type=type, | ||
).update( | ||
identifier=version_id, | ||
type=type, | ||
machine=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.
It would be good to explain with a comment in code the situation described in the description of the PR.
Is this really possible? I do see that we have a readthedocs.org/readthedocs/builds/models.py Line 181 in 2e3f208
|
It would be good to make |
that's slug, here the duplicates are in the verbose_name |
That's together with this change, otherwise will happen the same if a tag is updated |
So, about lsremote and gitpython returning the same values for branches, we could match the output of lsremote to the one from gitpython or the other way around. I'm not really sure why we include the remote part What I see: And other thing, whatever we choose, it will hit this code for a lot of versions readthedocs.org/readthedocs/api/v2/utils.py Lines 79 to 88 in 12b5889
Since the content will be changed from |
Okay, looks like |
Are we sure the Also, I found this repository that has different removes on some of their branches:
|
from the docs
|
Tested with gitpython, it doesn't list any other remotes, only origin, and those aren't included there. |
Looks like on checkout we always add the
readthedocs.org/readthedocs/vcs_support/backends/git.py Lines 354 to 357 in 3456634
|
It's redundant as we always have only one remote (origin), and we need to match the same behavior of lsremote.
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! Let's re-enable lsremote feature after merging/deploying this.
If two versions share the same verbose name
(a branch named 2.0 and a tag named 2.0),
then we will be updating both,
instead of just one and changing its type from branch to tag.
Later when running this same code,
it will see the branch as new, since isn't included in our queryset that
filters by type=branch.
This wasn't happening before because this check was true
readthedocs.org/readthedocs/api/v2/utils.py
Line 74 in 2e3f208
Since a branch would never change its identifier
(origin/name), but once lsremote was enabled,
the identifier didn't included the 'origin/' part.
So, when doing a full build the branches would be changed
to (origin/name) and when doing a syn they would be changed
to (name), and so on.
Ref #8992 (comment)