import requests


def pr_info(branch: str):
    """Get PR title and link from github api"""
    _, _, pr_nr = branch.partition("-")
    try:
        response = requests.get(
            f"https://api.github.com/repos/glotaran/pyglotaran/pulls/{pr_nr}",
        ).json()
        return response["title"], response["html_url"], response["state"]
    except Exception:
        return pr_nr, f"https://github.com/glotaran/pyglotaran/pull/{pr_nr}", "unknown"