def test_get_commits_last_modified_lines_rename_simple():
    gr = GitRepository('test-repos/test5/')

    buggy_commits = gr.get_commits_last_modified_lines(
        gr.get_commit('45ba0a61ccc448625bce0fea0301cf0c1ab32696'))

    assert len(buggy_commits) == 1
    assert 'e358878a00e78aca8366264d61a7319d00dd8186' in buggy_commits[
        'C.java']
def test_get_commits_last_modified_lines_simple():
    gr = GitRepository('test-repos/test5/')

    buggy_commits = gr.get_commits_last_modified_lines(
        gr.get_commit('e6d3b38a9ef683e8184eac10a0471075c2808bbd'))

    assert len(buggy_commits) == 1
    assert '540c7f31c18664a38190fafb6721b5174ff4a166' in buggy_commits[
        'B.java']
示例#3
0
def test_get_commits_last_modified_lines_hyper_blame_unblamable(
        tmp_path, repo: GitRepository):
    p = tmp_path / "ignore.txt"
    p.write_text("540c7f31c18664a38190fafb6721b5174ff4a166")

    buggy_commits = repo.get_commits_last_modified_lines(
        repo.get_commit('e6d3b38a9ef683e8184eac10a0471075c2808bbd'),
        hashes_to_ignore_path=str(p))

    assert len(buggy_commits) == 0
示例#4
0
def test_get_commits_last_modified_lines_hyper_blame_with_renaming(
        repo: GitRepository):
    buggy_commits = repo.get_commits_last_modified_lines(
        repo.get_commit('be0772cbaa2eba32bf97aae885199d1a357ddc93'))

    assert len(buggy_commits) == 2
    assert '9568d20856728304ab0b4d2d02fb9e81d0e5156d' in buggy_commits[
        'A.java']
    assert '9568d20856728304ab0b4d2d02fb9e81d0e5156d' in buggy_commits[
        'H.java']
示例#5
0
def test_get_commits_last_modified_lines_multiple():
    gr = GitRepository('test-repos/test5/')

    buggy_commits = gr.get_commits_last_modified_lines(
        gr.get_commit('9942ee9dcdd1103e5808d544a84e6bc8cade0e54'))

    assert len(buggy_commits) == 3
    assert '2eb905e5e7be414fd184d6b4f1571b142621f4de' in buggy_commits
    assert '20a40688521c1802569e60f9d55342c3bfdd772c' in buggy_commits
    assert '22505e97dca6f843549b3a484b3609be4e3acf17' in buggy_commits
示例#6
0
def test_get_commits_last_modified_lines_for_single_file():
    gr = GitRepository('test-repos/test5/')

    commit = gr.get_commit('0f726924f96621e4965039123098ba83e39ffba6')
    buggy_commits = None
    for mod in commit.modifications:
        if mod.filename == 'A.java':
            buggy_commits = gr.get_commits_last_modified_lines(commit, mod)

    assert len(buggy_commits) == 1
    assert 'e2ed043eb96c05ebde653a44ae733ded9ef90750' in buggy_commits
示例#7
0
def test_get_commits_last_modified_lines_rename_simple_more_commits():
    gr = GitRepository('test-repos/test5/')

    buggy_commits = gr.get_commits_last_modified_lines(
        gr.get_commit('04fadd3e68c58281db6cf15119f9769880ac1cbc'))

    assert len(buggy_commits) == 2
    assert '9b373199c270f9b24c37fee70f9e2b3ee9b816e3' in buggy_commits[
        'A.java']
    assert '9b373199c270f9b24c37fee70f9e2b3ee9b816e3' in buggy_commits[
        'B.java']
def test_get_commits_last_modified_lines_hyper_blame_ignore_hash(tmp_path, repo: GitRepository):
    p = tmp_path / "ignore.txt"
    p.write_text("5cb9e9ae44a0949ec91d06a955975289be766f34")

    buggy_commits = repo.get_commits_last_modified_lines(repo.get_commit(
        'c7002fb321a8ba32a28fac200538f7c2ba76f175'),
        hashes_to_ignore_path=str(p))

    assert len(buggy_commits) == 1
    assert 'c41d270f8abc203c895309235adbd5f3f81d4a45' in buggy_commits[
        'A.java']
示例#9
0
def test_get_commits_last_modified_lines_hyper_blame_with_renaming(
        depot_tools, tmpdir):
    gr = GitRepository('test-repos/test5/')

    buggy_commits = gr.get_commits_last_modified_lines(
        gr.get_commit('be0772cbaa2eba32bf97aae885199d1a357ddc93'))

    assert len(buggy_commits) == 2
    assert '9568d20856728304ab0b4d2d02fb9e81d0e5156d' in buggy_commits[
        'A.java']
    assert '9568d20856728304ab0b4d2d02fb9e81d0e5156d' in buggy_commits[
        'H.java']
示例#10
0
def test_get_commits_last_modified_lines_hyper_blame_ignore_hash(
        depot_tools, tmpdir):
    with open(os.path.join(str(tmpdir), "ignore"), "w") as f:
        f.write("540c7f31c18664a38190fafb6721b5174ff4a166")

    gr = GitRepository('test-repos/test5/')

    buggy_commits = gr.get_commits_last_modified_lines(
        gr.get_commit('e6d3b38a9ef683e8184eac10a0471075c2808bbd'),
        hashes_to_ignore_path=tmpdir / "ignore")

    assert len(buggy_commits) == 1
    assert '22505e97dca6f843549b3a484b3609be4e3acf17' in buggy_commits[
        'B.java']
示例#11
0
def test_get_commits_last_modified_lines_useless_lines2(repo: GitRepository):
    buggy_commits = repo.get_commits_last_modified_lines(
        repo.get_commit('4155c421ee5cbb3c34feee7b68aa78a2ee1bbeae'))
    assert len(buggy_commits) == 0
示例#12
0
def test_get_commits_last_modified_lines_useless_lines2():
    gr = GitRepository('test-repos/test5/')

    buggy_commits = gr.get_commits_last_modified_lines(
        gr.get_commit('4155c421ee5cbb3c34feee7b68aa78a2ee1bbeae'))
    assert len(buggy_commits) == 0
示例#13
0
def test_get_commits_last_modified_lines_useless_lines():
    gr = GitRepository('test-repos/test5/')

    buggy_commits = gr.get_commits_last_modified_lines(gr.get_commit('3bc7295c16b7dfc15d5f82eb6962a2774e1b8420'))
    assert len(buggy_commits) == 1
    assert 'c7fc2e870ce03b0b8dc29ed0eeb26d14e235ea3b' in buggy_commits
示例#14
0
def test_get_commits_last_modified_lines_rename_simple_more_commits():
    gr = GitRepository('test-repos/test5/')

    buggy_commits = gr.get_commits_last_modified_lines(gr.get_commit('4e287ab8e6dba110219404fb8a43993f3dda674c'))
    assert len(buggy_commits) == 1
    assert '06b9ff31cd3475d9fd9ef668cc0844ab169da726' in buggy_commits
示例#15
0
def test_get_commits_last_modified_lines_multiple_rename():
    gr = GitRepository('test-repos/test5/')
    # in this case the algorithm doesn't work because the file has been renamed 2 times!

    buggy_commits = gr.get_commits_last_modified_lines(gr.get_commit('9e858753b3d69f560cf72aaaa297f2608145ebcf'))
    assert len(buggy_commits) == 0
def test_get_commits_last_modified_lines_rename_and_fix(repo: GitRepository):
    buggy_commits = repo.get_commits_last_modified_lines(repo.get_commit('4e287ab8e6dba110219404fb8a43993f3dda674c'))

    assert len(buggy_commits) == 1
    assert '06b9ff31cd3475d9fd9ef668cc0844ab169da726' in buggy_commits[
        'H.java']
def test_get_commits_last_modified_lines_rename(repo: GitRepository):
    buggy_commits = repo.get_commits_last_modified_lines(repo.get_commit('2f2d0dec7cd06de4c2ed11ed010727a54af8ebf8'))

    assert len(buggy_commits) == 1
    assert '00e61714fd76ff110d8da953aa1179809591f5aa' in buggy_commits[
        str(Path('myfolder/Z.java'))]
示例#18
0
def test_get_commits_last_modified_lines_useless_lines(repo: GitRepository):
    buggy_commits = repo.get_commits_last_modified_lines(
        repo.get_commit('3bc7295c16b7dfc15d5f82eb6962a2774e1b8420'))
    assert len(buggy_commits) == 1
    assert 'c7fc2e870ce03b0b8dc29ed0eeb26d14e235ea3b' in buggy_commits[
        'H.java']
def test_get_commits_last_modified_lines_with_more_modification(repo: GitRepository):
    buggy_commits = repo.get_commits_last_modified_lines(repo.get_commit('c7002fb321a8ba32a28fac200538f7c2ba76f175'))
    assert len(buggy_commits) == 1
    assert '5cb9e9ae44a0949ec91d06a955975289be766f34' in buggy_commits[
        'A.java']