def execute(self, options, args, tool): commit_ids = tool.scm().commit_ids_from_commitish_arguments(args) if len( commit_ids ) > 10: # We could lower this limit, 10 is too many for one bug as-is. _log.error( "webkit-patch does not support attaching %s at once. Are you sure you passed the right commit range?" % (string_utils.pluralize( len(commit_ids), 'patch', plural='patches'))) sys.exit(1) have_obsoleted_patches = set() for commit_id in commit_ids: commit_message = tool.scm().commit_message_for_local_commit( commit_id) # Prefer --bug-id=, then a bug url in the commit message, then a bug url in the entire commit diff (i.e. ChangeLogs). bug_id = options.bug_id or parse_bug_id_from_changelog( commit_message.message()) or parse_bug_id_from_changelog( tool.scm().create_patch(git_commit=commit_id)) if not bug_id: _log.info( "Skipping %s: No bug id found in commit or specified with --bug-id." % commit_id) continue if options.obsolete_patches and bug_id not in have_obsoleted_patches: state = {"bug_id": bug_id} steps.ObsoletePatches(tool, options).run(state) have_obsoleted_patches.add(bug_id) diff = tool.scm().create_patch(git_commit=commit_id) description = options.description or commit_message.description( lstrip=True, strip_url=True) comment_text = self._comment_text_for_commit( options, commit_message, tool, commit_id) attachment_id = tool.bugs.add_patch_to_bug( bug_id, diff, description, comment_text, mark_for_review=options.review, mark_for_commit_queue=options.request_commit) # We only need to submit --no-review patches to EWS as patches posted for review are # automatically submitted to EWS by EWSFeeder. if not options.review and options.ews: state = {'attachment_ids': [attachment_id]} steps.SubmitToEWS(tool, options).run(state)
def bug_id_for_this_commit(self, git_commit, changed_files=None): try: return parse_bug_id_from_changelog( self.commit_message_for_this_commit(git_commit, changed_files).message()) except ScriptError as e: pass # We might not have ChangeLogs.
def execute(self, options, args, tool): commit_ids = tool.scm().commit_ids_from_commitish_arguments(args) if len(commit_ids) > 10: # We could lower this limit, 10 is too many for one bug as-is. _log.error("webkit-patch does not support attaching %s at once. Are you sure you passed the right commit range?" % (pluralize(len(commit_ids), "patch"))) sys.exit(1) have_obsoleted_patches = set() for commit_id in commit_ids: commit_message = tool.scm().commit_message_for_local_commit(commit_id) # Prefer --bug-id=, then a bug url in the commit message, then a bug url in the entire commit diff (i.e. ChangeLogs). bug_id = options.bug_id or parse_bug_id_from_changelog(commit_message.message()) or parse_bug_id_from_changelog(tool.scm().create_patch(git_commit=commit_id)) if not bug_id: _log.info("Skipping %s: No bug id found in commit or specified with --bug-id." % commit_id) continue if options.obsolete_patches and bug_id not in have_obsoleted_patches: state = { "bug_id": bug_id } steps.ObsoletePatches(tool, options).run(state) have_obsoleted_patches.add(bug_id) diff = tool.scm().create_patch(git_commit=commit_id) description = options.description or commit_message.description(lstrip=True, strip_url=True) comment_text = self._comment_text_for_commit(options, commit_message, tool, commit_id) tool.bugs.add_patch_to_bug(bug_id, diff, description, comment_text, mark_for_review=options.review, mark_for_commit_queue=options.request_commit)
def check_entry(self, first_line_checked, entry_lines): if not entry_lines: return for line in entry_lines: if parse_bug_id_from_changelog(line): break if re.search("Unreviewed", line, re.IGNORECASE): break if re.search("build", line, re.IGNORECASE) and re.search("fix", line, re.IGNORECASE): break else: self.handle_style_error(first_line_checked, "changelog/bugnumber", 5, "ChangeLog entry has no bug number") # check file change descriptions for style violations line_no = first_line_checked - 1 for line in entry_lines: line_no = line_no + 1 # filter file change descriptions if not re.match('\s*\*\s', line): continue if re.search(':\s*$', line) or re.search(':\s', line): continue self.handle_style_error(line_no, "changelog/filechangedescriptionwhitespace", 5, "Need whitespace between colon and description")
def check_entry(self, first_line_checked, entry_lines): if not entry_lines: return for line in entry_lines: if parse_bug_id_from_changelog(line): break if re.search("Unreviewed", line, re.IGNORECASE): break if re.search("build", line, re.IGNORECASE) and re.search("fix", line, re.IGNORECASE): break else: self.handle_style_error(first_line_checked, "changelog/bugnumber", 5, "ChangeLog entry has no bug number") # check file change descriptions for style violations line_no = first_line_checked - 1 for line in entry_lines: line_no = line_no + 1 # filter file change descriptions if not re.match('\s*\*\s', line): continue if re.search(':\s*$', line) or re.search(':\s', line): continue self.handle_style_error(line_no, "changelog/filechangedescriptionwhitespace", 5, "Need whitespace between colon and description") # check for a lingering "No new tests. (OOPS!)" left over from prepare-changeLog. line_no = first_line_checked - 1 for line in entry_lines: line_no = line_no + 1 if re.match('\s*No new tests. \(OOPS!\)$', line): self.handle_style_error(line_no, "changelog/nonewtests", 5, "You should remove the 'No new tests' and either add and list tests, or explain why no new tests were possible.")
def check_entry(self, first_line_checked, entry_lines): if not entry_lines: return for line in entry_lines: if parse_bug_id_from_changelog(line): break if searchIgnorecase("Unreviewed", line): break if searchIgnorecase("build", line) and searchIgnorecase("fix", line): break else: self.handle_style_error(first_line_checked, "changelog/bugnumber", 5, "ChangeLog entry has no bug number") # check file change descriptions for style violations line_no = first_line_checked - 1 for line in entry_lines: line_no = line_no + 1 # filter file change descriptions if not match('\s*\*\s', line): continue if search(':\s*$', line) or search(':\s', line): continue self.handle_style_error(line_no, "changelog/filechangedescriptionwhitespace", 5, "Need whitespace between colon and description") # check for a lingering "No new tests. (OOPS!)" left over from prepare-changeLog. line_no = first_line_checked - 1 for line in entry_lines: line_no = line_no + 1 if match('\s*No new tests. \(OOPS!\)$', line): self.handle_style_error(line_no, "changelog/nonewtests", 5, "You should remove the 'No new tests' and either add and list tests, or explain why no new tests were possible.")
def check_entry(self, first_line_checked, entry_lines): if not entry_lines: return for line in entry_lines: if parse_bug_id_from_changelog(line): break if re.search("Unreviewed", line, re.IGNORECASE): break if re.search("build", line, re.IGNORECASE) and re.search( "fix", line, re.IGNORECASE): break else: self.handle_style_error(first_line_checked, "changelog/bugnumber", 5, "ChangeLog entry has no bug number") # check file change descriptions for style violations line_no = first_line_checked - 1 for line in entry_lines: line_no = line_no + 1 # filter file change descriptions if not re.match('\s*\*\s', line): continue if re.search(':\s*$', line) or re.search(':\s', line): continue self.handle_style_error( line_no, "changelog/filechangedescriptionwhitespace", 5, "Need whitespace between colon and description")
def execute(self, options, args, tool): commit_ids = tool.scm().commit_ids_from_commitish_arguments(args) if len( commit_ids ) > 10: # We could lower this limit, 10 is too many for one bug as-is. error( "webkit-patch does not support attaching %s at once. Are you sure you passed the right commit range?" % (pluralize("patch", len(commit_ids)))) have_obsoleted_patches = set() for commit_id in commit_ids: commit_message = tool.scm().commit_message_for_local_commit( commit_id) # Prefer --bug-id=, then a bug url in the commit message, then a bug url in the entire commit diff (i.e. ChangeLogs). bug_id = options.bug_id or parse_bug_id_from_changelog( commit_message.message()) or parse_bug_id_from_changelog( tool.scm().create_patch(git_commit=commit_id)) if not bug_id: log("Skipping %s: No bug id found in commit or specified with --bug-id." % commit_id) continue if options.obsolete_patches and bug_id not in have_obsoleted_patches: state = {"bug_id": bug_id} steps.ObsoletePatches(tool, options).run(state) have_obsoleted_patches.add(bug_id) diff = tool.scm().create_patch(git_commit=commit_id) description = options.description or commit_message.description( lstrip=True, strip_url=True) comment_text = self._comment_text_for_commit( options, commit_message, tool, commit_id) tool.bugs.add_patch_to_bug( bug_id, diff, description, comment_text, mark_for_review=options.review, mark_for_commit_queue=options.request_commit)
def check_entry(self, first_line_checked, entry_lines): if not entry_lines: return for line in entry_lines: if parse_bug_id_from_changelog(line): break if re.search("Unreviewed", line, re.IGNORECASE): break if re.search("build", line, re.IGNORECASE) and re.search("fix", line, re.IGNORECASE): break else: self.handle_style_error(first_line_checked, "changelog/bugnumber", 5, "ChangeLog entry has no bug number")
def _changelog_data_for_revision(self, revision): changed_files = self._scm.changed_files_for_revision(revision) changelog_entries = self.changelog_entries_for_revision(revision, changed_files=changed_files) # Assume for now that the first entry has everything we need: # FIXME: This will throw an exception if there were no ChangeLogs. if not len(changelog_entries): return None changelog_entry = changelog_entries[0] return { "bug_id": parse_bug_id_from_changelog(changelog_entry.contents()), "author_name": changelog_entry.author_name(), "author_email": changelog_entry.author_email(), "author": changelog_entry.author(), "reviewer_text": changelog_entry.reviewer_text(), "reviewer": changelog_entry.reviewer(), "contents": changelog_entry.contents(), "changed_files": changed_files, }
def commit_info_for_revision(self, revision): committer_email = self._scm.committer_email_for_revision(revision) changelog_entries = self.changelog_entries_for_revision(revision) # Assume for now that the first entry has everything we need: # FIXME: This will throw an exception if there were no ChangeLogs. if not len(changelog_entries): return None changelog_entry = changelog_entries[0] changelog_data = { "bug_id": parse_bug_id_from_changelog(changelog_entry.contents()), "author_name": changelog_entry.author_name(), "author_email": changelog_entry.author_email(), "author": changelog_entry.author(), "reviewer_text": changelog_entry.reviewer_text(), "reviewer": changelog_entry.reviewer(), } # We could pass the changelog_entry instead of a dictionary here, but that makes # mocking slightly more involved, and would make aggregating data from multiple # entries more difficult to wire in if we need to do that in the future. return CommitInfo(revision, committer_email, changelog_data)
def _determine_bug_id_and_svn_revision(self, tool, bug_id, svn_revision): commit_log = self._fetch_commit_log(tool, svn_revision) if not bug_id: bug_id = parse_bug_id_from_changelog(commit_log) if not svn_revision: match = re.search("^r(?P<svn_revision>\d+) \|", commit_log, re.MULTILINE) if match: svn_revision = match.group('svn_revision') if not bug_id or not svn_revision: not_found = [] if not bug_id: not_found.append("bug id") if not svn_revision: not_found.append("svn revision") error("Could not find %s on command-line or in %s." % (" or ".join(not_found), "r%s" % svn_revision if svn_revision else "last commit")) return (bug_id, svn_revision)
def _determine_bug_id_and_svn_revision(self, tool, bug_id, svn_revision): commit_log = self._fetch_commit_log(tool, svn_revision) if not bug_id: bug_id = parse_bug_id_from_changelog(commit_log) if not svn_revision: match = re.search("^r(?P<svn_revision>\d+) \|", commit_log, re.MULTILINE) if match: svn_revision = match.group('svn_revision') if not bug_id or not svn_revision: not_found = [] if not bug_id: not_found.append("bug id") if not svn_revision: not_found.append("svn revision") _log.error("Could not find %s on command-line or in %s." % (" or ".join(not_found), "r%s" % svn_revision if svn_revision else "last commit")) sys.exit(1) return (bug_id, svn_revision)
def bug_id_for_this_commit(self, git_commit, changed_files=None): try: return parse_bug_id_from_changelog(self.commit_message_for_this_commit(git_commit, changed_files).message()) except ScriptError, e: pass # We might not have ChangeLogs.
def test_parse_bug_id_from_changelog(self): commit_text = ''' 2011-03-23 Ojan Vafai <*****@*****.**> Add failing result for WebKit2. All tests that require focus fail on WebKit2. See https://bugs.webkit.org/show_bug.cgi?id=56988. * platform/mac-wk2/fast/css/pseudo-any-expected.txt: Added. ''' self.assertEqual(56988, parse_bug_id_from_changelog(commit_text)) commit_text = ''' 2011-03-23 Ojan Vafai <*****@*****.**> Add failing result for WebKit2. All tests that require focus fail on WebKit2. See https://bugs.webkit.org/show_bug.cgi?id=56988. https://bugs.webkit.org/show_bug.cgi?id=12345 * platform/mac-wk2/fast/css/pseudo-any-expected.txt: Added. ''' self.assertEqual(12345, parse_bug_id_from_changelog(commit_text)) commit_text = ''' 2011-03-31 Adam Roben <*****@*****.**> Quote the executable path we pass to ::CreateProcessW This will ensure that spaces in the path will be interpreted correctly. Fixes <http://webkit.org/b/57569> Web process sometimes fails to launch when there are spaces in its path Reviewed by Steve Falkenburg. * UIProcess/Launcher/win/ProcessLauncherWin.cpp: (WebKit::ProcessLauncher::launchProcess): Surround the executable path in quotes. ''' self.assertEqual(57569, parse_bug_id_from_changelog(commit_text)) commit_text = ''' 2011-03-29 Timothy Hatcher <*****@*****.**> Update WebCore Localizable.strings to contain WebCore, WebKit/mac and WebKit2 strings. https://webkit.org/b/57354 Reviewed by Sam Weinig. * English.lproj/Localizable.strings: Updated. * StringsNotToBeLocalized.txt: Removed. To hard to maintain in WebCore. * platform/network/cf/LoaderRunLoopCF.h: Remove a single quote in an #error so extract-localizable-strings does not complain about unbalanced single quotes. ''' self.assertEqual(57354, parse_bug_id_from_changelog(commit_text))