def test_integration(temp_git_dir): with temp_git_dir.as_cwd(): assert main(argv=[]) == 0 temp_git_dir.join('f.py').write('a' * 10000) cmd_output('git', 'add', 'f.py') # Should not fail with default assert main(argv=['f.py']) == 0 # Should fail with --maxkb assert main(argv=['--maxkb', '9', 'f.py']) == 1
def test_integration(temp_git_dir): with local.cwd(temp_git_dir): assert main(argv=[]) == 0 write_file('f.py', 'a' * 10000) local['git']('add', 'f.py') # Should not fail with default assert main(argv=['f.py']) == 0 # Should fail with --maxkb assert main(argv=['--maxkb', '9', 'f.py']) == 1
def test_allows_gitlfs(temp_git_dir): # pragma: no cover with temp_git_dir.as_cwd(): cmd_output('git', 'lfs', 'install') temp_git_dir.join('f.py').write('a' * 10000) cmd_output('git', 'lfs', 'track', 'f.py') cmd_output('git', 'add', '--', '.') # Should succeed assert main(('--maxkb', '9', 'f.py')) == 0
def test_enforce_allows_gitlfs(temp_git_dir, monkeypatch): # pragma: no cover with temp_git_dir.as_cwd(): monkeypatch.setenv('HOME', str(temp_git_dir)) cmd_output('git', 'lfs', 'install') temp_git_dir.join('f.py').write('a' * 10000) cmd_output('git', 'lfs', 'track', 'f.py') cmd_output('git', 'add', '--', '.') # With --enforce-all large files on git lfs should succeed assert main(('--enforce-all', '--maxkb', '9', 'f.py')) == 0
def test_allows_gitlfs(temp_git_dir, monkeypatch): # pragma: no cover with temp_git_dir.as_cwd(): monkeypatch.setenv(str('HOME'), str(temp_git_dir.strpath)) cmd_output('git', 'lfs', 'install') temp_git_dir.join('f.py').write('a' * 10000) cmd_output('git', 'lfs', 'track', 'f.py') cmd_output('git', 'add', '--', '.') # Should succeed assert main(('--maxkb', '9', 'f.py')) == 0
def test_allows_gitlfs(temp_git_dir): # pragma: no cover with cwd(temp_git_dir): # Work around https://github.com/github/git-lfs/issues/913 cmd_output('git', 'commit', '--allow-empty', '-m', 'foo') cmd_output('git', 'lfs', 'install') write_file('f.py', 'a' * 10000) cmd_output('git', 'lfs', 'track', 'f.py') cmd_output('git', 'add', '.') # Should succeed assert main(('--maxkb', '9', 'f.py')) == 0
def test_moves_with_gitlfs(temp_git_dir): # pragma: no cover with temp_git_dir.as_cwd(): cmd_output('git', 'lfs', 'install') cmd_output('git', 'lfs', 'track', 'a.bin', 'b.bin') # First add the file we're going to move temp_git_dir.join('a.bin').write('a' * 10000) cmd_output('git', 'add', '--', '.') cmd_output('git', 'commit', '--no-gpg-sign', '-am', 'foo') # Now move it and make sure the hook still succeeds cmd_output('git', 'mv', 'a.bin', 'b.bin') assert main(('--maxkb', '9', 'b.bin')) == 0