pythongithubgithub-apipygithub

Is there a way in Python GitHub library to check if the branch for which a PR has been raised is out-of-date from it's base branch or not?


enter image description here

    from github import Github

    github_t = os.environ.get('GITHUB_TOKEN')
    github_c = Github(github_t)
    git_i = github_c.search_issues('DEVELOPERS-XXXX', state='open')
    for search in git_i:

Solution

  • result = subprocess.run(['gh', 'pr', 'view', fun_search_pr.html_url, '--json', 'mergeStateStatus'], capture_output=True, text=True)
    
    {
      "mergeStateStatus": "BEHIND"
    }