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()
Ejemplo n.º 2
0
def run():
  branch = Helper.current_branch()
  match = re.search('^(\d+)\-', branch)
  issue = None
  if match is not None:
    owner, repo = Helper.owner_and_repo()
    webbrowser.open('https://github.com/{0}/{1}/issues/{2}'.format(owner, repo, match.group(1)))
  else:
    print 'No issue number on branch'
def master_conflicts_check(printer):
  ###################################################################################################
  # CHECK FOR CONFLICTS WITH LOCAL MASTER
  ###################################################################################################
  printer.print_process('Checking for conflicts with origin master')
  if not Helper.has_origin_conflicts():
    printer.print_check()
  else:
    msg = 'There are conflicts that must be resolved'
    msg += '. Suggestion: (git checkout master && git pull origin master && git checkout {0} && git rebase master)'
    printer.print_error(msg.format(Helper.current_branch()))
Ejemplo n.º 4
0
def merge(printer, github_gateway):
  ###################################################################################################
  # 'CLICK' MERGE BUTTON
  ###################################################################################################
  printer.print_process('Triggering "Merge pull request" button actions')
  result = github_gateway.merge_pr(Helper.current_branch())
  if result is not None:
    if result.get('merged') is not None and result['merged'] == True:
      printer.print_check()
    else:
      if result.get('message') is not None:
        printer.print_error(result['message'])
      else:
        printer.print_error('Could not perform merge')
      sys.exit(-1)
  else:
    printer.print_error('Could not find open PR')
    sys.exit(-1)
Ejemplo n.º 5
0
  def get_lg_data(self):
    current_user = self._github_gateway.get_user()['login']
    all_comments = self._github_gateway.get_pr_and_review_comments(Helper.current_branch())
    comment_ids_addressed = self.get_ids_addressed(current_user, all_comments)
    all_comments.pop(current_user, None)
    ret = {}
    ret['lgs_count'] = 0
    ret['has_unaddressed_comments'] = False
    ret['has_nonregular_lgs'] = False
    ret['comments'] = {}
    for comments_user, comments in all_comments.iteritems():
      unaddressed_comments = []
      lgd = False
      lgcomment = None
      for comment in reversed(comments):
        match = re.search(r'\bLG\b', comment['body'], flags=re.IGNORECASE)
        if match is not None:
          lgcomment = comment['body']
          if len(unaddressed_comments) <= 0:
            ret['lgs_count'] += 1
            if comment['body'].upper().strip() != 'LG':
              ret['has_nonregular_lgs'] = True
          break
        else:
          if str(comment['id']) not in comment_ids_addressed:
            unaddressed_comments.append(comment)

      if len(unaddressed_comments) > 0:
        ret['has_unaddressed_comments'] = True

      ret['comments'][comments_user] = {
        'unaddressed_comments': unaddressed_comments,
        'lgcomment': lgcomment
      }

    return ret
Ejemplo n.º 6
0
 def get_builds(self):
   branch = Helper.current_branch()
   return self.call('recent_branch_builds', username=self._username, project=self._project, branch=branch)[0]