def master_differences_check(printer):
  ###################################################################################################
  # MAKE SURE MASTER LOCAL AND REMOTE ARE THE SAME
  ###################################################################################################
  printer.print_process('Checking for differences with local master')
  if Helper.local_sha('master') != Helper.origin_sha('master'):
    printer.print_warning("Remote master is different than local master. Suggestion: (git checkout master && git pull origin master)")
  else:
    printer.print_check()
def circleci_check(printer, circle_gateway):
  ###################################################################################################
  # CHECK FOR CIRCLECI TESTS
  ###################################################################################################
  printer.print_process('Checking CircleCi tests status')
  passed = False
  for build in circle_gateway.get_builds():
    if build['vcs_revision'] == Helper.local_sha() and build['outcome'] == 'success':
      passed = True
      break
  if passed:
    printer.print_check()
  else:
    printer.print_error("Tests have not yet passed")
def branch_differences_check(printer, github_gateway):
  ###################################################################################################
  # MAKE SURE LOCAL AND REMOTE BRANCH ARE THE SAME
  ###################################################################################################
  printer.print_process('Checking for differences with local branch')
  commits = github_gateway.get_pr_commits(Helper.current_branch())
  if len(commits) <= 0:
    printer.print_error("No commits on the pr. Suggestion: push any changes")
  else:
    pr_sha = commits[-1]['sha']
    local_sha = Helper.local_sha()
    if pr_sha != local_sha:
      branch = Helper.current_branch()
      printer.print_warning("The commit on the pr is different than local. Suggestion: (git push -f origin {0}) or (git pull origin {0})".format(branch))
    else:
      printer.print_check()