Skip to content
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

[fix] target_dir may be an empty directory #83

Merged
merged 1 commit into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion git_aggregator/repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def aggregate(self):
logger.info('Start aggregation of %s', self.cwd)
target_dir = self.cwd

is_new = not os.path.exists(target_dir)
is_new = not os.path.exists(target_dir) or os.listdir(target_dir) == []
if is_new:
cloned = self.init_repository(target_dir)

Expand Down
22 changes: 22 additions & 0 deletions tests/test_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,28 @@ def test_minimal(self):
last_rev = git_get_last_rev(self.cwd)
self.assertEqual(last_rev, self.commit_1_sha)

def test_empty_dir(self):
# ensure git clone in empty directory works
remotes = [{
'name': 'r1',
'url': self.url_remote1
}]
merges = [{
'remote': 'r1',
'ref': 'tag1'
}]
target = {
'remote': 'r1',
'branch': 'agg1'
}
# self.cwd should not exist yet
self.assertFalse(os.path.exists(self.cwd))
os.mkdir(self.cwd)
repo = Repo(self.cwd, remotes, merges, target)
repo.aggregate()
last_rev = git_get_last_rev(self.cwd)
self.assertEqual(last_rev, self.commit_1_sha)

def test_annotated_tag(self):
remotes = [{
'name': 'r1',
Expand Down
Loading