Skip to content

Removing unused core.utils.make_latest #1399

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

Merged
merged 1 commit into from
Jul 6, 2015
Merged

Conversation

gregmuellegger
Copy link
Contributor

It was in there but was actually never used anywhere in the history of the project:

(readthedocs.org) gregor@layka ~/projects/readthedocs.org (git)-[master] % git log -Smake_latest -p
commit b7ac78737f73f7d998d1234e3eb9e5fdd8539276
Author: Eric Holscher <[email protected]>
Date:   Tue May 13 18:00:35 2014 -0700

    Add basic make_latest util

diff --git a/readthedocs/core/utils.py b/readthedocs/core/utils.py
index 3aa81c6..4bba334 100644
--- a/readthedocs/core/utils.py
+++ b/readthedocs/core/utils.py
@@ -105,3 +105,21 @@ def run_on_app_servers(command):
     else:
         ret = os.system(command)
         return ret
+
+def make_latest(project):
+    """
+    Useful for correcting versions with no latest, using the database.
+
+    >>> no_latest = Project.objects.exclude(versions__slug__in=['latest'])
+    >>> for project in no_latest:
+    >>>     make_latest(project)
+    """
+    branch = project.default_branch or project.vcs_repo().fallback_branch
+    version_data, created = Version.objects.get_or_create(
+        project=project,
+        slug='latest',
+        type='branch',
+        active=True,
+        verbose_name='latest',
+        identifier=branch,
+    )

We already have the Version.objects.create_latest.

@agjohnson
Copy link
Contributor

Deferring to @ericholscher as the author, in case there is reason this needs to exist

@ericholscher
Copy link
Member

From the docstring, it looks like this was a CLI helper, that looks similar to the abstraction that you were referring to. No reason to keep it around now that we have the model manager.

ericholscher added a commit that referenced this pull request Jul 6, 2015
Removing unused core.utils.make_latest
@ericholscher ericholscher merged commit bb878c1 into master Jul 6, 2015
@gregmuellegger gregmuellegger deleted the remove-make-latest branch August 3, 2015 13:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants