How to use the pydriller.domain.commit.ModificationType.MODIFY function in PyDriller

To help you get started, we’ve selected a few PyDriller 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 ishepard / pydriller / tests / test_git_repository.py View on Github external
def test_modification_status():
    gr = GitRepository('test-repos/git-1/')
    commit = gr.get_commit('866e997a9e44cb4ddd9e00efe49361420aff2559')
    assert commit.modifications[0].change_type == ModificationType.ADD
    assert commit.modifications[0].old_path is None

    commit = gr.get_commit('57dbd017d1a744b949e7ca0b1c1a3b3dd4c1cbc1')
    assert commit.modifications[0].change_type == ModificationType.MODIFY
    assert commit.modifications[0].new_path == commit.modifications[0].old_path

    commit = gr.get_commit('ffccf1e7497eb8136fd66ed5e42bef29677c4b71')
    assert commit.modifications[0].change_type == ModificationType.DELETE
    assert commit.modifications[0].new_path is None
github ishepard / pydriller / tests / test_commit.py View on Github external
def test_metrics_not_supported_file():
    sc = 'asd !&%@*&^@\n jjdkj'

    diff_and_sc = {
        'diff': '',
        'source_code': sc,
        'source_code_before': sc
    }

    m1 = Modification('test-repos/test6/NotSupported.pdf',
                      "test-repos/test6/NotSupported.pdf",
                      ModificationType.MODIFY, diff_and_sc)

    assert m1.nloc == 2
    assert len(m1.methods) == 0
github ishepard / pydriller / pydriller / domain / commit.py View on Github external
def _from_change_to_modification_type(diff: Diff):
        if diff.new_file:
            return ModificationType.ADD
        if diff.deleted_file:
            return ModificationType.DELETE
        if diff.renamed_file:
            return ModificationType.RENAME
        if diff.a_blob and diff.b_blob and diff.a_blob != diff.b_blob:
            return ModificationType.MODIFY

        return ModificationType.UNKNOWN