mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Provide pull request link when syncing web-platform-tests with upstream.
This commit is contained in:
parent
b6bc49225e
commit
4a0e24b56f
2 changed files with 43 additions and 12 deletions
|
@ -2,7 +2,10 @@
|
|||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
from distutils.spawn import find_executable
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
|
||||
from wptrunner import update as wptupdate
|
||||
|
@ -57,7 +60,7 @@ class GitTree(wptupdate.tree.GitTree):
|
|||
:base_param commit: Commit object for the base commit from which to log
|
||||
:param path: Path that the commits must touch
|
||||
"""
|
||||
args = ["--pretty=format:%H", "--reverse", "-z"]
|
||||
args = ["--pretty=format:%H", "--reverse", "-z", "--no-merges"]
|
||||
if base_commit is not None:
|
||||
args.append("%s.." % base_commit.sha1)
|
||||
if path is not None:
|
||||
|
@ -115,9 +118,10 @@ class GitTree(wptupdate.tree.GitTree):
|
|||
return get_unique_name(branches, prefix)
|
||||
|
||||
class Patch(object):
|
||||
def __init__(self, author, email, message, diff):
|
||||
def __init__(self, author, email, message, merge_message, diff):
|
||||
self.author = author
|
||||
self.email = email
|
||||
self.merge_message = merge_message
|
||||
if isinstance(message, CommitMessage):
|
||||
self.message = message
|
||||
else:
|
||||
|
@ -147,6 +151,7 @@ class GeckoCommitMessage(CommitMessage):
|
|||
|
||||
_bug_re = re.compile("^Bug (\d+)[^\w]*(?:Part \d+[^\w]*)?(.*?)\s*(?:r=(\w*))?$",
|
||||
re.IGNORECASE)
|
||||
_merge_re = re.compile("^Auto merge of #(\d+) - [^:]+:[^,]+, r=(.+)$", re.IGNORECASE)
|
||||
|
||||
_backout_re = re.compile("^(?:Back(?:ing|ed)\s+out)|Backout|(?:Revert|(?:ed|ing))",
|
||||
re.IGNORECASE)
|
||||
|
@ -160,6 +165,11 @@ class GeckoCommitMessage(CommitMessage):
|
|||
else:
|
||||
self.backouts = []
|
||||
|
||||
m = self._merge_re.match(self.full_summary)
|
||||
if m is not None:
|
||||
self.bug, self.reviewer = m.groups()
|
||||
self.summary = self.full_summary
|
||||
else:
|
||||
m = self._bug_re.match(self.full_summary)
|
||||
if m is not None:
|
||||
self.bug, self.summary, self.reviewer = m.groups()
|
||||
|
@ -170,6 +180,20 @@ class GeckoCommitMessage(CommitMessage):
|
|||
class GeckoCommit(Commit):
|
||||
msg_cls = GeckoCommitMessage
|
||||
|
||||
def __init__(self, tree, sha1, is_merge=False):
|
||||
Commit.__init__(self, tree, sha1)
|
||||
if not is_merge:
|
||||
args = ["-c", sha1]
|
||||
try:
|
||||
merge_rev = self.git("when-merged", *args).strip()
|
||||
except subprocess.CalledProcessError as exn:
|
||||
if not find_executable('git-when-merged'):
|
||||
print('Please add the `when-merged` git command to your PATH ' +
|
||||
'(https://github.com/mhagger/git-when-merged/).')
|
||||
sys.exit(1)
|
||||
raise exn
|
||||
self.merge = GeckoCommit(tree, merge_rev, True)
|
||||
|
||||
def export_patch(self, path=None):
|
||||
"""Convert a commit in the tree to a Patch with the bug number and
|
||||
reviewer stripped from the message"""
|
||||
|
@ -180,5 +204,6 @@ class GeckoCommit(Commit):
|
|||
|
||||
diff = self.git("show", *args)
|
||||
|
||||
return Patch(self.author, self.email, self.message, diff)
|
||||
merge_message = self.merge.message if self.merge else None
|
||||
return Patch(self.author, self.email, self.message, merge_message, diff)
|
||||
|
||||
|
|
|
@ -39,15 +39,19 @@ def rewrite_patch(patch, strip_dir):
|
|||
|
||||
assert new_diff != patch
|
||||
|
||||
return Patch(patch.author, patch.email, rewrite_message(patch), new_diff)
|
||||
return Patch(patch.author, patch.email, rewrite_message(patch), None, new_diff)
|
||||
|
||||
def rewrite_message(patch):
|
||||
if patch.message.bug is not None:
|
||||
if patch.merge_message and patch.merge_message.bug:
|
||||
bug = patch.merge_message.bug
|
||||
else:
|
||||
bug = patch.message.bug
|
||||
if bug is not None:
|
||||
return "\n".join([patch.message.summary,
|
||||
patch.message.body,
|
||||
"",
|
||||
"Upstreamed from https://bugzilla.mozilla.org/show_bug.cgi?id=%s [ci skip]" %
|
||||
patch.message.bug])
|
||||
"Upstreamed from https://github.com/servo/servo/pull/%s [ci skip]" %
|
||||
bug])
|
||||
|
||||
return "\n".join([patch.message.full_summary, "%s\n[ci skip]\n" % patch.message.body])
|
||||
|
||||
|
@ -141,7 +145,7 @@ class LoadCommits(Step):
|
|||
state.source_commits = state.local_tree.log(state.last_sync_commit,
|
||||
state.tests_path)
|
||||
|
||||
update_regexp = re.compile("Bug \d+ - Update web-platform-tests to revision [0-9a-f]{40}")
|
||||
update_regexp = re.compile("Update web-platform-tests to revision [0-9a-f]{40}")
|
||||
|
||||
for i, commit in enumerate(state.source_commits[:]):
|
||||
if update_regexp.match(commit.message.text):
|
||||
|
@ -153,7 +157,7 @@ class LoadCommits(Step):
|
|||
#TODO: Add support for collapsing backouts
|
||||
raise NotImplementedError("Need to get the Git->Hg commits for backouts and remove the backed out patch")
|
||||
|
||||
if not commit.message.bug:
|
||||
if not commit.message.bug and not (commit.merge and commit.merge.message.bug):
|
||||
self.logger.error("Commit %i (%s) doesn't have an associated bug number." %
|
||||
(i + 1, commit.sha1))
|
||||
return exit_unclean
|
||||
|
@ -176,6 +180,8 @@ class SelectCommits(Step):
|
|||
remove_idx = set()
|
||||
invalid = False
|
||||
for item in remove.split(" "):
|
||||
if not item:
|
||||
continue
|
||||
try:
|
||||
item = int(item)
|
||||
except:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue