Skip to content
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

Consistent version format #3504

Merged
merged 3 commits into from
May 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function init(data) {
warning
.find('a')
.attr('href', currentURL)
.text(data.version);
.text(data.slug);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to render a different value, right?

What's is version and what's slug here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is version used in another places? We should check that we can still access it now it's not a tuple anymore.

Copy link
Member Author

@stsewd stsewd Mar 23, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's is version and what's slug here?

I think your past self alreay answer that question 😄 #2357 (comment). Also #2357 (comment)

I did a grep and it is used here:

https://github.com/rtfd/readthedocs.org/blob/c5d102a4b119e191fd6a7ea201c776e84dd177f8/readthedocs/core/static-src/core/js/doc-embed/search.js#L16

But again thanks to the implicit cast of js everything was good (at the end everyone was expecting a string here p:)


var body = $("div.body");
if (!body.length) {
Expand Down
2 changes: 1 addition & 1 deletion readthedocs/restapi/views/footer_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def get_version_compare_data(project, base_version=None):
}
if highest_version_obj:
ret_val['url'] = highest_version_obj.get_absolute_url()
ret_val['slug'] = (highest_version_obj.slug,)
ret_val['slug'] = highest_version_obj.slug
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a single item. We were already biten by this issue and I saw a couple of drawbacks when changing this, and finally it stayed as it was (like a tuple).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that this should be a single item.

Technically, this changes a public API endpoint response which would involve a major rev of the API (ugh, one of the few downsides of semver). If instead we classify it as a bugfix, then perhaps it's ok.

Do we have any idea why it was an array instead of a simple string? This appears to date back to at least #1499 when the v2 footer API was added. Do we think it was a bug the whole time? There was additional discussion in #3394 (comment).

if base_version and base_version.slug != LATEST:
try:
base_version_comparable = parse_version_failsafe(
Expand Down
14 changes: 7 additions & 7 deletions readthedocs/rtd_tests/tests/test_footer.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def test_highest_version_from_stable(self):
valid_data = {
'project': 'Version 0.8.1 of Pip (19)',
'url': '/dashboard/pip/version/0.8.1/',
'slug': ('0.8.1',),
'slug': '0.8.1',
'version': '0.8.1',
'is_highest': True,
}
Expand All @@ -116,7 +116,7 @@ def test_highest_version_from_lower(self):
valid_data = {
'project': 'Version 0.8.1 of Pip (19)',
'url': '/dashboard/pip/version/0.8.1/',
'slug': ('0.8.1',),
'slug': '0.8.1',
'version': '0.8.1',
'is_highest': False,
}
Expand All @@ -129,7 +129,7 @@ def test_highest_version_from_latest(self):
valid_data = {
'project': 'Version 0.8.1 of Pip (19)',
'url': '/dashboard/pip/version/0.8.1/',
'slug': ('0.8.1',),
'slug': '0.8.1',
'version': '0.8.1',
'is_highest': True,
}
Expand Down Expand Up @@ -157,7 +157,7 @@ def test_highest_version_over_branches(self):
valid_data = {
'project': 'Version 1.0.0 of Pip ({})'.format(version.pk),
'url': '/dashboard/pip/version/1.0.0/',
'slug': ('1.0.0',),
'slug': '1.0.0',
'version': '1.0.0',
'is_highest': False,
}
Expand All @@ -171,7 +171,7 @@ def test_highest_version_without_tags(self):
valid_data = {
'project': 'Version 0.8.1 of Pip (19)',
'url': '/dashboard/pip/version/0.8.1/',
'slug': ('0.8.1',),
'slug': '0.8.1',
'version': '0.8.1',
'is_highest': True,
}
Expand All @@ -182,7 +182,7 @@ def test_highest_version_without_tags(self):
valid_data = {
'project': 'Version 0.8.1 of Pip (19)',
'url': '/dashboard/pip/version/0.8.1/',
'slug': ('0.8.1',),
'slug': '0.8.1',
'version': '0.8.1',
'is_highest': False,
}
Expand All @@ -199,7 +199,7 @@ def test_highest_version_without_tags(self):
valid_data = {
'project': 'Version 2.0.0 of Pip ({})'.format(version.pk),
'url': '/dashboard/pip/version/2.0.0/',
'slug': ('2.0.0',),
'slug': '2.0.0',
'version': '2.0.0',
'is_highest': False,
}
Expand Down