How to use the gitlint.git.modified_lines 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_git.py View on Github external
def test_modified_lines_new_addition(self):
        self.assertEqual(
            None,
            git.modified_lines('/home/user/repo/foo/bar.txt', 'A '))
github sk- / git-lint / test / unittest / test_git.py View on Github external
def test_modified_lines(self):
        output = os.linesep.join([
            'baz',
            '0000000000000000000000000000000000000000 2 2 4',
            'foo',
            '0000000000000000000000000000000000000000 5 5',
            'bar']).encode('utf-8')
        with mock.patch('subprocess.check_output',
                        return_value=output) as check_output:
            self.assertEqual(
                [2, 5],
                list(git.modified_lines('/home/user/repo/foo/bar.txt', ' M')))
            self.assertEqual(
                [2, 5],
                list(git.modified_lines('/home/user/repo/foo/bar.txt', 'M ')))
            self.assertEqual(
                [2, 5],
                list(git.modified_lines('/home/user/repo/foo/bar.txt', 'MM')))
            expected_calls = [mock.call(
                ['git', 'blame', '--porcelain',
                 '/home/user/repo/foo/bar.txt'])] * 3
            self.assertEqual(expected_calls, check_output.call_args_list)
github sk- / git-lint / test / unittest / test_git.py View on Github external
def test_modified_lines(self):
        output = os.linesep.join([
            'baz',
            '0000000000000000000000000000000000000000 2 2 4',
            'foo',
            '0000000000000000000000000000000000000000 5 5',
            'bar']).encode('utf-8')
        with mock.patch('subprocess.check_output',
                        return_value=output) as check_output:
            self.assertEqual(
                [2, 5],
                list(git.modified_lines('/home/user/repo/foo/bar.txt', ' M')))
            self.assertEqual(
                [2, 5],
                list(git.modified_lines('/home/user/repo/foo/bar.txt', 'M ')))
            self.assertEqual(
                [2, 5],
                list(git.modified_lines('/home/user/repo/foo/bar.txt', 'MM')))
            expected_calls = [mock.call(
                ['git', 'blame', '--porcelain',
                 '/home/user/repo/foo/bar.txt'])] * 3
            self.assertEqual(expected_calls, check_output.call_args_list)
github sk- / git-lint / test / unittest / test_git.py View on Github external
'baz',
            '0000000000000000000000000000000000000000 2 2 4',
            'foo',
            '0000000000000000000000000000000000000000 5 5',
            'bar']).encode('utf-8')
        with mock.patch('subprocess.check_output',
                        return_value=output) as check_output:
            self.assertEqual(
                [2, 5],
                list(git.modified_lines('/home/user/repo/foo/bar.txt', ' M')))
            self.assertEqual(
                [2, 5],
                list(git.modified_lines('/home/user/repo/foo/bar.txt', 'M ')))
            self.assertEqual(
                [2, 5],
                list(git.modified_lines('/home/user/repo/foo/bar.txt', 'MM')))
            expected_calls = [mock.call(
                ['git', 'blame', '--porcelain',
                 '/home/user/repo/foo/bar.txt'])] * 3
            self.assertEqual(expected_calls, check_output.call_args_list)
github sk- / git-lint / test / unittest / test_git.py View on Github external
return_value=output) as check_output:
            self.assertEqual(
                [2, 5],
                list(git.modified_lines(
                    '/home/user/repo/foo/bar.txt',
                    ' M',
                    commit='0123456789abcdef31410123456789abcdef3141')))
            self.assertEqual(
                [2, 5],
                list(git.modified_lines(
                    '/home/user/repo/foo/bar.txt',
                    'M ',
                    commit='0123456789abcdef31410123456789abcdef3141')))
            self.assertEqual(
                [2, 5],
                list(git.modified_lines(
                    '/home/user/repo/foo/bar.txt',
                    'MM',
                    commit='0123456789abcdef31410123456789abcdef3141')))
            expected_calls = [mock.call(
                ['git', 'blame', '--porcelain',
                 '/home/user/repo/foo/bar.txt'])] * 3
            self.assertEqual(expected_calls, check_output.call_args_list)