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

Improve error message when a folder is not an SCM repo #8956

Merged
merged 1 commit into from May 24, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion conans/client/tools/scm.py
Expand Up @@ -16,7 +16,7 @@


def _check_repo(cmd, folder):
msg = "Not a valid '{0}' repository or '{0}' not found.".format(cmd[0])
msg = "'{0}' is not a valid '{1}' repository or '{1}' not found.".format(folder, cmd[0])
try:
ret = muted_runner(cmd, folder=folder)
except Exception:
Expand Down
5 changes: 3 additions & 2 deletions conans/test/functional/scm/test_command_export.py
Expand Up @@ -34,8 +34,9 @@ def test_no_repo(self, repo_type, autos):
rev_value=rev_value)
})
self.client.run("export . lib/version@user/channel", assert_error=True)
self.assertIn("ERROR: Not a valid '{}' repository".format(repo_type.lower()),
self.client.out)
self.assertIn("ERROR: '{}' is not a valid '{}' repository".format(
self.client.current_folder, repo_type.lower()), self.client.out)


@pytest.mark.tool_git
class ExportCommandTestCase(unittest.TestCase):
Expand Down
9 changes: 6 additions & 3 deletions conans/test/functional/scm/tools/test_git.py
@@ -1,5 +1,6 @@
# coding=utf-8
import os
import re
import subprocess
import unittest

Expand Down Expand Up @@ -397,9 +398,11 @@ def test_in_branch_with_tag(self):

def test_get_tag_no_git_repo(self):
# Try to get tag out of a git repo
git = Git(folder=temp_folder())
with six.assertRaisesRegex(self, ConanException,
"Not a valid 'git' repository or 'git' not found"):
tmp_folder = temp_folder()
git = Git(folder=tmp_folder)
pattern = "'{0}' is not a valid 'git' repository or 'git' not found".format(
re.escape(tmp_folder))
with six.assertRaisesRegex(self, ConanException, pattern):
git.get_tag()

def test_excluded_files(self):
Expand Down
4 changes: 3 additions & 1 deletion conans/test/functional/scm/tools/test_svn.py
@@ -1,6 +1,7 @@
# coding=utf-8

import os
import re
import shutil
import subprocess
import unittest
Expand Down Expand Up @@ -56,7 +57,8 @@ def test_check_svn_repo(self):
project_url, _ = self.create_project(files={'myfile': "contents"})
tmp_folder = self.gimme_tmp()
svn = SVN(folder=tmp_folder)
with six.assertRaisesRegex(self, ConanException, "Not a valid 'svn' repository"):
pattern = "'{0}' is not a valid 'svn' repository".format(re.escape(tmp_folder))
with six.assertRaisesRegex(self, ConanException, pattern):
svn.check_repo()
svn.checkout(url=project_url)
try:
Expand Down