-
-
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
Replace Version.get_vcs_slug() and Version.remote_slug with Version.commit_name #1650
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
from django.test import TestCase | ||
from django_dynamic_fixture import get | ||
from django_dynamic_fixture import new | ||
|
||
from readthedocs.builds.constants import BRANCH | ||
from readthedocs.builds.constants import LATEST | ||
from readthedocs.builds.constants import STABLE | ||
from readthedocs.builds.constants import TAG | ||
from readthedocs.builds.models import Version | ||
from readthedocs.projects.constants import REPO_TYPE_GIT | ||
from readthedocs.projects.constants import REPO_TYPE_HG | ||
from readthedocs.projects.models import Project | ||
|
||
|
||
class VersionCommitNameTests(TestCase): | ||
def test_branch_name(self): | ||
version = new(Version, identifier='release-2.5.x', | ||
slug='release-2.5.x', verbose_name='release-2.5.x', | ||
type=BRANCH) | ||
self.assertEqual(version.commit_name, 'release-2.5.x') | ||
|
||
def test_tag_name(self): | ||
version = new(Version, identifier='10f1b29a2bd2', slug='release-2.5.0', | ||
verbose_name='release-2.5.0', type=TAG) | ||
self.assertEqual(version.commit_name, 'release-2.5.0') | ||
|
||
def test_branch_with_name_stable(self): | ||
version = new(Version, identifier='origin/stable', slug=STABLE, | ||
verbose_name='stable', type=BRANCH) | ||
self.assertEqual(version.commit_name, 'stable') | ||
|
||
def test_stable_version_tag(self): | ||
version = new(Version, | ||
identifier='3d92b728b7d7b842259ac2020c2fa389f13aff0d', | ||
slug=STABLE, verbose_name=STABLE, type=TAG) | ||
self.assertEqual(version.commit_name, | ||
'3d92b728b7d7b842259ac2020c2fa389f13aff0d') | ||
|
||
def test_hg_latest_branch(self): | ||
hg_project = get(Project, repo_type=REPO_TYPE_HG) | ||
version = new(Version, identifier='default', slug=LATEST, | ||
verbose_name=LATEST, type=BRANCH, project=hg_project) | ||
self.assertEqual(version.commit_name, 'default') | ||
|
||
def test_git_latest_branch(self): | ||
git_project = get(Project, repo_type=REPO_TYPE_GIT) | ||
version = new(Version, project=git_project, | ||
identifier='origin/master', slug=LATEST, | ||
verbose_name=LATEST, type=BRANCH) | ||
self.assertEqual(version.commit_name, 'master') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One rule that is missing from the original handling are the changes to handle I'm not sure if that is important, or if the original issue would surface at this level anyways. If we're sure that de-slugging the names with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There must not be any slugs with a slash since we merged #1362 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And we are not using the slug anymore for generating the "commit name" that we use for linking. At least GitHub is cool with slashes in the branch name, for example: #1362 |
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.
+1 for being thorough and explicit, this is a lot more clear