internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: readthedocs/readthedocs.org

Issue:
Remove copyright application
This was brought up in review and not handled. Doesn't look like we need it any longer?


Discussion:
Hi! I'm new to rtd.  Is this referring to removing from base.py?
Greetings! 👋

It is, though the `copyright` application is likely called somewhere else in code as well. It shouldn't take much work at all, but I haven't looked into removing this yet.

If you want to try removing this, our development installation guide is here:
http://docs.readthedocs.io/en/latest/install.html#installing-read-the-docs
Original PR here: #1300
Cool!  I'll give it a try =)  Thanks for replying so quickly!
I would like to do an PR, or are you working on this, @kikisdeliveryservice?

Resolving patch:
diff --git a/readthedocs/settings/base.py b/readthedocs/settings/base.py
--- a/readthedocs/settings/base.py
+++ b/readthedocs/settings/base.py
@@ -77,7 +77,6 @@ def INSTALLED_APPS(self):  # noqa
             'django_gravatar',
             'rest_framework',
             'corsheaders',
-            'copyright',
             'textclassifier',
             'annoying',
             'django_extensions',
@@ -315,7 +314,6 @@ def INSTALLED_APPS(self):  # noqa
     # Misc application settings
     GLOBAL_ANALYTICS_CODE = 'UA-17997319-1'
     GRAVATAR_DEFAULT_IMAGE = 'https://media.readthedocs.org/images/silhouette.png'  # NOQA
-    COPY_START_YEAR = 2010
     RESTRICTEDSESSIONS_AUTHED_ONLY = True
     RESTRUCTUREDTEXT_FILTER_SETTINGS = {
         'cloak_email_addresses': True,


Test patch:
Repository: readthedocs/readthedocs.org

Issue:
Project slug names that are not valid DNS names are not caught on project creation
A sufficiently long enough project name will still be linked from RTD, but the DNS lookup will fail viewing these docs. We should be double checking for slugs that would be 63 characters or more and failing validation.
Project slug names that are not valid DNS names are not caught on project creation
A sufficiently long enough project name will still be linked from RTD, but the DNS lookup will fail viewing these docs. We should be double checking for slugs that would be 63 characters or more and failing validation.


Discussion:

Resolving patch:
diff --git a/readthedocs/projects/migrations/0030_change-max-length-project-slug.py b/readthedocs/projects/migrations/0030_change-max-length-project-slug.py
new file mode 100644
--- /dev/null
+++ b/readthedocs/projects/migrations/0030_change-max-length-project-slug.py
@@ -0,0 +1,36 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.11.16 on 2018-11-01 20:55
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+from django.db.models.functions import Length
+
+
+def forwards_func(apps, schema_editor):
+    max_length = 63
+    Project = apps.get_model('projects', 'Project')
+    projects_invalid_slug = (
+        Project
+        .objects
+        .annotate(slug_length=Length('slug'))
+        .filter(slug_length__gt=max_length)
+    )
+    for project in projects_invalid_slug:
+        project.slug = project.slug[:max_length]
+        project.save()
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('projects', '0029_add_additional_languages'),
+    ]
+
+    operations = [
+        migrations.RunPython(forwards_func),
+        migrations.AlterField(
+            model_name='project',
+            name='slug',
+            field=models.SlugField(max_length=63, unique=True, verbose_name='Slug'),
+        ),
+    ]
diff --git a/readthedocs/projects/models.py b/readthedocs/projects/models.py
--- a/readthedocs/projects/models.py
+++ b/readthedocs/projects/models.py
@@ -81,7 +81,8 @@ class Project(models.Model):
     users = models.ManyToManyField(User, verbose_name=_('User'),
                                    related_name='projects')
     name = models.CharField(_('Name'), max_length=255)
-    slug = models.SlugField(_('Slug'), max_length=255, unique=True)
+    # A DNS label can contain up to 63 characters.
+    slug = models.SlugField(_('Slug'), max_length=63, unique=True)
     description = models.TextField(_('Description'), blank=True,
                                    help_text=_('The reStructuredText '
                                                'description of the project'))


Test patch:
Repository: readthedocs/readthedocs.org

Issue:
Don't allow to create a subproject of the project itself
## Expected Result

When creating a subproject, the current project should no be listed as a child and no allowed to be a subproject of the project itself.

## Actual Result

The current project is listed as a child project, if someone chooses, it can't be easily deleted.
The current solution is manually entering to the edit page of the subproject (https://readthedocs.org/dashboard/{project}/subprojects/{subproject}/edit/).

See #3173


Discussion:

Resolving patch:
diff --git a/readthedocs/projects/forms.py b/readthedocs/projects/forms.py
--- a/readthedocs/projects/forms.py
+++ b/readthedocs/projects/forms.py
@@ -270,6 +270,13 @@ def clean_parent(self):
                 _('Subproject nesting is not supported'))
         return self.project
 
+    def clean_child(self):
+        child = self.cleaned_data['child']
+        if child == self.project:
+            raise forms.ValidationError(
+                _('A project can not be a subproject of itself'))
+        return child
+
     def get_subproject_queryset(self):
         """
         Return scrubbed subproject choice queryset.
@@ -280,7 +287,8 @@ def get_subproject_queryset(self):
         queryset = (
             Project.objects.for_admin_user(self.user)
             .exclude(subprojects__isnull=False)
-            .exclude(superprojects__isnull=False))
+            .exclude(superprojects__isnull=False)
+            .exclude(pk=self.project.pk))
         return queryset
 
 


Test patch:
diff --git a/readthedocs/rtd_tests/tests/test_subprojects.py b/readthedocs/rtd_tests/tests/test_subprojects.py
--- a/readthedocs/rtd_tests/tests/test_subprojects.py
+++ b/readthedocs/rtd_tests/tests/test_subprojects.py
@@ -143,6 +143,21 @@ def test_excludes_existing_subprojects(self):
             [''],
         )
 
+    def test_exclude_self_project_as_subproject(self):
+        user = fixture.get(User)
+        project = fixture.get(Project, users=[user])
+
+        form = ProjectRelationshipForm(
+            {'child': project.pk},
+            project=project,
+            user=user
+        )
+        self.assertFalse(form.is_valid())
+        self.assertNotIn(
+            project.id,
+            [proj_id for (proj_id, __) in form.fields['child'].choices]
+        )
+
 
 @override_settings(PUBLIC_DOMAIN='readthedocs.org')
 class ResolverBase(TestCase):
Repository: readthedocs/readthedocs.org

Issue:
List of redirects doesn't say which URLs are being redirected (if exact redirects)
## Details
- Project URL: https://readthedocs.org/projects/bigchaindb/
- List of project redirects (URL): https://readthedocs.org/dashboard/bigchaindb/redirects/
## Expected Result

When I make a bunch of redirects, I would expect the list of exact redirects to say the URL being redirected (and maybe where). Maybe the list would be simple but I'd be able to click on each item to see the details (such as the URL which get redirected and where).
## Actual Result

The actual list of redirects doesn't say anything about each one, other than it's an "Exact Redirect" (as seen in the image below). Also, I can't click on a redirect to find out more information about it.

What if I want to remove one (but only one) redirect? How can I pick the one to remove?

<hr>

![list_of_redirects](https://cloud.githubusercontent.com/assets/1210951/18984645/06cac79a-86f4-11e6-9d5b-7854c4959615.png)



Discussion:

Resolving patch:
diff --git a/readthedocs/redirects/models.py b/readthedocs/redirects/models.py
--- a/readthedocs/redirects/models.py
+++ b/readthedocs/redirects/models.py
@@ -78,13 +78,30 @@ class Meta(object):
         ordering = ('-update_dt',)
 
     def __str__(self):
-        if self.redirect_type == 'prefix':
-            return ugettext('Prefix Redirect:') + ' %s ->' % self.from_url
-        elif self.redirect_type == 'page':
-            return ugettext('Page Redirect:') + ' %s -> %s' % (
-                self.from_url,
-                self.to_url)
-        return ugettext('Redirect: %s' % self.get_redirect_type_display())
+        redirect_text = '{type}: {from_to_url}'
+        if self.redirect_type in ['prefix', 'page', 'exact']:
+            return redirect_text.format(
+                type=self.get_redirect_type_display(),
+                from_to_url=self.get_from_to_url_display()
+            )
+        return ugettext('Redirect: {}'.format(
+            self.get_redirect_type_display())
+        )
+
+    def get_from_to_url_display(self):
+        if self.redirect_type in ['prefix', 'page', 'exact']:
+            from_url = self.from_url
+            to_url = self.to_url
+            if self.redirect_type == 'prefix':
+                to_url = '/{lang}/{version}/'.format(
+                    lang=self.project.language,
+                    version=self.project.default_version
+                )
+            return '{from_url} -> {to_url}'.format(
+                from_url=from_url,
+                to_url=to_url
+            )
+        return ''
 
     def get_full_path(self, filename, language=None, version_slug=None):
         """


Test patch:
Repository: readthedocs/readthedocs.org

Issue:
Clarify set up text when using project name
The project name is currently `pip` but the text should clarify why we're using `pip` -- 'we'll use a test project of `pip` blah blah'

refs #2240



Discussion:

Resolving patch:
diff --git a/docs/conf.py b/docs/conf.py
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -27,6 +27,7 @@
     'sphinxcontrib.httpdomain',
     'djangodocs',
     'doc_extensions',
+    'sphinx_tabs.tabs',
 ]
 templates_path = ['_templates']
 


Test patch:
Repository: readthedocs/readthedocs.org

Issue:
Improve security contact webpage
We need to improve our documentation about a user who found a security issue could contact us to report this vulnerability in a confidential way.

This page should be clear regarding how to report the issue, how submit a patch (wihtout making it public) and what to do receive feedback / discuss about the solution.

There is a page already but it's too poor: https://readthedocs.org/security/


Discussion:

Resolving patch:
diff --git a/readthedocs/urls.py b/readthedocs/urls.py
--- a/readthedocs/urls.py
+++ b/readthedocs/urls.py
@@ -34,6 +34,8 @@
     url(r'^$', HomepageView.as_view(), name='homepage'),
     url(r'^support/', SupportView.as_view(), name='support'),
     url(r'^security/', TemplateView.as_view(template_name='security.html')),
+    url(r'^.well-known/security.txt',
+        TemplateView.as_view(template_name='security.txt', content_type='text/plain')),
 ]
 
 rtd_urls = [


Test patch:
Repository: readthedocs/readthedocs.org

Issue:
AttributeError: 'SyncRepositoryTask' object has no attribute '_log'
https://sentry.io/read-the-docs/readthedocs-org/issues/471122664/

```
AttributeError: 'SyncRepositoryTask' object has no attribute '_log'
  File "readthedocs/projects/tasks.py", line 175, in run
    self.sync_repo()
  File "readthedocs/projects/tasks.py", line 111, in sync_repo
    self._log(

An unhandled exception was raised during VCS syncing
```


Discussion:

Resolving patch:
diff --git a/readthedocs/projects/tasks.py b/readthedocs/projects/tasks.py
--- a/readthedocs/projects/tasks.py
+++ b/readthedocs/projects/tasks.py
@@ -151,6 +151,15 @@ def sync_repo(self):
             except Exception:
                 log.exception('Unknown Sync Versions Exception')
 
+    # TODO this is duplicated in the classes below, and this should be
+    # refactored out anyways, as calling from the method removes the original
+    # caller from logging.
+    def _log(self, msg):
+        log.info(LOG_TEMPLATE
+                 .format(project=self.project.slug,
+                         version=self.version.slug,
+                         msg=msg))
+
 
 class SyncRepositoryTask(SyncRepositoryMixin, Task):
 


Test patch:
Repository: readthedocs/readthedocs.org

Issue:
Conditionally do git submodule operations
We shouldn't be doing submodule operations on repositories that don't have submodules. We can check for this by determining if a repository has a `.gitmodules` file at the top level, and if not, we can skip these commands.

Raised in #3520 as we're storing all these as extraneous commands now.


Discussion:

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
@@ -55,6 +55,10 @@ def repo_exists(self):
         code, _, _ = self.run('git', 'status', record=False)
         return code == 0
 
+    def submodules_exists(self):
+        code, out, _ = self.run('git', 'submodule', 'status', record=False)
+        return code == 0 and bool(out)
+
     def fetch(self):
         code, _, _ = self.run('git', 'fetch', '--tags', '--prune')
         if code != 0:
@@ -187,9 +191,10 @@ def checkout(self, identifier=None):
         self.run('git', 'clean', '-d', '-f', '-f')
 
         # Update submodules
-        self.run('git', 'submodule', 'sync')
-        self.run('git', 'submodule', 'update',
-                 '--init', '--recursive', '--force')
+        if self.submodules_exists():
+            self.run('git', 'submodule', 'sync')
+            self.run('git', 'submodule', 'update',
+                     '--init', '--recursive', '--force')
 
         return code, out, err
 


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
@@ -78,6 +78,16 @@ def test_parse_git_tags(self):
                      self.project.vcs_repo().parse_tags(data)]
         self.assertEqual(expected_tags, given_ids)
 
+    def test_check_for_submodules(self):
+        repo = self.project.vcs_repo()
+
+        repo.checkout()
+        self.assertFalse(repo.submodules_exists())
+
+        # The submodule branch contains one submodule
+        repo.checkout('submodule')
+        self.assertTrue(repo.submodules_exists())
+
 
 class TestHgBackend(RTDTestCase):
     def setUp(self):
diff --git a/readthedocs/rtd_tests/utils.py b/readthedocs/rtd_tests/utils.py
--- a/readthedocs/rtd_tests/utils.py
+++ b/readthedocs/rtd_tests/utils.py
@@ -34,6 +34,13 @@ def make_test_git():
     log.info(check_output(['git', 'init'] + [directory], env=env))
     log.info(check_output(['git', 'add', '.'], env=env))
     log.info(check_output(['git', 'commit', '-m"init"'], env=env))
+    # Add repo itself as submodule
+    log.info(check_output(['git', 'checkout', '-b', 'submodule'], env=env))
+    log.info(check_output(['git', 'submodule', 'add', '-b', 'master', './', 'submodule'], env=env))
+    log.info(check_output(['git', 'add', '.'], env=env))
+    log.info(check_output(['git', 'commit', '-m"Add submodule"'], env=env))
+    # Checkout to master branch again
+    log.info(check_output(['git', 'checkout', 'master'], env=env))
     chdir(path)
     return directory
Repository: readthedocs/readthedocs.org

Issue:
Upgrade django-pagination
We are using a fork of the unmaintained `django-pagination` (https://github.com/zyga/django-pagination).

On the other hand, I found that there is another fork that maybe is more maintained at https://github.com/pydanny/dj-pagination

I opened an issue that the 3dparty repository at https://github.com/zyga/django-pagination/issues/42

Ref #2435


Discussion:

Resolving patch:
diff --git a/readthedocs/settings/base.py b/readthedocs/settings/base.py
--- a/readthedocs/settings/base.py
+++ b/readthedocs/settings/base.py
@@ -71,7 +71,7 @@ def INSTALLED_APPS(self):  # noqa
             'django.contrib.humanize',
 
             # third party apps
-            'linaro_django_pagination',
+            'dj_pagination',
             'taggit',
             'guardian',
             'django_gravatar',
@@ -131,7 +131,7 @@ def USE_PROMOS(self):  # noqa
         'django.middleware.csrf.CsrfViewMiddleware',
         'django.contrib.auth.middleware.AuthenticationMiddleware',
         'django.contrib.messages.middleware.MessageMiddleware',
-        'linaro_django_pagination.middleware.PaginationMiddleware',
+        'dj_pagination.middleware.PaginationMiddleware',
         'readthedocs.core.middleware.SubdomainMiddleware',
         'readthedocs.core.middleware.SingleVersionMiddleware',
         'corsheaders.middleware.CorsMiddleware',


Test patch:
Repository: readthedocs/readthedocs.org

Issue:
Stable versions are broken
For instance: http://readthedocs.org/projects/docs/builds/6938938/


Discussion:
Related issues https://github.com/rtfd/readthedocs.org/issues/3837
Previous `stable` passing is this one: http://readthedocs.org/projects/docs/builds/6933018/

Note that the only difference is that now the `git checkout` command is adding the `origin/` to the commit. Guessing, I would say that maybe some output has changed between Git 1.9 and Git 2.7.4 that was upgraded with the Ubuntu upgrade (a couple of days ago). Not sure, anyway.
@humitos I think it is due the git upgrade, on my local instance I can't reproduce this. But the checkout commands are different

![screenshot-2018-3-24 cice-consortium cice read the docs](https://user-images.githubusercontent.com/4975310/37859813-e53ba4e4-2ee7-11e8-9866-3f33f4e98da3.png)
![screenshot-2018-3-23 test-build read the docs](https://user-images.githubusercontent.com/4975310/37859814-e8799512-2ee7-11e8-9cbb-00733d1250d0.png)

 
Now I was able to reproduce this on my local instance with this project https://github.com/irmen/Pyro4

![screenshot-2018-3-23 pyoro read the docs](https://user-images.githubusercontent.com/4975310/37860022-8e0702be-2eeb-11e8-886a-408427782a20.png)

Found it!

The error is here

https://github.com/rtfd/readthedocs.org/blob/f3c0c0aa33c6017951b900e540d61ef36ea71d4e/readthedocs/vcs_support/backends/git.py#L250-L252

https://github.com/rtfd/readthedocs.org/blob/f3c0c0aa33c6017951b900e540d61ef36ea71d4e/readthedocs/vcs_support/backends/git.py#L256-L258

This is because before `code` was the original `exit_code` of the command, but after #3831(I think) the original `exit_code` is losed. This is something I was wondering while writing tests on https://github.com/rtfd/readthedocs.org/pull/3764#issuecomment-375827453
So, probably other places that rely on the original `exit_code` are going to be in trouble...
@stsewd great find! i think you're right

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
@@ -9,8 +9,9 @@
 import os
 import re
 
-from django.core.exceptions import ValidationError
 import git
+from django.core.exceptions import ValidationError
+from git.exc import BadName
 from six import PY2, StringIO
 
 from readthedocs.core.validators import validate_repository_url
@@ -273,8 +274,13 @@ def find_ref(self, ref):
         return ref
 
     def ref_exists(self, ref):
-        code, _, _ = self.run('git', 'show-ref', ref, record_as_success=True)
-        return code == 0
+        try:
+            r = git.Repo(self.working_dir)
+            if r.commit(ref):
+                return True
+        except (BadName, ValueError):
+            return False
+        return False
 
     @property
     def env(self):


Test patch:
Repository: readthedocs/readthedocs.org

Issue:
Documentation for the v2 of the configuration file
At first, I was thinking to automate this given the schema, but the spec isn't very large so we can just hand-write this without too much effort.


Discussion:

Resolving patch:
diff --git a/docs/doc_extensions.py b/docs/doc_extensions.py
--- a/docs/doc_extensions.py
+++ b/docs/doc_extensions.py
@@ -6,11 +6,14 @@
 djangosetting
     Output an inline literal of the corresponding setting value. Useful for
     keeping documentation up to date without editing on settings changes.
-"""
 
-from docutils import nodes, utils
+buildpyversions
+    Output a comma separated list of the supported python versions for a
+    Read the Docs build image.
+"""
 
 from django.conf import settings
+from docutils import nodes, utils
 
 from readthedocs.projects.models import Feature
 
@@ -23,8 +26,23 @@ def django_setting_role(typ, rawtext, text, lineno, inliner, options=None,
     return [node], []
 
 
+def python_supported_versions_role(typ, rawtext, text, lineno, inliner,
+                                   options=None, content=None):
+    """Up to date supported python versions for each build image."""
+    image = '{}:{}'.format(settings.DOCKER_DEFAULT_IMAGE, text)
+    image_settings = settings.DOCKER_IMAGE_SETTINGS[image]
+    python_versions = image_settings['python']['supported_versions']
+    node_list = []
+    separator = ', '
+    for i, version in enumerate(python_versions):
+        node_list.append(nodes.literal(version, version))
+        if i < len(python_versions) - 1:
+            node_list.append(nodes.Text(separator))
+    return (node_list, [])
+
+
 def feature_flags_role(typ, rawtext, text, lineno, inliner, options=None,
-                        content=None):
+                       content=None):
     """Up to date feature flags from the application."""
     all_features = Feature.FEATURES
     requested_feature = utils.unescape(text)
@@ -40,9 +58,13 @@ def setup(_):
         'djangosetting',
         django_setting_role
     )
+    roles.register_local_role(
+        'buildpyversions',
+        python_supported_versions_role,
+    )
     roles.register_local_role(
         'featureflags',
-        feature_flags_role
+        feature_flags_role,
     )
 
     return {


Test patch:
Repository: readthedocs/readthedocs.org

Issue:
Improve Intro and Getting Started documentation
I think the [introduction](https://docs.readthedocs.io/en/latest/) and [getting started guide](https://docs.readthedocs.io/en/latest/getting_started.html) could use a few improvements to make it easier for brand new users who may not already know about Sphinx/MkDocs/Markdown/RestructuredText and are just looking for a guide on how to write some docs.

I also think our introduction could stand some improvements to point users in the right direction. We have a lot of docs, but a few layout and explanation improvements will help users find the right section for them.

Here are some specific goals and improvements:

- Make it easier to start a brand new docs project
  * Have a getting started guide for Sphinx
  * Have a getting started guide for Sphinx with commonmark
  * Have a getting started guide for MkDocs
  * Explain the why between the above technologies
- Improve the intro paragraphs ("Read the Docs hosts documentation for...") on the index page to explain RTD's value proposition and why somebody should choose Read the Docs.
- Full sentence/paragraph descriptions on different sections (eg. User documentation) rather than just a big toctree.


Discussion:
I think this is a great idea, and needed. I still don't fully grok how to do this, either.

Aside: Is there a reason there are two milestones, `Documentation` and `Better User Documentation`? Could we join them?
Some existing content which might be useful to steal:

* http://ericholscher.com/blog/2016/jul/1/sphinx-and-rtd-for-writers/
* https://sphinx-tutorial.readthedocs.io/
> Aside: Is there a reason there are two milestones, Documentation and Better User Documentation? Could we join them?

I don't know the answer to this. Perhaps @agjohnson does?

Resolving patch:
diff --git a/docs/conf.py b/docs/conf.py
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -71,7 +71,7 @@
 gettext_compact = False
 
 html_theme = 'sphinx_rtd_theme'
-# html_static_path = ['_static']
+html_static_path = ['_static']
 html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
 html_logo = 'img/logo.svg'
 html_theme_options = {


Test patch: