bisect-kit: switch source version while maintaining project list
After bisectors migrated to use codechange module, they can enumerate
changes with add/del repos. This CL adds support of source code version
switching.
BUG=chromium:827092
TEST=test following cases:
(unrelated command line options are skipped)
- repo case 1
./bisect_cros_repo.py init --old R67-10502.0.0 --new R67-10503.0.0
./switch_cros_localbuild.py R67-10502.0.0~R67-10503.0.0/46
- repo case 2
./bisect_cros_repo.py init --old R70-10907.0.0 --new R70-10908.0.0
./switch_cros_localbuild.py R70-10907.0.0~R70-10908.0.0/68
- gclient
./bisect_cros_localbuild_internal.py init --old 70.0.3509.0 --new 70.0.3510.0
Change-Id: I416baf916fcdf7e7a80dbbde562469d290e5b2b4
Reviewed-on: https://chromium-review.googlesource.com/1218248
Commit-Ready: Kuang-che Wu <kcwu@chromium.org>
Tested-by: Kuang-che Wu <kcwu@chromium.org>
Reviewed-by: Chung-yih Wang <cywang@chromium.org>
diff --git a/bisect_kit/git_util.py b/bisect_kit/git_util.py
index bb28131..06464d7 100644
--- a/bisect_kit/git_util.py
+++ b/bisect_kit/git_util.py
@@ -50,6 +50,15 @@
return os.path.exists(os.path.join(path, '.git'))
+def clone(git_repo, repo_url, reference=None):
+ if not os.path.exists(git_repo):
+ os.makedirs(git_repo)
+ cmd = ['git', 'clone', repo_url, '.']
+ if reference:
+ cmd += ['--reference', reference]
+ util.check_call(*cmd, cwd=git_repo)
+
+
def checkout_version(git_repo, rev):
"""git checkout.