Skip to content

Commit

Permalink
Add support for setting a path on get_files
Browse files Browse the repository at this point in the history
Signed-off-by: kaosx5s <>
  • Loading branch information
kaosx5s committed Oct 5, 2023
1 parent e8dd5ad commit 6260cea
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 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.6.0] - 2023-05-16
### Added
- Added support to pass in a path when calling get_files(), resolves issue #34

## [3.5.0] - 2023-05-16
### Added
- Added support to pass in a github token, username and password as named parameters
Expand Down
4 changes: 2 additions & 2 deletions gordian/repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ def get_objects(self, filename, klass=None):

return PlainTextFile(file, self)

def get_files(self):
def get_files(self, path=''):
if not self.files:
contents = self._get_repo_contents('')
contents = self._get_repo_contents(path)

while contents:
file = contents.pop(0)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
setup_reqs = ["pytest", "pytest-cov", "pytest-runner", "flake8"]
setuptools.setup(
name="gordian",
version="3.5.0",
version="3.6.0",
author="Intuit",
author_email="[email protected]",
description="A tool to search and replace files in a Git repo",
Expand Down
10 changes: 10 additions & 0 deletions tests/test_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,16 @@ def test_delete_file(self, mock_git):
repo._source_repo.delete_file.assert_called_once()
self.assertTrue(repo.dirty)

def test_get_files_with_path(self):
self.repo._set_target_branch('target')
self.repo.files = []
self.repo._source_repo = MagicMock()
repository_file = MagicMock(path='test/afile.txt', type='not_dir')
self.repo._source_repo.get_contents.side_effect = [[MagicMock(path='directory', type='dir')],[repository_file]]
self.repo.get_files('test')
self.repo._source_repo.get_contents.assert_has_calls([call('test', 'refs/heads/target'), call('directory', 'refs/heads/target')])
self.assertEquals(self.repo.files, [repository_file])

def test__get_github_client(self):
repo = Repo('test_repo', branch='', github=self.mock_git)

Expand Down

0 comments on commit 6260cea

Please sign in to comment.