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

Provide clearer error message when repository entry is empty #256

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
4 changes: 4 additions & 0 deletions test/bad.repos
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
repositories:
empty_entry:
missing_url:
type: git
6 changes: 6 additions & 0 deletions test/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
REPOS2_FILE = os.path.join(os.path.dirname(__file__), 'list2.repos')
TEST_WORKSPACE = os.path.join(
os.path.dirname(os.path.dirname(__file__)), 'test_workspace')
BAD_REPOS_FILE = os.path.join(os.path.dirname(__file__), 'bad.repos')

CI = os.environ.get('CI') == 'true' # Travis CI / Github actions set: CI=true
svn = which('svn')
Expand Down Expand Up @@ -326,6 +327,11 @@ def test_validate(self):
expected = get_expected_output('validate_hide')
self.assertEqual(output, expected)

output = run_command(
'validate', ['--input', BAD_REPOS_FILE])
expected = get_expected_output('validate_bad')
self.assertEqual(output, expected)

@unittest.skipIf(not svn and not CI, '`svn` was not found')
@unittest.skipIf(not hg and not CI, '`hg` was not found')
def test_validate_svn_and_hg(self):
Expand Down
2 changes: 2 additions & 0 deletions test/validate_bad.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Repository 'empty_entry' is empty
Repository 'missing_url' does not provide the necessary information: 'url'
6 changes: 6 additions & 0 deletions vcstool/commands/import_.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ def get_repos_in_vcstool_format(repositories):
for path in repositories:
repo = {}
attributes = repositories[path]
if not attributes:
print(
ansi('yellowf') + (
"Repository '%s' is empty" % path) + ansi('reset'),
file=sys.stderr)
continue
try:
repo['type'] = attributes['type']
repo['url'] = attributes['url']
Expand Down