Exemple #1
0
    def find_vcs_root(cls, path):
        """Try to find a version control root directory of this type for the
        given path.

        If successful, returns (vcs_root, levels_up), where vcs_root is the
        path to the version control root directory it found, and levels_up is an
        integer indicating how many parent directories it had to search through
        to find it, where 0 means it was found in the indicated path, 1 means it
        was found in that path's parent, etc. If not sucessful, returns None
        """
        if cls.search_parents_for_root():
            valid_dirs = walk_up_dirs(path)
        else:
            valid_dirs = [path]
        for i, current_path in enumerate(valid_dirs):
            if cls.is_valid_root(current_path):
                return current_path, i
        return None
Exemple #2
0
    def find_vcs_root(cls, path):
        """Try to find a version control root directory of this type for the
        given path.

        If successful, returns (vcs_root, levels_up), where vcs_root is the
        path to the version control root directory it found, and levels_up is an
        integer indicating how many parent directories it had to search through
        to find it, where 0 means it was found in the indicated path, 1 means it
        was found in that path's parent, etc. If not sucessful, returns None
        """
        if cls.search_parents_for_root():
            valid_dirs = walk_up_dirs(path)
        else:
            valid_dirs = [path]
        for i, current_path in enumerate(valid_dirs):
            if cls.is_valid_root(current_path):
                return current_path, i
        return None