Skip to content

Commit

Permalink
Removing .git from repo_name
Browse files Browse the repository at this point in the history
  • Loading branch information
AgarFu authored Dec 11, 2020
1 parent ff88851 commit 38ed5ae
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com),
and this project adheres to [Semantic Versioning](https://semver.org).

## [3.1.1] - 2020-12-11
### Fix
- Remove '.git' from repo_name

## [3.1.0] - 2020-08-26
### Added
- Allow `repo#create_pr` to be called without setting labels
Expand Down
3 changes: 3 additions & 0 deletions gordian/repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ def __init__(self, repo_name, github_api_url=None, branch=None, github=None, fil
files = []
self.files = files

if repo_name.endswith('.git'):
repo_name = repo_name[:-4]

self._initialize_repos(repo_name, fork)

self.version_file = None
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
setup_reqs = ['pytest', 'pytest-cov', 'pytest-runner', 'flake8']
setuptools.setup(
name="gordian",
version="3.1.0",
version="3.1.1",
author="Intuit",
author_email="[email protected]",
description="A tool to search and replace files in a Git repo",
Expand Down
18 changes: 12 additions & 6 deletions tests/test_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,24 @@ def setUp(self, mock_git):
self.mock_repo.get_branches.return_value = self.mock_branches
self.mock_git.get_repo.return_value = self.mock_repo

@patch('gordian.repo.Github')
def test_remove_dot_git_from_repo_name(self, mock_git):
self.mock_git.reset_mock()
self.repo = Repo('test.git', github=self.mock_git)
self.mock_git.get_repo.assert_called_once_with('test')

def test_no_fork(self):
repo = Repo(None, branch='', github=self.mock_git, fork=False)
repo = Repo('test_repo', branch='', github=self.mock_git, fork=False)
repo._target_repo.create_fork.assert_not_called()
self.assertEqual(repo._source_repo, repo._target_repo)

def test_fork(self):
repo = Repo(None, branch='', github=self.mock_git, fork=True)
repo = Repo('test_repo', branch='', github=self.mock_git, fork=True)
repo._target_repo.create_fork.assert_called_once()
self.assertNotEqual(repo._source_repo, repo._target_repo)

def test_make_branch_fork(self):
repo = Repo(None, branch='', github=self.mock_git, fork=True)
repo = Repo('test_repo', branch='', github=self.mock_git, fork=True)
repo.branch_exists = False
mock_branch = MagicMock()
self.mock_repo.get_branch.return_value = mock_branch
Expand All @@ -40,7 +46,7 @@ def test_make_branch_fork(self):
repo._source_repo.create_git_ref.assert_called_once()

def test_make_branch_no_fork(self):
repo = Repo(None, branch='', github=self.mock_git, fork=False)
repo = Repo('test_repo', branch='', github=self.mock_git, fork=False)
repo.branch_exists = False
mock_branch = MagicMock()
self.mock_repo.get_branch.return_value = mock_branch
Expand Down Expand Up @@ -100,7 +106,7 @@ def test__set_target_branch_reset_file_cache(self):
self.assertEqual(self.repo.target_ref, 'refs/heads/Something different')

def test_create_pr(self):
repo = Repo(None, branch='', github=self.mock_git)
repo = Repo('test_repo', branch='', github=self.mock_git)
repo._target_repo = MagicMock()
repo._source_repo = MagicMock()
repo._source_repo.owner.login = 'someone'
Expand All @@ -111,7 +117,7 @@ def test_create_pr(self):
repo._source_repo.create_pull.assert_not_called()

def test_create_pr_no_labels(self):
repo = Repo(None, branch='', github=self.mock_git)
repo = Repo('test_repo', branch='', github=self.mock_git)
repo._target_repo = MagicMock()
repo._source_repo = MagicMock()
repo._source_repo.owner.login = 'someone'
Expand Down
2 changes: 1 addition & 1 deletion tests/test_transformations.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def setUp(self, mock_git):
self.mock_repo.get_branches.return_value = self.mock_branches
mock_git.get_repo.return_value = self.mock_repo
self.mock_repo.get_contents.return_value = []
self.instance = Repo(None, branch='', github=mock_git, files=[])
self.instance = Repo('test_repo', branch='', github=mock_git, files=[])
self.instance.branch_exists = False
f = open('./tests/fixtures/content.yaml', 'r')
contents = f.read()
Expand Down

0 comments on commit 38ed5ae

Please sign in to comment.