summaryrefslogtreecommitdiffstats
path: root/subcmds
diff options
context:
space:
mode:
authorRaman Tenneti <rtenneti@google.com>2021-06-11 17:29:45 -0700
committerRaman Tenneti <rtenneti@google.com>2021-06-16 04:48:35 +0000
commit784e16f3aa941ca3564d823cc686017a161621a1 (patch)
tree611fe2add0b6638330ea7b34fa1f70d05c0d895e /subcmds
parentb8c84483a55b575277ab791c6834a8682d47f1af (diff)
downloadgit-repo-784e16f3aa941ca3564d823cc686017a161621a1.tar.gz
superproject: Don't exit if superproject tag doesn't exist in manifest.v2.16
Don't exit if there are missing commit ids in superproject. This change implements the following suggestion from delphij@: "we should note the event (so we know that --use-superproject but there were some errors, e.g. manifest didn't specify commit id for some reason, or if there is no superproject but --use-superproject is used), print out a message telling the use that this is not support, but continue as if --no-use-superproject was specified?" Changes: superproject: + Added git_trace2_event_log as an argument to the constructor. + Sync method returns SyncResult a NamedTuple of ++ success - True if sync of superproject is successful, or False. ++ fatal - True if caller should exit, Or False. + UpdateProjectsRevisionId returns UpdateProjectsResult a NamedTuple of ++ manifest_path - path name of the overriding manifest file instead of None ++ fatal - True if caller should exit, Or False + _GetAllProjectsCommitIds returns CommitIdsResult a NamedTuple of ++ commit_ids - a dictionary with the projects/commit ids on success, otherwise None ++ fatal - True if caller should exit, Or False + Added _SkipUpdatingProjectRevisionId a helper function to see if a project's revision id needs to be updated or not. This function is used to exclude projects from local manifest file. + Added the following error events into git_trace2_event_log ++ If superproject is missing in a manifest ++ If there are missing commit ids for projects. command.py: + Deleted unused import - platform + Added git_trace2_event_log as a member so all subcmds can log error events. main.py: + Initialized git_trace2_event_log as a member of command object. init.py: + Deleted unused import - optparse init.py: + Called sys.exit only if Sync returns exit=True sync.py: + Called sys.exit only if Superproject's UpdateProjectsRevisionId returns exit=True + Reloaded the manifest only if manifest path is returned by UpdateProjectsRevisionId. If not, fall back to the old way of doing repo sync. test_git_superproject: + Added code to verify error events are being logged. + Added a test for no superproject tag + Added test for UpdateProjectsRevisionId not updating the revision id with the commit ids. Tested the code with the following commands. + Positive test case with aosp-master. $ repo_dev init -u persistent-https://android.git.corp.google.com/platform/manifest -b master --use-superproject NOTICE: --use-superproject is in beta; report any issues to the address described in `repo version` .../android/aosp/.repo/exp-superproject/925043f706ba64db713e9bf3b55987e2-superproject.git: Initial setup for superproject completed. Your identity is: Raman Tenneti <rtenneti@google.com> If you want to change this, please re-run 'repo init' with --config-name repo has been initialized in .../android/aosp $ repo_dev sync -j40 --use-superproject remote: Total 12 (delta 4), reused 12 (delta 4) NOTICE: --use-superproject is in beta; report any issues to the address described in `repo version` .../android/aosp/.repo/exp-superproject/925043f706ba64db713e9bf3b55987e2-superproject.git: Initial setup for superproject completed. ... repo sync has finished successfully. + Negative test case without superproject tag. $ repo_dev sync -j40 --use-superproject NOTICE: --use-superproject is in beta; report any issues to the address described in `repo version` repo error: superproject tag is not defined in manifest: .../android/aosp/.repo/manifest.xml error: Cannot get project commit ids from manifest error: Update of revsionId from superproject has failed. Please resync with --no-use-superproject option ... Checking out: 100% (1022/1022), done in 3.589s repo sync has finished successfully. + Test for missing commit_id for a project. $ repo_dev sync -j40 --use-superproject NOTICE: --use-superproject is in beta; report any issues to the address described in `repo version` .../android/aosp/.repo/exp-superproject/925043f706ba64db713e9bf3b55987e2-superproject.git: Initial setup for superproject completed. error: please file a bug using go/repo-bug to report missing commit_ids for: ['build/blueprint'] error: Update of revsionId from superproject has failed. Please resync with --no-use-superproject option ... Checking out: 100% (1022/1022), done in 3.364s repo sync has finished successfully. $ ./run_tests -v ... ...== 164 passed in 2.87s ==... Bug: [google internal] b/189371541 Change-Id: I5ea49f87e8fa41be590fc0c914573e16c8cdfcfa Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/309162 Tested-by: Raman Tenneti <rtenneti@google.com> Reviewed-by: Mike Frysinger <vapier@google.com>
Diffstat (limited to 'subcmds')
-rw-r--r--subcmds/init.py8
-rw-r--r--subcmds/sync.py18
2 files changed, 17 insertions, 9 deletions
diff --git a/subcmds/init.py b/subcmds/init.py
index 750facba..536e367c 100644
--- a/subcmds/init.py
+++ b/subcmds/init.py
@@ -12,7 +12,6 @@
12# See the License for the specific language governing permissions and 12# See the License for the specific language governing permissions and
13# limitations under the License. 13# limitations under the License.
14 14
15import optparse
16import os 15import os
17import platform 16import platform
18import re 17import re
@@ -97,10 +96,13 @@ to update the working directory files.
97 """ 96 """
98 superproject = git_superproject.Superproject(self.manifest, 97 superproject = git_superproject.Superproject(self.manifest,
99 self.repodir, 98 self.repodir,
99 self.git_event_log,
100 quiet=opt.quiet) 100 quiet=opt.quiet)
101 if not superproject.Sync(): 101 sync_result = superproject.Sync()
102 if not sync_result.success:
102 print('error: git update of superproject failed', file=sys.stderr) 103 print('error: git update of superproject failed', file=sys.stderr)
103 sys.exit(1) 104 if sync_result.fatal:
105 sys.exit(1)
104 106
105 def _SyncManifest(self, opt): 107 def _SyncManifest(self, opt):
106 m = self.manifest.manifestProject 108 m = self.manifest.manifestProject
diff --git a/subcmds/sync.py b/subcmds/sync.py
index b15d9477..8d89cf72 100644
--- a/subcmds/sync.py
+++ b/subcmds/sync.py
@@ -302,21 +302,25 @@ later is required to fix a server side protocol bug.
302 load_local_manifests: Whether to load local manifests. 302 load_local_manifests: Whether to load local manifests.
303 303
304 Returns: 304 Returns:
305 Returns path to the overriding manifest file. 305 Returns path to the overriding manifest file instead of None.
306 """ 306 """
307 superproject = git_superproject.Superproject(self.manifest, 307 superproject = git_superproject.Superproject(self.manifest,
308 self.repodir, 308 self.repodir,
309 self.git_event_log,
309 quiet=opt.quiet) 310 quiet=opt.quiet)
310 all_projects = self.GetProjects(args, 311 all_projects = self.GetProjects(args,
311 missing_ok=True, 312 missing_ok=True,
312 submodules_ok=opt.fetch_submodules) 313 submodules_ok=opt.fetch_submodules)
313 manifest_path = superproject.UpdateProjectsRevisionId(all_projects) 314 update_result = superproject.UpdateProjectsRevisionId(all_projects)
314 if not manifest_path: 315 manifest_path = update_result.manifest_path
316 if manifest_path:
317 self._ReloadManifest(manifest_path, load_local_manifests)
318 else:
315 print('error: Update of revsionId from superproject has failed. ' 319 print('error: Update of revsionId from superproject has failed. '
316 'Please resync with --no-use-superproject option', 320 'Please resync with --no-use-superproject option',
317 file=sys.stderr) 321 file=sys.stderr)
318 sys.exit(1) 322 if update_result.fatal:
319 self._ReloadManifest(manifest_path, load_local_manifests) 323 sys.exit(1)
320 return manifest_path 324 return manifest_path
321 325
322 def _FetchProjectList(self, opt, projects): 326 def _FetchProjectList(self, opt, projects):
@@ -961,7 +965,9 @@ later is required to fix a server side protocol bug.
961 965
962 load_local_manifests = not self.manifest.HasLocalManifests 966 load_local_manifests = not self.manifest.HasLocalManifests
963 if self._UseSuperproject(opt): 967 if self._UseSuperproject(opt):
964 manifest_name = self._UpdateProjectsRevisionId(opt, args, load_local_manifests) 968 new_manifest_name = self._UpdateProjectsRevisionId(opt, args, load_local_manifests)
969 if not new_manifest_name:
970 manifest_name = new_manifest_name
965 971
966 if self.gitc_manifest: 972 if self.gitc_manifest:
967 gitc_manifest_projects = self.GetProjects(args, 973 gitc_manifest_projects = self.GetProjects(args,