Repository: readthedocs/readthedocs.org

Issue:
Git backend transforming tags/branches incorrectly
I had thought that the refactor to version slugs had unified our slugging for VCS versions, but it seems the Git backend is still performing transforms on these names. Is there a reason for this?

For instance, a repository with a tag of "release/foobar" becomes just "foobar" at:
https://github.com/rtfd/readthedocs.org/blob/master/readthedocs/vcs_support/backends/git.py#L113

Shouldn't the `VersionSlugField` be handling this now?



Discussion:
@agjohnson following you example, what should be the correct slug generated, `release-foobar`?

Resolving patch:
diff --git a/readthedocs/vcs_support/backends/git.py b/readthedocs/vcs_support/backends/git.py
--- a/readthedocs/vcs_support/backends/git.py
+++ b/readthedocs/vcs_support/backends/git.py
@@ -111,7 +111,7 @@ def parse_tags(self, data):
             if row == []:
                 continue
             commit_hash, name = row
-            clean_name = name.split('/')[-1]
+            clean_name = name.replace('refs/tags/', '')
             vcs_tags.append(VCSVersion(self, commit_hash, clean_name))
         return vcs_tags
 
@@ -148,15 +148,12 @@ def parse_branches(self, data):
             if branch:
                 branch = branch[0]
                 if branch.startswith('origin/'):
-                    cut_len = len('origin/')
-                    slug = branch[cut_len:].replace('/', '-')
-                    if slug in ['HEAD']:
+                    verbose_name = branch.replace('origin/', '')
+                    if verbose_name in ['HEAD']:
                         continue
-                    clean_branches.append(VCSVersion(self, branch, slug))
+                    clean_branches.append(VCSVersion(self, branch, verbose_name))
                 else:
-                    # Believe this is dead code.
-                    slug = branch.replace('/', '-')
-                    clean_branches.append(VCSVersion(self, branch, slug))
+                    clean_branches.append(VCSVersion(self, branch, branch))
         return clean_branches
 
     @property


Test patch:
diff --git a/readthedocs/rtd_tests/tests/test_backend.py b/readthedocs/rtd_tests/tests/test_backend.py
--- a/readthedocs/rtd_tests/tests/test_backend.py
+++ b/readthedocs/rtd_tests/tests/test_backend.py
@@ -33,15 +33,17 @@ def test_parse_branches(self):
         origin/HEAD -> origin/master
         origin/master
         origin/release/2.0.0
+        origin/release/foo/bar
         """
 
         expected_ids = [
             ('develop', 'develop'),
             ('master', 'master'),
-            ('release/2.0.0', 'release-2.0.0'),
+            ('release/2.0.0', 'release/2.0.0'),
             ('origin/2.0.X', '2.0.X'),
             ('origin/master', 'master'),
-            ('origin/release/2.0.0', 'release-2.0.0')
+            ('origin/release/2.0.0', 'release/2.0.0'),
+            ('origin/release/foo/bar', 'release/foo/bar'),
         ]
         given_ids = [(x.identifier, x.verbose_name) for x in
                      self.project.vcs_repo().parse_branches(data)]
@@ -60,6 +62,7 @@ def test_parse_git_tags(self):
             a63a2de628a3ce89034b7d1a5ca5e8159534eef0 refs/tags/2.1.0.beta2
             c7fc3d16ed9dc0b19f0d27583ca661a64562d21e refs/tags/2.1.0.rc1
             edc0a2d02a0cc8eae8b67a3a275f65cd126c05b1 refs/tags/2.1.0.rc2
+            274a5a8c988a804e40da098f59ec6c8f0378fe34 refs/tags/release/foobar
          """
         expected_tags = [
             ('3b32886c8d3cb815df3793b3937b2e91d0fb00f1', '2.0.0'),
@@ -68,6 +71,7 @@ def test_parse_git_tags(self):
             ('a63a2de628a3ce89034b7d1a5ca5e8159534eef0', '2.1.0.beta2'),
             ('c7fc3d16ed9dc0b19f0d27583ca661a64562d21e', '2.1.0.rc1'),
             ('edc0a2d02a0cc8eae8b67a3a275f65cd126c05b1', '2.1.0.rc2'),
+            ('274a5a8c988a804e40da098f59ec6c8f0378fe34', 'release/foobar'),
         ]
 
         given_ids = [(x.identifier, x.verbose_name) for x in