Exemple #1
0
def get_branch_commit(repo, branch):
    # This may fail, but so far, I don't really know how.
    url = "https://api.github.com/repos/{}/branches/{}".format(repo, branch)
    with github_utils.get_session() as session:
        response = session.get(url)
        response.raise_for_status()
        return response.json()["commit"]["sha"]
Exemple #2
0
 def check_matches(self, match_info, django_version):
     with github_utils.get_session() as session:
         for ticket, ticket_matches in match_info.items():
             sha1 = get_merge_commit_sha1(ticket, session)
             if sha1:
                 if is_commit_in_version(sha1, django_version, session):
                     for match in ticket_matches:
                         yield (
                             "Ticket #{} has been merged in Django {}"
                             .format(ticket, django_version),
                             match)
Exemple #3
0
def download_files_from_repo(repo, commit, files):
    result = {}

    template = "https://raw.githubusercontent.com/{}/{}/{}"
    with github_utils.get_session() as session:
        for filename in files:
            url = template.format(repo, commit, filename)
            response = session.get(url)
            if response.status_code != 200:
                content = FILE_NOT_FOUND
            else:
                content = response.text

            result[filename] = content

    return result
Exemple #4
0
def test_get_session_no_token(mocker):
    mocker.patch("os.getenv", return_value=None)
    assert github_utils.get_session().auth is None
Exemple #5
0
def test_get_session(mocker):
    mocker.patch("os.getenv", return_value="a:b")
    assert github_utils.get_session().auth == ("a", "b")