-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Delete untracked tags on fetch #4811
Merged
ericholscher
merged 7 commits into
readthedocs:master
from
stsewd:delete-untracked-tags-on-fetch
Nov 1, 2018
Merged
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
85acbb5
Test
stsewd 8b0e2df
Isort
stsewd 6ec6b1b
Add --prune-tags
stsewd 3f2b4f4
Update docs
stsewd 64b8e09
Install git 2.17.1 on travis
stsewd 7b7c83b
Test with jsut apt-get
stsewd 07ad2a5
Merge branch 'master' into delete-untracked-tags-on-fetch
ericholscher File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,33 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from __future__ import ( | ||
absolute_import, division, print_function, unicode_literals) | ||
absolute_import, | ||
division, | ||
print_function, | ||
unicode_literals, | ||
) | ||
|
||
import os | ||
from os.path import exists | ||
from tempfile import mkdtemp | ||
|
||
import django_dynamic_fixture as fixture | ||
import pytest | ||
from django.contrib.auth.models import User | ||
from mock import Mock | ||
from mock import Mock, patch | ||
|
||
from readthedocs.config import ALL | ||
from readthedocs.projects.exceptions import RepositoryError | ||
from readthedocs.projects.models import Feature, Project | ||
from readthedocs.rtd_tests.base import RTDTestCase | ||
from readthedocs.rtd_tests.utils import ( | ||
create_git_tag, make_test_git, make_test_hg) | ||
create_git_branch, | ||
create_git_tag, | ||
delete_git_branch, | ||
delete_git_tag, | ||
make_test_git, | ||
make_test_hg, | ||
) | ||
|
||
|
||
class TestGitBackend(RTDTestCase): | ||
|
@@ -118,6 +130,51 @@ def test_check_invalid_submodule_urls(self): | |
repo.checkout('invalidsubmodule') | ||
self.assertEqual(e.msg, RepositoryError.INVALID_SUBMODULES) | ||
|
||
@patch('readthedocs.projects.models.Project.checkout_path') | ||
def test_fetch_clean_tags_and_branches(self, checkout_path): | ||
upstream_repo = self.project.repo | ||
create_git_tag(upstream_repo, 'v01') | ||
create_git_tag(upstream_repo, 'v02') | ||
create_git_branch(upstream_repo, 'newbranch') | ||
|
||
local_repo = os.path.join(mkdtemp(), 'local') | ||
os.mkdir(local_repo) | ||
checkout_path.return_value = local_repo | ||
|
||
repo = self.project.vcs_repo() | ||
repo.clone() | ||
|
||
delete_git_tag(upstream_repo, 'v02') | ||
delete_git_branch(upstream_repo, 'newbranch') | ||
|
||
# We still have all branches and tags in the local repo | ||
self.assertEqual( | ||
set(['v01', 'v02']), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just realized that I wrote this code... I should have written |
||
set(vcs.verbose_name for vcs in repo.tags) | ||
) | ||
self.assertEqual( | ||
set([ | ||
'relativesubmodule', 'invalidsubmodule', | ||
'master', 'submodule', 'newbranch', | ||
]), | ||
set(vcs.verbose_name for vcs in repo.branches) | ||
) | ||
|
||
repo.checkout() | ||
|
||
# We don't have the eliminated branches and tags in the local repo | ||
self.assertEqual( | ||
set(['v01']), | ||
set(vcs.verbose_name for vcs in repo.tags) | ||
) | ||
self.assertEqual( | ||
set([ | ||
'relativesubmodule', 'invalidsubmodule', | ||
'master', 'submodule' | ||
]), | ||
set(vcs.verbose_name for vcs in repo.branches) | ||
) | ||
|
||
|
||
class TestHgBackend(RTDTestCase): | ||
def setUp(self): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we are deprecating Python2 we should remove these imports and also configure .isort to not add them anymore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I opened readthedocs/common#19