mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2025-02-10 12:09:31 +00:00
tools/cl: Identify cl's by Change-Id
Otherwise we won't be able to find the corresponding gerrit change if the commit has been ammended. BUG=b:239840337 TEST=./tools/cl status Change-Id: I5a9673414145a0dcc0547c1de6422992478a3094 Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3885076 Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Tested-by: Dennis Kempin <denniskempin@google.com> Commit-Queue: Dennis Kempin <denniskempin@google.com>
This commit is contained in:
parent
644251cec0
commit
a91002bb46
1 changed files with 21 additions and 4 deletions
25
tools/cl
25
tools/cl
|
@ -4,10 +4,12 @@
|
||||||
# found in the LICENSE file.
|
# found in the LICENSE file.
|
||||||
|
|
||||||
import functools
|
import functools
|
||||||
|
import re
|
||||||
|
import sys
|
||||||
from os import chdir
|
from os import chdir
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from impl.common import CROSVM_ROOT, GerritChange, confirm, run_commands, cmd
|
|
||||||
import sys
|
from impl.common import CROSVM_ROOT, GerritChange, cmd, confirm, run_commands
|
||||||
|
|
||||||
USAGE = """\
|
USAGE = """\
|
||||||
./tools/cl [upload|rebase|status|prune]
|
./tools/cl [upload|rebase|status|prune]
|
||||||
|
@ -65,9 +67,19 @@ class LocalChange(object):
|
||||||
sha_title = line.split(" ", 1)
|
sha_title = line.split(" ", 1)
|
||||||
yield cls(sha_title[0], sha_title[1])
|
yield cls(sha_title[0], sha_title[1])
|
||||||
|
|
||||||
|
@functools.cached_property
|
||||||
|
def change_id(self):
|
||||||
|
msg = git("log -1 --format=email", self.sha).stdout()
|
||||||
|
match = re.search("^Change-Id: (I[a-f0-9]+)", msg, re.MULTILINE)
|
||||||
|
if not match:
|
||||||
|
return None
|
||||||
|
return match.group(1)
|
||||||
|
|
||||||
@functools.cached_property
|
@functools.cached_property
|
||||||
def gerrit(self):
|
def gerrit(self):
|
||||||
results = GerritChange.query("project:crosvm/crosvm", self.sha)
|
if not self.change_id:
|
||||||
|
return None
|
||||||
|
results = GerritChange.query("project:crosvm/crosvm", self.change_id)
|
||||||
if len(results) > 1:
|
if len(results) > 1:
|
||||||
raise Exception(f"Multiple gerrit changes found for commit {self.sha}: {self.title}.")
|
raise Exception(f"Multiple gerrit changes found for commit {self.sha}: {self.title}.")
|
||||||
return results[0] if results else None
|
return results[0] if results else None
|
||||||
|
@ -127,7 +139,12 @@ def prerequisites():
|
||||||
|
|
||||||
|
|
||||||
def print_branch_summary(branch: str):
|
def print_branch_summary(branch: str):
|
||||||
print("Branch", branch, "tracking", get_upstream(branch))
|
upstream = get_upstream(branch)
|
||||||
|
if not upstream:
|
||||||
|
print("Branch", branch, "is not tracking an upstream branch")
|
||||||
|
print()
|
||||||
|
return
|
||||||
|
print("Branch", branch, "tracking", upstream)
|
||||||
changes = [*LocalChange.list_changes(branch)]
|
changes = [*LocalChange.list_changes(branch)]
|
||||||
for change in changes:
|
for change in changes:
|
||||||
if change.gerrit:
|
if change.gerrit:
|
||||||
|
|
Loading…
Reference in a new issue