Guest User

Untitled

a guest
Nov 24th, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 2.13 KB | None | 0 0
  1.     diff --git a/roundabout/github/client.py b/roundabout/github/client.py
  2.     index f2e49c9..487147f 100644
  3.     --- a/roundabout/github/client.py
  4.     +++ b/roundabout/github/client.py
  5.     @@ -82,12 +82,13 @@ class PullRequest(object):
  6.          """ A github pull request """
  7.      
  8.          def __init__(self, client, pull_request, lgtm_text, username=None,
  9.     -                 password=None):
  10.     +                 password=None, rejection_token='rejecting'):
  11.              """ Take a pull_request dict from github, and builds a PullRequest """
  12.      
  13.              self.__dict__ = pull_request
  14.              self.client = client
  15.     -        self.lgtm_text = lgtm_text
  16.     +        self.lgtm_text = lgtm_text.lower()
  17.     +        self.rejection_token = rejection_token.lower()
  18.              self.username = username
  19.              self.password = password
  20.      
  21.     @@ -131,23 +132,14 @@ class PullRequest(object):
  22.              "lgtmed" the request. Returns true if so, None otherwise.
  23.              """
  24.      
  25.     -        lgtm_re = re.compile("^%s$" % re.escape(self.lgtm_text), re.I)
  26.     -        rejected_re = re.compile("rejecting")
  27.     -
  28.     -        lgtms = []
  29.     -        rejected = [c for c
  30.     -                      in self.discussion
  31.     -                      if rejected_re.search(c.get('body', ''))]
  32.     -
  33.     -        for comment in self.discussion:
  34.     -            try:
  35.     -                if comment['user']['login'] in approvers and \
  36.     -                   lgtm_re.match(comment.get('body', "")):
  37.     -                    lgtms.append(comment)
  38.     -            except TypeError:
  39.     -                continue
  40.     -
  41.     -        return len(rejected) < len(lgtms)
  42.     +        rejection_cnt, lgtm_cnt = 0, 0
  43.     +        for c in self.discussion:
  44.     +            body = c.get('body', '').lower()
  45.     +            if self.rejection_token in body:
  46.     +                rejection_cnt += 1
  47.     +            elif c['user']['login'] in approvers and body == self.lgtm_text:
  48.     +                lgtm_cnt += 1
  49.     +        return rejection_cnt < lgtm_cnt
  50.      
  51.          def __get_full_request(self):
  52.              """
Add Comment
Please, Sign In to add comment