Ticket #74: mail.py.diff

File mail.py.diff, 3.0 KB (added by rochg, 5 years ago)
  • mail.py

    RCS file: /cvsroot/buildbot/buildbot/buildbot/status/mail.py,v
    retrieving revision 1.28
    diff -u -r1.28 mail.py
     
    100100        @param mode: one of: 
    101101                     - 'all': send mail about all builds, passing and failing 
    102102                     - 'failing': only send mail about builds which fail 
     103                     - 'warnings': send mail about builds containing warnings 
    103104                     - 'problem': only send mail about a build which failed 
    104105                     when the previous build passed 
    105106 
     
    206207               builder.category not in self.categories: 
    207208            return # ignore this build 
    208209 
    209         if self.mode == "failing" and results != FAILURE: 
    210             return 
    211         if self.mode == "problem": 
    212             if results != FAILURE: 
    213                 return 
     210        # Decide whether or not a message is to be sent 
     211        domail = False 
     212 
     213        if self.mode == "warnings" and (results == WARNINGS or results == FAILURE): 
     214            domail = True 
     215        if self.mode == "failing" and results == FAILURE: 
     216            domail = True 
     217        if self.mode == "problem" and results == FAILURE: 
    214218            prev = build.getPreviousBuild() 
    215             if prev and prev.getResults() == FAILURE: 
    216                 return 
     219            if prev: 
     220                if prev.getResults() != FAILURE: 
     221                    domail = True 
     222            else: 
     223                domail = True 
     224 
    217225        # for testing purposes, buildMessage returns a Deferred that fires 
    218226        # when the mail has been sent. To help unit tests, we return that 
    219227        # Deferred here even though the normal IStatusReceiver.buildFinished 
    220228        # signature doesn't do anything with it. If that changes (if 
    221229        # .buildFinished's return value becomes significant), we need to 
    222230        # rearrange this. 
    223         return self.buildMessage(name, build, results) 
     231        if domail: 
     232            return self.buildMessage(name, build, results) 
    224233 
    225234    def buildMessage(self, name, build, results): 
    226235        text = "" 
     
    228237            text += "The Buildbot has finished a build of %s.\n" % name 
    229238        elif self.mode == "failing": 
    230239            text += "The Buildbot has detected a failed build of %s.\n" % name 
    231         else: 
     240        elif self.mode == "problem": 
    232241            text += "The Buildbot has detected a new failure of %s.\n" % name 
     242        else: 
     243            text += "The Buildbot has detected warnings in %s.\n" % name 
    233244        buildurl = self.status.getURLForThing(build) 
    234245        if buildurl: 
    235246            text += "Full details are available at:\n %s\n" % buildurl 
     
    252263            if branch: 
    253264                source += "[branch %s] " % branch 
    254265            if revision: 
    255                 source += revision 
     266                source += str(revision) 
    256267            else: 
    257268                source += "HEAD" 
    258269            if patch is not None: