How to use the pydriller.domain.commit.ModificationType.ADD 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
gr = GitRepository('test-repos/test1/')
    c = gr.get_commit('a88c84ddf42066611e76e6cb690144e5357d132c')
    to_zone = timezone(timedelta(hours=1))

    assert c.hash == 'a88c84ddf42066611e76e6cb690144e5357d132c'
    assert c.author.name == 'ishepard'
    assert c.committer.name == 'ishepard'
    assert c.author_date.timestamp() == datetime(2018, 3, 22, 10, 41, 11,
                                                 tzinfo=to_zone).timestamp()
    assert c.committer_date.timestamp() == datetime(2018, 3, 22, 10, 41, 11,
                                                    tzinfo=to_zone).timestamp()
    assert len(c.modifications) == 2
    assert c.msg == 'First commit adding 2 files'
    assert c.in_main_branch is True

    assert c.modifications[0].change_type == ModificationType.ADD
    assert c.modifications[1].change_type == ModificationType.ADD
github ishepard / pydriller / tests / test_commit.py View on Github external
def test_filename():
    diff_and_sc = {
        'diff': '',
        'source_code': '',
        'source_code_before': ''
    }
    m1 = Modification('dspadini/pydriller/myfile.py',
                      'dspadini/pydriller/mynewfile.py',
                      ModificationType.ADD, diff_and_sc)
    m3 = Modification('dspadini/pydriller/myfile.py',
                      'dspadini/pydriller/mynewfile.py',
                      ModificationType.ADD, diff_and_sc)
    m2 = Modification('dspadini/pydriller/myfile.py',
                      None,
                      ModificationType.ADD, diff_and_sc)

    assert m1.filename == 'mynewfile.py'
    assert m2.filename == 'myfile.py'
    assert m1 != m2
    assert m3 == m1
github ishepard / pydriller / tests / test_commit.py View on Github external
def test_filename():
    diff_and_sc = {
        'diff': '',
        'source_code': '',
        'source_code_before': ''
    }
    m1 = Modification('dspadini/pydriller/myfile.py',
                      'dspadini/pydriller/mynewfile.py',
                      ModificationType.ADD, diff_and_sc)
    m3 = Modification('dspadini/pydriller/myfile.py',
                      'dspadini/pydriller/mynewfile.py',
                      ModificationType.ADD, diff_and_sc)
    m2 = Modification('dspadini/pydriller/myfile.py',
                      None,
                      ModificationType.ADD, diff_and_sc)

    assert m1.filename == 'mynewfile.py'
    assert m2.filename == 'myfile.py'
    assert m1 != m2
    assert m3 == m1
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
github mozilla / normandy / bin / generate_deploy_bug.py View on Github external
"root": {"handlers": ["console"], "level": "WARNING"},
            "loggers": {
                "normandy": {"propagate": False, "handlers": ["console"], "level": log_level}
            },
        }
    )

    pr_commits = []
    dependency_updates = []
    migrations = []

    mine = RepositoryMining(".", from_tag=args.from_tag, to_tag=args.to_tag)
    num_commits_processed = 0
    for commit in mine.traverse_commits():
        for mod in commit.modifications:
            if mod.change_type == ModificationType.ADD and "/migrations/" in mod.new_path:
                migrations.append(get_migration_desc(mod))

        if not commit.merge:
            log.debug(f"Skipping {commit.hash[:7]}: Not a merge")
            # Not a PR merge
            continue
        commit.prs = get_pr_numbers(commit)
        if not commit.prs:
            log.debug(f"Skipping {commit.hash[:7]}: No PR numbers")
            continue

        if is_dependency_update(commit):
            log.debug(f"Processing commit {commit.hash[:7]} as dependency commit")
            dependency_updates.append(commit)
        else:
            log.debug(f"Processing commit {commit.hash[:7]} as normal commit")