Exemple #1
0
 def test_parse_bug_id(self):
     # Test that we can parse the urls we produce.
     bugs = Bugzilla()
     self.assertEqual(
         12345, urls.parse_bug_id(bugs.short_bug_url_for_bug_id(12345)))
     self.assertEqual(12345,
                      urls.parse_bug_id(bugs.bug_url_for_bug_id(12345)))
     self.assertEqual(
         12345, urls.parse_bug_id(bugs.bug_url_for_bug_id(12345, xml=True)))
Exemple #2
0
def _post_error_and_check_for_bug_url(tool, nicks_string, exception):
    tool.irc().post("%s" % exception)
    bug_id = urls.parse_bug_id(exception.output)
    if bug_id:
        bug_url = tool.bugs.bug_url_for_bug_id(bug_id)
        tool.irc().post("%s: Ugg...  Might have created %s" %
                        (nicks_string, bug_url))
Exemple #3
0
    def post_rollout_patch(self, svn_revision_list, rollout_reason):
        # Ensure that svn revisions are numbers (and not options to
        # create-rollout).
        try:
            svn_revisions = " ".join([str(int(revision)) for revision in svn_revision_list])
        except:
            raise ScriptError(message="Invalid svn revision number \"%s\"."
                              % " ".join(svn_revision_list))

        if rollout_reason.startswith("-"):
            raise ScriptError(message="The rollout reason may not begin "
                              "with - (\"%s\")." % rollout_reason)

        output = self._sheriffbot.run_webkit_patch([
            "create-rollout",
            "--force-clean",
            # In principle, we should pass --non-interactive here, but it
            # turns out that create-rollout doesn't need it yet.  We can't
            # pass it prophylactically because we reject unrecognized command
            # line switches.
            "--parent-command=sheriff-bot",
            svn_revisions,
            rollout_reason,
        ])
        return urls.parse_bug_id(output)
Exemple #4
0
    def post_revert_patch(self, svn_revision_list, revert_reason):
        # Ensure that svn revisions are numbers (and not options to
        # create-revert).
        try:
            svn_revisions = " ".join(
                [str(int(revision)) for revision in svn_revision_list])
        except:
            raise ScriptError(message="Invalid svn revision number \"%s\"." %
                              " ".join(svn_revision_list))

        if revert_reason.startswith("-"):
            raise ScriptError(message="The revert reason may not begin "
                              "with - (\"%s\")." % revert_reason)

        output = self._sheriffbot.run_webkit_patch([
            "create-revert",
            "--force-clean",
            # In principle, we should pass --non-interactive here, but it
            # turns out that create-revert doesn't need it yet.  We can't
            # pass it prophylactically because we reject unrecognized command
            # line switches.
            "--parent-command=sheriff-bot",
            svn_revisions,
            revert_reason,
        ])
        return urls.parse_bug_id(output)
Exemple #5
0
 def post_chromium_deps_roll(self, revision, revision_name):
     args = [
         "post-chromium-deps-roll",
         "--force-clean",
         "--non-interactive",
         "--parent-command=sheriff-bot",
     ]
     # revision can be None, but revision_name is always something meaningful.
     args += [revision, revision_name]
     output = self._sheriffbot.run_webkit_patch(args)
     return urls.parse_bug_id(output)
Exemple #6
0
 def post_chromium_deps_roll(self, revision, revision_name):
     args = [
         "post-chromium-deps-roll",
         "--force-clean",
         "--non-interactive",
         "--parent-command=sheriff-bot",
     ]
     # revision can be None, but revision_name is always something meaningful.
     args += [revision, revision_name]
     output = self._sheriffbot.run_webkit_patch(args)
     return urls.parse_bug_id(output)
Exemple #7
0
def parse_bug_id_from_changelog(message):
    if not message:
        return None
    match = re.search("^\s*" + config_urls.bug_url_short + "$", message, re.MULTILINE)
    if match:
        return int(match.group('bug_id'))
    match = re.search("^\s*" + config_urls.bug_url_long + "$", message, re.MULTILINE)
    if match:
        return int(match.group('bug_id'))
    # We weren't able to find a bug URL in the format used by prepare-ChangeLog. Fall back to the
    # first bug URL found anywhere in the message.
    return config_urls.parse_bug_id(message)
Exemple #8
0
def parse_bug_id_from_changelog(message):
    if not message:
        return None
    match = re.search("^\s*" + config_urls.bug_url_short + "$", message, re.MULTILINE)
    if match:
        return int(match.group('bug_id'))
    match = re.search("^\s*" + config_urls.bug_url_long + "$", message, re.MULTILINE)
    if match:
        return int(match.group('bug_id'))
    # We weren't able to find a bug URL in the format used by prepare-ChangeLog. Fall back to the
    # first bug URL found anywhere in the message.
    return config_urls.parse_bug_id(message)
Exemple #9
0
    def _fetch_list_of_patches_to_process(self, options, args, tool):
        all_patches = []
        for url in args:
            bug_id = urls.parse_bug_id(url)
            if bug_id:
                patches = tool.bugs.fetch_bug(bug_id).patches()
                _log.info("%s found on bug %s." % (pluralize("patch", len(patches)), bug_id))
                all_patches += patches

            attachment_id = urls.parse_attachment_id(url)
            if attachment_id:
                all_patches += tool.bugs.fetch_attachment(attachment_id)

        return all_patches
Exemple #10
0
    def _fetch_list_of_patches_to_process(self, options, args, tool):
        all_patches = []
        for url in args:
            bug_id = urls.parse_bug_id(url)
            if bug_id:
                patches = tool.bugs.fetch_bug(bug_id).patches()
                _log.info("%s found on bug %s." % (pluralize("patch", len(patches)), bug_id))
                all_patches += patches

            attachment_id = urls.parse_attachment_id(url)
            if attachment_id:
                all_patches += tool.bugs.fetch_attachment(attachment_id)

        return all_patches
Exemple #11
0
    def test_parse_bug_id(self):
        # FIXME: These would be all better as doctests
        self.assertEqual(12345, parse_bug_id("http://webkit.org/b/12345"))
        self.assertEqual(
            12345, parse_bug_id("foo\n\nhttps://webkit.org/b/12345\nbar\n\n"))
        self.assertEqual(
            12345,
            parse_bug_id("https://bugs.webkit.org/show_bug.cgi?id=12345"))
        self.assertEqual(
            12345,
            parse_bug_id(
                "https://bugs.webkit.org/show_bug.cgi?id=12345&ctype=xml"))
        self.assertEqual(
            12345,
            parse_bug_id(
                "https://bugs.webkit.org/show_bug.cgi?id=12345&ctype=xml&excludefield=attachmentdata"
            ))
        self.assertEqual(
            12345,
            parse_bug_id(
                "https://bugs.webkit.org/show_bug.cgi?id=12345excludefield=attachmentdata&ctype=xml"
            ))

        # Our url parser is super-fragile, but at least we're testing it.
        self.assertIsNone(parse_bug_id("http://www.webkit.org/b/12345"))
        self.assertIsNone(
            parse_bug_id(
                "https://bugs.webkit.org/show_bug.cgi?ctype=xml&id=12345"))
        self.assertIsNone(
            parse_bug_id(
                "https://bugs.webkit.org/show_bug.cgi?ctype=xml&id=12345&excludefield=attachmentdata"
            ))
        self.assertIsNone(
            parse_bug_id(
                "https://bugs.webkit.org/show_bug.cgi?ctype=xml&excludefield=attachmentdata&id=12345"
            ))
        self.assertIsNone(
            parse_bug_id(
                "https://bugs.webkit.org/show_bug.cgi?excludefield=attachmentdata&ctype=xml&id=12345"
            ))
        self.assertIsNone(
            parse_bug_id(
                "https://bugs.webkit.org/show_bug.cgi?excludefield=attachmentdata&id=12345&ctype=xml"
            ))
 def test_parse_bug_id(self):
     # Test that we can parse the urls we produce.
     bugs = Bugzilla()
     self.assertEqual(12345, urls.parse_bug_id(bugs.short_bug_url_for_bug_id(12345)))
     self.assertEqual(12345, urls.parse_bug_id(bugs.bug_url_for_bug_id(12345)))
     self.assertEqual(12345, urls.parse_bug_id(bugs.bug_url_for_bug_id(12345, xml=True)))
Exemple #13
0
def _post_error_and_check_for_bug_url(tool, nicks_string, exception):
    tool.irc().post("%s" % exception)
    bug_id = urls.parse_bug_id(exception.output)
    if bug_id:
        bug_url = tool.bugs.bug_url_for_bug_id(bug_id)
        tool.irc().post("%s: Ugg...  Might have created %s" % (nicks_string, bug_url))