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 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 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 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 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 bug_id(self): return parse_bug_id_from_changelog(self._contents)
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.