Repository: readthedocs/readthedocs.org

Issue:
Link to GitHub include 'origin' and thus are broken
## Details
I'm facing the same problem as mentioned in #3203 
That issue is closed.

* Read the Docs project URL: http://datastandard.globalcoffeeplatform.org
* Build URL (if applicable): https://readthedocs.org/api/v2/build/8790271.txt
* Read the Docs username (if applicable):

## Expected Result
I expect the 'Edit on GitHub' to be
https://github.com/globalcoffeeplatform/CoffeeDataStandard/blob/master/docs/source/index.rst
Without the 'origin' part.
*A description of what you wanted to happen*

## Actual Result
Now the link is 
https://github.com/globalcoffeeplatform/CoffeeDataStandard/blob/origin/master/docs/source/index.rst

*A description of what actually happened*
I've rebuild several times. Perhaps I need a different version of some tool?
I'm using Spinx v1.8.4 and sphinx-rtd-theme v0.4.2


Discussion:
I'm not really sure why we put the `origin` there, but you can solve this problem in the meantime going to your project's advanced settings, the `default branch` setting will be filled with `master`, you just need to change it to `blank` (which is basically the same as master) and click `save`.
Thanks @stsewd your workaround works. 
Looks like we are mixing some fields when saving the versions

https://github.com/rtfd/readthedocs.org/blob/5ed7677e864360b10b9f2d0efbf2b22ac8af354c/readthedocs/builds/models.py#L180-L185

Resolving patch:
diff --git a/readthedocs/projects/forms.py b/readthedocs/projects/forms.py
--- a/readthedocs/projects/forms.py
+++ b/readthedocs/projects/forms.py
@@ -241,12 +241,14 @@ def __init__(self, *args, **kwargs):
         )
 
         default_choice = (None, '-' * 9)
-        all_versions = self.instance.versions.values_list(
-            'identifier',
-            'verbose_name',
-        )
+        # commit_name is used as the id because it handles
+        # the special cases of LATEST and STABLE.
+        all_versions_choices = [
+            (v.commit_name, v.verbose_name)
+            for v in self.instance.versions.all()
+        ]
         self.fields['default_branch'].widget = forms.Select(
-            choices=[default_choice] + list(all_versions),
+            choices=[default_choice] + all_versions_choices,
         )
 
         active_versions = self.get_all_active_versions()


Test patch:
diff --git a/readthedocs/rtd_tests/tests/test_project_forms.py b/readthedocs/rtd_tests/tests/test_project_forms.py
--- a/readthedocs/rtd_tests/tests/test_project_forms.py
+++ b/readthedocs/rtd_tests/tests/test_project_forms.py
@@ -16,6 +16,7 @@
 )
 from readthedocs.projects.exceptions import ProjectSpamError
 from readthedocs.projects.forms import (
+    EmailHookForm,
     EnvironmentVariableForm,
     ProjectAdvancedForm,
     ProjectBasicsForm,
@@ -23,7 +24,6 @@
     TranslationForm,
     UpdateProjectForm,
     WebHookForm,
-    EmailHookForm
 )
 from readthedocs.projects.models import EnvironmentVariable, Project
 
@@ -201,6 +201,7 @@ def setUp(self):
             active=True,
             privacy_level=PUBLIC,
             identifier='public-1',
+            verbose_name='public-1',
         )
         get(
             Version,
@@ -209,6 +210,7 @@ def setUp(self):
             active=True,
             privacy_level=PUBLIC,
             identifier='public-2',
+            verbose_name='public-2',
         )
         get(
             Version,
@@ -217,6 +219,7 @@ def setUp(self):
             active=False,
             privacy_level=PROTECTED,
             identifier='public-3',
+            verbose_name='public-3',
         )
         get(
             Version,
@@ -225,6 +228,7 @@ def setUp(self):
             active=False,
             privacy_level=PUBLIC,
             identifier='public/4',
+            verbose_name='public/4',
         )
         get(
             Version,
@@ -233,6 +237,7 @@ def setUp(self):
             active=True,
             privacy_level=PRIVATE,
             identifier='private',
+            verbose_name='private',
         )
         get(
             Version,
@@ -241,6 +246,7 @@ def setUp(self):
             active=True,
             privacy_level=PROTECTED,
             identifier='protected',
+            verbose_name='protected',
         )
 
     def test_list_only_active_versions_on_default_version(self):