summaryrefslogtreecommitdiffstats
path: root/subcmds/sync.py
diff options
context:
space:
mode:
authorRaman Tenneti <rtenneti@google.com>2021-02-07 16:30:27 -0800
committerRaman Tenneti <rtenneti@google.com>2021-02-08 17:34:55 +0000
commit8d43dea6ea4b7d1664632e555e207f617e54657b (patch)
tree5632d2a6e5d6e8ccff305e84734665f2f1b4fb04 /subcmds/sync.py
parent1fd7bc24386dbba3a9454bb49c702a642f00e34c (diff)
downloadgit-repo-8d43dea6ea4b7d1664632e555e207f617e54657b.tar.gz
sync: pass --bare option when doing git clone of superproject.v2.12.1
Changed "git pull" to "git fetch" as we are using --bare option. Used the following command to fetch: git fetch origin +refs/heads/*:refs/heads/* --prune Pass --branch argument to Superproject's UpdateProjectsRevisionId function. Returned False/None when directories don't exist instead of raise GitError exception from _Fetch and _LsTree functions. The caller of Fetch does Clone if Fetch fails. Tested the code with the following commands. $ ./run_tests -v Tested the init and sync code by copying all the repo changes into my Android AOSP checkout and running repo sync with --use-superproject option. Bug: https://crbug.com/gerrit/13709 Bug: https://crbug.com/gerrit/13707 Tested-by: Raman Tenneti <rtenneti@google.com> Change-Id: I3e441ecdfc87c735f46eff0eb98efa63cc2eb22a Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/296222 Reviewed-by: Mike Frysinger <vapier@google.com>
Diffstat (limited to 'subcmds/sync.py')
-rw-r--r--subcmds/sync.py19
1 files changed, 13 insertions, 6 deletions
diff --git a/subcmds/sync.py b/subcmds/sync.py
index c0f605a8..5855af55 100644
--- a/subcmds/sync.py
+++ b/subcmds/sync.py
@@ -271,6 +271,15 @@ later is required to fix a server side protocol bug.
271 dest='repo_upgraded', action='store_true', 271 dest='repo_upgraded', action='store_true',
272 help=SUPPRESS_HELP) 272 help=SUPPRESS_HELP)
273 273
274 def _GetBranch(self):
275 """Returns the branch name for getting the approved manifest."""
276 p = self.manifest.manifestProject
277 b = p.GetBranch(p.CurrentBranch)
278 branch = b.merge
279 if branch.startswith(R_HEADS):
280 branch = branch[len(R_HEADS):]
281 return branch
282
274 def _UpdateProjectsRevisionId(self, opt, args): 283 def _UpdateProjectsRevisionId(self, opt, args):
275 """Update revisionId of every project with the SHA from superproject. 284 """Update revisionId of every project with the SHA from superproject.
276 285
@@ -302,9 +311,11 @@ later is required to fix a server side protocol bug.
302 all_projects = self.GetProjects(args, 311 all_projects = self.GetProjects(args,
303 missing_ok=True, 312 missing_ok=True,
304 submodules_ok=opt.fetch_submodules) 313 submodules_ok=opt.fetch_submodules)
314 branch = self._GetBranch()
305 manifest_path = superproject.UpdateProjectsRevisionId(self.manifest, 315 manifest_path = superproject.UpdateProjectsRevisionId(self.manifest,
306 all_projects, 316 all_projects,
307 url=superproject_url) 317 url=superproject_url,
318 branch=branch)
308 if not manifest_path: 319 if not manifest_path:
309 print('error: Update of revsionId from superproject has failed', 320 print('error: Update of revsionId from superproject has failed',
310 file=sys.stderr) 321 file=sys.stderr)
@@ -753,11 +764,7 @@ later is required to fix a server side protocol bug.
753 try: 764 try:
754 server = xmlrpc.client.Server(manifest_server, transport=transport) 765 server = xmlrpc.client.Server(manifest_server, transport=transport)
755 if opt.smart_sync: 766 if opt.smart_sync:
756 p = self.manifest.manifestProject 767 branch = self._GetBranch()
757 b = p.GetBranch(p.CurrentBranch)
758 branch = b.merge
759 if branch.startswith(R_HEADS):
760 branch = branch[len(R_HEADS):]
761 768
762 if 'SYNC_TARGET' in os.environ: 769 if 'SYNC_TARGET' in os.environ:
763 target = os.environ['SYNC_TARGET'] 770 target = os.environ['SYNC_TARGET']