diff options
| author | Raman Tenneti <rtenneti@google.com> | 2021-06-11 17:29:45 -0700 |
|---|---|---|
| committer | Raman Tenneti <rtenneti@google.com> | 2021-06-16 04:48:35 +0000 |
| commit | 784e16f3aa941ca3564d823cc686017a161621a1 (patch) | |
| tree | 611fe2add0b6638330ea7b34fa1f70d05c0d895e /command.py | |
| parent | b8c84483a55b575277ab791c6834a8682d47f1af (diff) | |
| download | git-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 'command.py')
| -rw-r--r-- | command.py | 5 |
1 files changed, 3 insertions, 2 deletions
| @@ -15,7 +15,6 @@ | |||
| 15 | import multiprocessing | 15 | import multiprocessing |
| 16 | import os | 16 | import os |
| 17 | import optparse | 17 | import optparse |
| 18 | import platform | ||
| 19 | import re | 18 | import re |
| 20 | import sys | 19 | import sys |
| 21 | 20 | ||
| @@ -58,11 +57,13 @@ class Command(object): | |||
| 58 | # it is the number of parallel jobs to default to. | 57 | # it is the number of parallel jobs to default to. |
| 59 | PARALLEL_JOBS = None | 58 | PARALLEL_JOBS = None |
| 60 | 59 | ||
| 61 | def __init__(self, repodir=None, client=None, manifest=None, gitc_manifest=None): | 60 | def __init__(self, repodir=None, client=None, manifest=None, gitc_manifest=None, |
| 61 | git_event_log=None): | ||
| 62 | self.repodir = repodir | 62 | self.repodir = repodir |
| 63 | self.client = client | 63 | self.client = client |
| 64 | self.manifest = manifest | 64 | self.manifest = manifest |
| 65 | self.gitc_manifest = gitc_manifest | 65 | self.gitc_manifest = gitc_manifest |
| 66 | self.git_event_log = git_event_log | ||
| 66 | 67 | ||
| 67 | # Cache for the OptionParser property. | 68 | # Cache for the OptionParser property. |
| 68 | self._optparse = None | 69 | self._optparse = None |
