How to use the gitlint.linters.parse_yaml_config function in gitlint

To help you get started, we’ve selected a few gitlint examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sk- / git-lint / test / unittest / test_linters.py View on Github external
'arguments': [],
                'command':
                'ls',
                'requirements': [
                    'some_unexistent_command_one',
                    'ls',
                    'some_unexistent_command_two',
                ],
                'extensions': ['.foo'],
                'filter':
                '.*',
                'installation':
                'Run apt-get install command_one command_two',
            }
        }
        config = linters.parse_yaml_config(yaml_config, '')
        self.assertEqual({
            'filename': {
                'skipped': [
                    'some_unexistent_command_one, ' +
                    'some_unexistent_command_two are not '
                    'installed. Run apt-get install command_one ' +
                    'command_two'
                ]
            }
        }, config['.foo'][0]('filename', []))
github sk- / git-lint / test / unittest / test_linters.py View on Github external
'{REPO_HOME}/bin/linter'.format(**variables),
                'requirements': [
                    '{REPO_HOME}/bin/dep1'.format(**variables),
                ],
                'extensions': ['.foo'],
                'filter':
                '.*',
                'installation':
                'install',
            }
        }

        with mock.patch('gitlint.utils.which', return_value=['lint']):
            config_with_vars = linters.parse_yaml_config(
                yaml_config_with_vars, variables['REPO_HOME'])
            config_no_vars = linters.parse_yaml_config(yaml_config_no_vars,
                                                       variables['REPO_HOME'])

            self.assertEqual(config_with_vars, config_no_vars)
github sk- / git-lint / test / unittest / test_linters.py View on Github external
def test_parse_yaml_config_command_not_in_path(self):
        yaml_config = {
            'linter': {
                'arguments': [],
                'command':
                'some_unexistent_program_name',
                'extensions': ['.foo'],
                'filter':
                '.*',
                'installation':
                ('Go to some_unexistent_program_name.com to ' + 'install it.'),
            }
        }
        config = linters.parse_yaml_config(yaml_config, '')
        self.assertEqual({
            'filename': {
                'skipped': [
                    'some_unexistent_program_name is not ' +
                    'installed. Go to some_unexistent_program_' +
                    'name.com to install it.'
                ]
            }
        }, config['.foo'][0]('filename', []))
github sk- / git-lint / test / unittest / test_linters.py View on Github external
],
                'command':
                '{REPO_HOME}/bin/linter'.format(**variables),
                'requirements': [
                    '{REPO_HOME}/bin/dep1'.format(**variables),
                ],
                'extensions': ['.foo'],
                'filter':
                '.*',
                'installation':
                'install',
            }
        }

        with mock.patch('gitlint.utils.which', return_value=['lint']):
            config_with_vars = linters.parse_yaml_config(
                yaml_config_with_vars, variables['REPO_HOME'])
            config_no_vars = linters.parse_yaml_config(yaml_config_no_vars,
                                                       variables['REPO_HOME'])

            self.assertEqual(config_with_vars, config_no_vars)
github sk- / git-lint / gitlint / __init__.py View on Github external
if repo_root:
        repo_config = os.path.join(repo_root, '.gitlint.yaml')
        if os.path.exists(repo_config):
            config = repo_config

    with open(config) as f:
        # We have to read the content first as yaml hangs up when reading from
        # MockOpen
        content = f.read()
        # Yaml.load will return None when the input is empty.
        if not content:
            yaml_config = {}
        else:
            yaml_config = yaml.load(content)

    return linters.parse_yaml_config(yaml_config, repo_root)