def do_merge(pr_url, pr, session):
 response = session.put((pr_url + '/merge'), data=json.dumps(dict(sha=pr['head']['sha'])))
 if (response.status_code != 200):
  print('PR failed to merge: {}'.format(response.json()['message']))
  return False
 else:
  print('{} at {}'.format(response.json()['message'], response.json()['sha']))
  del_resp = delete_branch(pr, session)
  if (del_resp.status_code != 204):
   print('Branch deletion failed: {}'.format(del_resp.content))
   return False
 print('Branch deleted')
 return True

def do_merge ( pr_url , pr , session ) : response = session . put ( ( pr_url + '/merge' ) , data = json . dumps ( dict ( sha = pr [ 'head' ] [ 'sha' ] ) ) ) if ( response . status_code != 200 ) : print ( 'PR failed to merge: {}' . format ( response . json ( ) [ 'message' ] ) ) return False else : print ( '{} at {}' . format ( response . json ( ) [ 'message' ] , response . json ( ) [ 'sha' ] ) ) del_resp = delete_branch ( pr , session ) if ( del_resp . status_code != 204 ) : print ( 'Branch deletion failed: {}' . format ( del_resp . content ) ) return False print ( 'Branch deleted' ) return True
attempt a merge using the github api then delete the source branch .