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

Avoid warning message from SVN check function #4264

Merged
merged 9 commits into from
Feb 28, 2019

Conversation

jgsogo
Copy link
Contributor

@jgsogo jgsogo commented Jan 10, 2019

Changelog: Fix: Avoid warning message (shown in console output) when running the SVN check outside a SVN repository
Docs: Omit

Implementation proposed by @ahauan4 in #3831 (comment)

@tags: svn

Copy link
Member

@danimtb danimtb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure but, Is it possible to add a test to this?

@lasote lasote added this to the 1.13 milestone Jan 10, 2019
@jgsogo
Copy link
Contributor Author

jgsogo commented Jan 10, 2019

@danimtb, I've added a test specific to this function (not actually related to the output warning message). I don't know if, after returning from the command I can read the previous output to check that there is no such message.

If you have some idea, please tell me:

    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 self.assertRaisesRegexp(ConanException, "Not a valid SVN repository"):
            svn._check_svn_repo()
            # --->> Get the output and check that there isn't a warning message there ¿?
        svn.checkout(url=project_url)
        try:
            svn._check_svn_repo()
        except Exception:
            self.fail("After checking out, it should be a valid SVN repository")

@danimtb
Copy link
Member

danimtb commented Jan 10, 2019

yes, is the only way to do it properly I think 👍

conans/client/tools/scm.py Outdated Show resolved Hide resolved
@jgsogo
Copy link
Contributor Author

jgsogo commented Feb 15, 2019

Please, review again, maybe it is time to get some ✅ s.

Copy link
Contributor

@lasote lasote left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, take a look to the detect_repo_type also in the scm module (model). I introduced it to decouple the revisions with the scm feature. We should integrate both solutions.


def detect_repo_type(folder):
    if not folder:
        return None

    def _run_command_ignore_output(cmd):
        with chdir(folder):
            try:
                ret = subprocess.call(cmd, shell=True,
                                      stdout=open(os.devnull, 'w'), stderr=subprocess.STDOUT)
                if ret != 0:
                    return False
            except Exception:
                return False
        return True

    if _run_command_ignore_output("git status"):
        return "git"
    elif _run_command_ignore_output("svn info"):
        return "svn"
    return None

conans/client/tools/scm.py Outdated Show resolved Hide resolved
@jgsogo
Copy link
Contributor Author

jgsogo commented Feb 27, 2019

@lasote , take a look at the reengineering of the check_repo, detect_repo_type, ... functions that were around the code. Now I have a SVN::check_repo and Git::check_repo and I can ask SCM object about the type of repo corresponding to a folder from the list SCM::availables ones. All the changes are in this commit: d503cc7

@lasote lasote merged commit 200a968 into conan-io:develop Feb 28, 2019
@ghost ghost removed the stage: review label Feb 28, 2019
@jgsogo jgsogo deleted the fix/svn-warning-message branch February 28, 2019 22:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants