Skip to content

Commit fc624ee

Browse files
authored
Merge pull request readthedocs#5308 from stsewd/rstrip-repo-url
Rstrip repo url
2 parents 4d91f61 + 5a16e7b commit fc624ee

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

readthedocs/projects/forms.py

+4
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,10 @@ def clean_name(self):
131131

132132
return name
133133

134+
def clean_repo(self):
135+
repo = self.cleaned_data.get('repo', '')
136+
return repo.rstrip('/')
137+
134138
def clean_remote_repository(self):
135139
remote_repo = self.cleaned_data.get('remote_repository', None)
136140
if not remote_repo:

readthedocs/rtd_tests/tests/test_project_forms.py

+13-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1-
# -*- coding: utf-8 -*-
2-
31
import mock
42
from django.contrib.auth.models import User
53
from django.test import TestCase
64
from django.test.utils import override_settings
75
from django_dynamic_fixture import get
86
from textclassifier.validators import ClassifierValidator
9-
from django.core.exceptions import ValidationError
107

118
from readthedocs.builds.constants import LATEST
129
from readthedocs.builds.models import Version
@@ -180,6 +177,18 @@ def test_length_of_tags(self):
180177
error_msg = 'Length of each tag must be less than or equal to 100 characters.'
181178
self.assertDictEqual(form.errors, {'tags': [error_msg]})
182179

180+
def test_strip_repo_url(self):
181+
form = ProjectBasicsForm({
182+
'name': 'foo',
183+
'repo_type': 'git',
184+
'repo': 'https://github.com/rtfd/readthedocs.org/'
185+
})
186+
self.assertTrue(form.is_valid())
187+
self.assertEqual(
188+
form.cleaned_data['repo'],
189+
'https://github.com/rtfd/readthedocs.org'
190+
)
191+
183192

184193
class TestProjectAdvancedForm(TestCase):
185194

@@ -514,7 +523,7 @@ class TestNotificationForm(TestCase):
514523

515524
def setUp(self):
516525
self.project = get(Project)
517-
526+
518527
def test_webhookform(self):
519528
self.assertEqual(self.project.webhook_notifications.all().count(), 0)
520529

0 commit comments

Comments
 (0)