cros_util: fix up naming
Since these two scripts are tracking upstream Chrome OS repos,
fixing naming is a bit harder. This patch creates a variable to
hold the name of the main branch, so it's easier to fix these
files in case any future name fixing on upstream.
Also run `yapf` during presubmit.
BUG=chromium:1099035
TEST=None
Change-Id: Ic72a213dadf12b382a76fe50d48cde6fcecc3b25
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/2270728
Reviewed-by: Caroline Tice <cmtice@chromium.org>
Commit-Queue: Tiancong Wang <tcwang@google.com>
Tested-by: Tiancong Wang <tcwang@google.com>
diff --git a/cros_utils/manifest_versions.py b/cros_utils/manifest_versions.py
index 115c604..4838de3 100644
--- a/cros_utils/manifest_versions.py
+++ b/cros_utils/manifest_versions.py
@@ -19,6 +19,8 @@
from cros_utils import command_executer
from cros_utils import logger
+MANIFEST_VERSION_MAIN_BRANCH = 'master'
+
def IsCrosVersion(version):
match = re.search(r'(\d+\.\d+\.\d+\.\d+)', version)
@@ -72,7 +74,8 @@
commands = [
'cd {0}'.format(self.clone_location), 'cd manifest-versions',
'git checkout -f $(git rev-list' +
- ' --max-count=1 --before={0} origin/master)'.format(my_time)
+ ' --max-count=1 --before={0} origin/{1})'.format(
+ my_time, MANIFEST_VERSION_MAIN_BRANCH)
]
ret = self.ce.RunCommands(commands)
if ret:
@@ -106,7 +109,7 @@
version = pp[-2] + '.' + small
commands = [
'cd {0}'.format(self.clone_location), 'cd manifest-versions',
- 'git checkout master'
+ 'git checkout {0}'.format(MANIFEST_VERSION_MAIN_BRANCH)
]
self.ce.RunCommands(commands)
return version
@@ -120,7 +123,8 @@
commands = [
'cd {0}'.format(self.clone_location), 'cd manifest-versions',
'git checkout -f $(git rev-list' +
- ' --max-count=1 --before={0} origin/master)'.format(my_time)
+ ' --max-count=1 --before={0} origin/{1})'.format(
+ my_time, MANIFEST_VERSION_MAIN_BRANCH)
]
ret = self.ce.RunCommands(commands)
if ret:
@@ -133,7 +137,7 @@
version = pp[-2] + '.' + small
commands = [
'cd {0}'.format(self.clone_location), 'cd manifest-versions',
- 'git checkout master'
+ 'git checkout {0}'.format(MANIFEST_VERSION_MAIN_BRANCH)
]
self.ce.RunCommands(commands)
return version
diff --git a/cros_utils/misc.py b/cros_utils/misc.py
index b4beb60..d8b47d1 100644
--- a/cros_utils/misc.py
+++ b/cros_utils/misc.py
@@ -24,6 +24,8 @@
TOOLCHAIN_UTILS_PATH = ('/mnt/host/source/src/third_party/toolchain-utils/'
'cros_utils/toolchain_utils.sh')
+CROS_MAIN_BRANCH = 'cros/master'
+
def GetChromeOSVersionFromLSBVersion(lsb_version):
"""Get Chromeos version from Lsb version."""
@@ -444,8 +446,9 @@
cmd1, print_to_console=True) == 0
-def ApplyGerritPatches(chromeos_root, gerrit_patch_string,
- branch='cros/master'):
+def ApplyGerritPatches(chromeos_root,
+ gerrit_patch_string,
+ branch=CROS_MAIN_BRANCH):
"""Apply gerrit patches on a chromeos tree.
Args: