Ejemplo n.º 1
0
            if branch not in hashes[repo['repository']]:
                hashes[repo['repository']][branch] = {}

            for file in repo['files']:
                response = github_api.get_file(repo['repository'], file)
                sha = response['sha']

                path = file_path(repo['repository'], file)

                if file in hashes[repo['repository']][branch] and hashes[
                        repo['repository']][branch][file] != sha:
                    response = github_api.get_file_commits(
                        repo['repository'], file)
                    commit = response[0]

                    notifier.append(notifier.notify_commit(file, commit))
                    hashes[repo['repository']][branch][file] = sha

        notifier.send_notifications(
            '[{}] A new commit changed watched files.'.format(
                repo['repository']))

    except PermissionError as e:
        notifier.append(notifier.error(e.args[0]),
                        '[{}] API Error!'.format(repo['repository']))
        notifier.send_notifications(
            '[{}] A new commit changed watched files.'.format(
                repo['repository']))
        raise e

with open('hashes.json', 'w') as fp:
Ejemplo n.º 2
0
        delta = timedelta(**repo['timespan'])
        time_from = now - delta

        if 'branches' not in repo:
            repo['branches'] = ['master']

        for branch in repo['branches']:
            prs = github_api.get_prs_since(repo['repository'], branch,
                                           time_from)
            n = len(prs)

            for i in range(n):
                response = github_api.get_pr_files(repo['repository'],
                                                   prs[i]['number'])

                for file in response:
                    if file['filename'] in repo['files']:
                        notifier.append(notifier.notify_pr(file, prs[i]))

        notifier.send_notifications(
            '[{}] A new pull request changes watched files.'.format(
                repo['repository']))

    except PermissionError as e:
        notifier.append(notifier.error(e.args[0]),
                        '[{}] API Error!'.format(repo['repository']))
        notifier.send_notifications(
            '[{}] A new commit changed watched files.'.format(
                repo['repository']))
        raise e