| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 return result; | 46 return result; |
| 47 } | 47 } |
| 48 return null; | 48 return null; |
| 49 } | 49 } |
| 50 | 50 |
| 51 function isRollbotStopped(issue) { | 51 function isRollbotStopped(issue) { |
| 52 // Ignore the first message as it always contains "STOP" | 52 // Ignore the first message as it always contains "STOP" |
| 53 return issue.messages.slice(1).some(function(message) { return message.text.
match(/STOP/); }); | 53 return issue.messages.slice(1).some(function(message) { return message.text.
match(/STOP/); }); |
| 54 } | 54 } |
| 55 | 55 |
| 56 rollbot.fetchCurrentRoll = function(callback) { | 56 rollbot.fetchCurrentRoll = function() { |
| 57 net.json(issueSearchURL).then(function(searchJSON) { | 57 return net.json(issueSearchURL).then(function(searchJSON) { |
| 58 var issue = findRollIssue(searchJSON); | 58 var issue = findRollIssue(searchJSON); |
| 59 if (!issue) { | 59 if (!issue) |
| 60 callback(null); | 60 return null; |
| 61 return; | |
| 62 } | |
| 63 | 61 |
| 64 var issueNumber = issue['issue']; | 62 var issueNumber = issue['issue']; |
| 65 var subjectMatch = issue['subject'].match(rollSubjectRegexp); | 63 var subjectMatch = issue['subject'].match(rollSubjectRegexp); |
| 66 callback({ | 64 return { |
| 67 'issue': issueNumber, | 65 'issue': issueNumber, |
| 68 'url': config.kRietveldURL + "/" + issueNumber, | 66 'url': config.kRietveldURL + "/" + issueNumber, |
| 69 'isStopped': isRollbotStopped(issue), | 67 'isStopped': isRollbotStopped(issue), |
| 70 'fromRevision': subjectMatch[1], | 68 'fromRevision': subjectMatch[1], |
| 71 'toRevision': subjectMatch[2], | 69 'toRevision': subjectMatch[2], |
| 72 }); | 70 }; |
| 73 }); | 71 }); |
| 74 }; | 72 }; |
| 75 | 73 |
| 76 // Exposed for unittesting. | 74 // Exposed for unittesting. |
| 77 rollbot._isRollbotStopped = isRollbotStopped; | 75 rollbot._isRollbotStopped = isRollbotStopped; |
| 78 | 76 |
| 79 })(); | 77 })(); |
| OLD | NEW |