summaryrefslogtreecommitdiffstats
path: root/tests
Commit message (Collapse)AuthorAgeFilesLines
* launcher: change RunError to subprocess.CalledProcessErrorMike Frysinger2025-04-011-1/+1
| | | | | | | | | | | Since we require Python 3.6 now in the launcher, swap out our custom RunError class for the standard subprocess one. Change-Id: Id0ca17c40e22ece03e06366a263ad340963f979d Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/464401 Commit-Queue: Mike Frysinger <vapier@google.com> Reviewed-by: Scott Lee <ddoman@google.com> Tested-by: Mike Frysinger <vapier@google.com>
* black: update to v25Mike Frysinger2025-03-251-1/+1
| | | | | | | | | | Requires a little reformatting in the tree. Change-Id: Iaa40fe0dfca372c49c04cc26edccb5f7b0c2a8ad Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/462883 Commit-Queue: Mike Frysinger <vapier@google.com> Reviewed-by: Gavin Mak <gavinmak@google.com> Tested-by: Mike Frysinger <vapier@google.com>
* run_tests: move test filtering to pytest markersMike Frysinger2025-03-252-0/+7
| | | | | | | | | | | | Move the test disable logic even closer to the exact test that's disabled. This way people updating tests have a better chance of seeing they'll get reduced coverage in the CQ. Change-Id: I57c1a073a844019798b27e14d742fd32925d9ae8 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/462882 Tested-by: Mike Frysinger <vapier@google.com> Reviewed-by: Gavin Mak <gavinmak@google.com> Commit-Queue: Mike Frysinger <vapier@google.com>
* launcher: change RunResult to subprocess.CompletedProcessMike Frysinger2025-03-241-5/+6
| | | | | | | | | | | Since we require Python 3.6 now in the launcher, swap out our custom RunResult class for the standard subprocess one. Change-Id: Idd8598df37c0a952d3ef828df6e250cab03c6589 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/462341 Reviewed-by: Gavin Mak <gavinmak@google.com> Tested-by: Mike Frysinger <vapier@google.com> Commit-Queue: Mike Frysinger <vapier@google.com>
* Add smoke test for subcmd forallFredrik de Groot2024-12-111-0/+156
| | | | | | | | | | | | | | | | | | | After some refactoring earlier, the forall command was broken briefly, returning after only one run instead of after all projects. This test, albeit simple in nature, would have caught that. Due to the somewhat demanding nature of forall, a lot more setup was needed than expected but seems to do its job now so hopefully it catches similar stuff in the future. Change-Id: I51e161ff0e7e31a65401211c376f319bda504532 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/445461 Tested-by: Fredrik de Groot <fredrik.de.groot@haleytek.com> Reviewed-by: Josip Sokcevic <sokcevic@google.com> Commit-Queue: Fredrik de Groot <fredrik.de.groot@haleytek.com>
* Remove gitc support from repoJosip Sokcevic2024-12-032-75/+1
| | | | | | | | | | gitc is no longer available. Change-Id: I0cbfdf936832f2cdd4876104ae3cc5a6e26154e2 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/444841 Reviewed-by: Gavin Mak <gavinmak@google.com> Commit-Queue: Josip Sokcevic <sokcevic@google.com> Tested-by: Josip Sokcevic <sokcevic@google.com>
* Fix event log command event hierarchy.Josip Sokcevic2024-11-221-13/+9
| | | | | | | | | | | | command should be cmd_name, to match what git is emitting. This also fixes arguments, so that only relevant arguments are passed instead of the entire sys.args, which will contain wrapper information Change-Id: Id436accfff511292ec2c56798fffb2306dda38fc Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/443741 Commit-Queue: Josip Sokcevic <sokcevic@google.com> Reviewed-by: Gavin Mak <gavinmak@google.com> Tested-by: Josip Sokcevic <sokcevic@google.com>
* manifest: add optional base check on remove and extendFredrik de Groot2024-10-281-0/+85
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds an optional, built-in checker for guarding against patches hanging on wrong base revisions, which is useful if a lower layer of the manifest changes after a patch was done. When adding a patch with a new revision using extend-project or remove-project/project: C---D---E patches in project bla / A---B project bla in manifest state 1 <extend-project name="bla" revision="E" base-rev="B"> If project bla gets updated, in a new snap ID or by a supplier or similar, to a new state: C---D---E patches in project bla / A---B---F---G project bla in manifest state 2 Parsing will fail because revision of bla is now G, giving the choice to create a new patch branch from G and updating base-rev, or keeping previous branch for some reason and only updating base-rev. Intended for use in a layered manifest with hashed revisions. Named refs like branches and tags also work fine when comparing, but will be misleading if a branch is used as base-rev. Change-Id: Ic6211550a7d3cc9656057f6a2087c505b40cad2b Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/436777 Reviewed-by: Josip Sokcevic <sokcevic@google.com> Tested-by: Fredrik de Groot <fredrik.de.groot@haleytek.com> Commit-Queue: Josip Sokcevic <sokcevic@google.com>
* sync: Always use WORKER_BATCH_SIZEv2.48Josip Sokcevic2024-10-071-0/+24
| | | | | | | | | | | | | | | | | | | With 551285fa35ccd0836513e9cf64ee8d3372e5e3f4, the comment about number of workers no longer stands - dict is shared among multiprocesses and real time information is available. Using 2.7k projects as the baseline, using chunk size of 4 takes close to 5 minutes. A chunk size of 32 takes this down to 40s - a reduction of rougly 8 times which matches the increase. R=gavinmak@google.com Bug: b/371638995 Change-Id: Ida5fd8f7abc44b3b82c02aa0f7f7ae01dff5eb07 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/438523 Commit-Queue: Josip Sokcevic <sokcevic@google.com> Tested-by: Josip Sokcevic <sokcevic@google.com> Reviewed-by: Gavin Mak <gavinmak@google.com>
* color: fix have_fg not re assign to truebright2024-09-122-0/+82
| | | | | | | | | | | | | | | | In method _parse the value of this variable 'have_fg ' is always False, Maybe reassign it to True is lost. I guess the author’s original intention was: if set some value in gitconfig file(for ex: text = black red ul), the first is bg color, the second is fg color, and the last one is attr. Change-Id: I372698fe625db4c1fdaa94ea7f193a80a850ecb9 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/425997 Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: Bright Ma <mmh1989@foxmail.com> Commit-Queue: Josip Sokcevic <sokcevic@google.com>
* logging: Fix log formatting with colored outputShik Chen2024-07-021-0/+37
| | | | | | | | | | | | | | | | | | | | The log message is already formatted before being passed to the colorer. To avoid the exception "TypeError: not enough arguments for format string", we should use the `nofmt_colorer` instead. This bug occurs only when the formatted string still contains '%' character. The following snippet can reproduce the bug: ``` from repo_logging import RepoLogger RepoLogger(__name__).error("%s", "100% failed") ``` Change-Id: I4e3977b3d21aec4e0deb95fc1c6dd1e59272d695 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/432017 Tested-by: Shik Chen <shik@google.com> Commit-Queue: Shik Chen <shik@google.com> Reviewed-by: Mike Frysinger <vapier@google.com>
* sync: Fix sorting for nested projectsJosip Sokcevic2024-03-081-10/+35
| | | | | | | | | | | | | | | | | | | The current logic to create checkout layers doesn't work in all cases. For example, let's assume there are three projects: "foo", "foo/bar" and "foo-bar". Sorting lexicographical order is incorrect as foo-bar would be placed between foo and foo/bar, breaking layering logic. Instead, we split filepaths based using path delimiter (always /) and then use lexicographical sort. BUG=b:325119758 TEST=./run_tests, manual sync on chromiumos repository Change-Id: I76924c3cc6ba2bb860d7a3e48406a6bba8f58c10 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/412338 Tested-by: Josip Sokcevic <sokcevic@google.com> Commit-Queue: Josip Sokcevic <sokcevic@google.com> Reviewed-by: George Engelbrecht <engeg@google.com>
* upload: Add support for setting patchset descriptionSergiy Belozorov2024-03-041-0/+10
| | | | | | | | | Bug: 308467447 Change-Id: I7abcbc98131b826120fc9ab85d5b889f90db4b0a Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/355968 Tested-by: Sergiy Belozorov <sergiyb@chromium.org> Reviewed-by: Mike Frysinger <vapier@google.com> Commit-Queue: Sergiy Belozorov <sergiyb@chromium.org>
* sync: Introduce git checkout levelsv2.42Josip Sokcevic2024-02-271-0/+26
| | | | | | | | | | | | | | | | | | | | | If a repo manifest is updated so that project B is placed within a project A, and if project A had content in new B's location in the old checkout, then repo sync could break depending on checkout order, since B can't be checked out before A. This change introduces checkout levels which enforces right sequence of checkouts while still allowing for parallel checkout. In an example above, A will always be checked out first before B. BUG=b:325119758 TEST=./run_tests, manual sync on ChromeOS repository Change-Id: Ib3b5e4d2639ca56620a1e4c6bf76d7b1ab805250 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/410421 Tested-by: Josip Sokcevic <sokcevic@google.com> Reviewed-by: Greg Edelston <gredelston@google.com> Commit-Queue: Josip Sokcevic <sokcevic@google.com> Reviewed-by: Gavin Mak <gavinmak@google.com>
* tests: setup user identity for testsVitalii Dmitriev2023-12-201-0/+9
| | | | | | | | | | | | | | | | | After a6413f5d a GitCommandError is raised. Since there were no user identity were set up, it fails: - ReviewableBranchTests from test_project.py - ResolveRepoRev and CheckRepoRev from test_wrapper.py Test: ./run_tests Change-Id: Id7f5772afe22c77fc4c8f8f0b8be1b627ed42187 Signed-off-by: Vitalii Dmitriev <vitalii.dmitriev@unikie.com> Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/398658 Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: Vitalii Dmitriev <dmit.vitalii@gmail.com> Commit-Queue: Vitalii Dmitriev <dmit.vitalii@gmail.com>
* manifest_xml: fix url normalization for inits and remotesVitalii Dmitriev2023-12-201-0/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Before the change, repo normalizes the urls with a following format only: git@github.com:foo/bar It doesn't cover the following case: <remote name="org" fetch="git@github.com:org/" /> <project name="somerepo" remote="org" /> Results to: error: Cannot fetch somerepo from ssh://git@github.com/org/git@github.com:org/somerepo Current change fixes it by normalizing this format: git@github.com:foo Test: ./run_tests tests/test_manifest_xml.py Change-Id: I1ad0f5df0d52c0b7229ba4c9a4db4eecb5c1a003 Signed-off-by: Vitalii Dmitriev <vitalii.dmitriev@unikie.com> Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/398337 Commit-Queue: Vitalii Dmitriev <dmit.vitalii@gmail.com> Tested-by: Vitalii Dmitriev <dmit.vitalii@gmail.com> Reviewed-by: Mike Frysinger <vapier@google.com>
* manifest_xml: do not allow / before : in scp-like syntaxMike Frysinger2023-12-191-0/+11
| | | | | | | | | | | Since git doesn't treat these as ssh:// URIs, we shouldn't either. Bug: https://g-issues.gerritcodereview.com/issues/40010331 Change-Id: I001f49be30395187cac447d09cb5a6c29e95768b Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/398517 Tested-by: Mike Frysinger <vapier@google.com> Reviewed-by: Jason Chang <jasonnc@google.com> Commit-Queue: Mike Frysinger <vapier@google.com>
* sync: Fix partial sync false positiveMatt Schulte2023-11-301-0/+38
| | | | | | | | | | | | | | | | | | | | | In the case of a project being removed from the manifest, and in the path in which the project used to exist, and symlink is place to another project repo will start to warn about partial syncs when a partial sync did not occur. Repro steps: 1) Create a manifest with two projects. Project a -> a/ and project b -> b/ 2) Run `repo sync` 3) Remove project b from the manifest. 4) Use `link` in the manifest to link all of Project a to b/ Bug: 314161804 Change-Id: I4a4ac4f70a7038bc7e0c4e0e51ae9fc942411a34 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/395640 Reviewed-by: Gavin Mak <gavinmak@google.com> Tested-by: Matt Schulte <matsch@google.com> Commit-Queue: Gavin Mak <gavinmak@google.com>
* Correctly handle schema-less URIs for remote fetch URLMichael Kelly2023-11-081-0/+29
| | | | | | | | | | | | | | | | Currently we don't deal with schema-less URIs like `git@github.com:foo` at all resulting in a scenario where we append them to the manifest repo URL. In order to deal with this, we munge both the manifest URL and the fetch URL into a format we like and proceed with that. Bug: https://g-issues.gerritcodereview.com/issues/40010331 Change-Id: I7b79fc4ed276630fdbeb235b94e327b172f0879b Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/386954 Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: Michael Kelly <mkelly@arista.com> Commit-Queue: Mike Frysinger <vapier@google.com>
* cleanup: Update codebase to expect Python 3.6Jason R. Coombs2023-10-316-13/+8
| | | | | | | | | | | - Bump minimum version to Python 3.6. - Use f-strings in a lot of places. Change-Id: I2aa70197230fcec2eff8e7c8eb754f20c08075bb Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/389034 Tested-by: Jason R. Coombs <jaraco@google.com> Reviewed-by: Mike Frysinger <vapier@google.com> Commit-Queue: Jason R. Coombs <jaraco@google.com>
* cleanup: delete redundant "r" open modeJason R. Coombs2023-10-212-5/+5
| | | | | | | | Change-Id: I86ebb8c5a9dc3752e8a25f4b11b64c5be3a6429e Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/390375 Tested-by: Mike Frysinger <vapier@google.com> Commit-Queue: Mike Frysinger <vapier@google.com> Reviewed-by: Aravind Vasudevan <aravindvasudev@google.com>
* manifest_xml: Fix empty project list when DOCTYPE is presentChris Allen2023-10-201-0/+15
| | | | | | | | | | | | | | | When parsing the manifest XML, the code looks for a top level DOM node named "manifest". However, it doesn't check that it's an element type node so if there is also an XML document type declaration node present (which has the same name as the root element) then it selects the wrong node and hence you end up with no projects defined at all. Change-Id: I8d101caffbbc2a06e56136ff21302e3f09cfc96b Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/390357 Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: Chris Allen <chris.allen@arm.com> Commit-Queue: Chris Allen <chris.allen@arm.com>
* project: using --depth results in error when including submanifestsRoberto Vladimir Prado Carranza2023-10-201-1/+4
| | | | | | | | | | | Fix: https://issues.gerritcodereview.com/issues/40015442 Change-Id: I7fb6c50cf2e438b21181ce1a5893885f09b9ee2b Signed-off-by: Roberto Vladimir Prado Carranza <roberto.prado.c@gmail.com> Signed-off-by: Guillaume Micouin-Jorda <gmicouin@netcourrier.com> Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/385995 Commit-Queue: Mike Frysinger <vapier@google.com> Reviewed-by: Mike Frysinger <vapier@google.com> Reviewed-by: Jerome Couto <jerome.couto@renault.com>
* delete Python 2 (object) compatMike Frysinger2023-10-202-2/+2
| | | | | | | | | Bug: 302871152 Change-Id: I39636d73a6e1d69efa8ade74f75c5381651e6dc8 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/390054 Commit-Queue: Mike Frysinger <vapier@google.com> Reviewed-by: Aravind Vasudevan <aravindvasudev@google.com> Tested-by: Mike Frysinger <vapier@google.com>
* tests: Set HOME to a temporary directory when running tests.v2.38Jason R. Coombs2023-10-171-0/+49
| | | | | | | | | | | | When running the tests in my environment, tests that derived from `test_wrapper.GitCheckoutTestCase` would fail on commit or tag due to incomplete or incorrect gpg config. Ideally, the tests should not be dependent on the user's git config. This change ensures $HOME (or Windows equivalent) is replaced for the session. Bug: 302797407 Change-Id: Ib42b712dd7b6602fee6e18329a8c6d52fb9458b9 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/388235 Tested-by: Jason R. Coombs <jaraco@google.com> Reviewed-by: Mike Frysinger <vapier@google.com> Commit-Queue: Jason R. Coombs <jaraco@google.com>
* git_command: Augment underlying git errors with suggestionsAravind Vasudevan2023-10-061-0/+133
| | | | | | | | | | | | | | | This change appends suggestions to the underlying git error to make the error slightly more actionable. DD: go/improve-repo-error-reporting & go/tee-repo-stderr Bug: b/292704435 Change-Id: I2bf8bea5fca42c6a9acd2fadc70f58f22456e027 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/387774 Commit-Queue: Aravind Vasudevan <aravindvasudev@google.com> Reviewed-by: Jason Chang <jasonnc@google.com> Tested-by: Aravind Vasudevan <aravindvasudev@google.com> Reviewed-by: Aravind Vasudevan <aravindvasudev@google.com>
* Use non-deprecated API for obtaining UTC timeLuK13372023-09-182-2/+6
| | | | | | | | | | | | | DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC). Change-Id: Ia2c46fb87c544d98cc2dd68a829f67d4770b479c Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/386615 Tested-by: Łukasz Patron <priv.luk@gmail.com> Reviewed-by: Mike Frysinger <vapier@google.com> Reviewed-by: Łukasz Patron <priv.luk@gmail.com> Commit-Queue: Mike Frysinger <vapier@google.com>
* main: Use repo loggerAravind Vasudevan2023-09-181-32/+34
| | | | | | | | | Bug: b/292704435 Change-Id: Ica02e4c00994a2f64083bb36e8f4ee8aa45d76bd Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/386454 Reviewed-by: Jason Chang <jasonnc@google.com> Commit-Queue: Aravind Vasudevan <aravindvasudev@google.com> Tested-by: Aravind Vasudevan <aravindvasudev@google.com>
* tests: test_subcmds_sync.py: fix for py3.6 & 3.7Daniel Kutik2023-09-131-2/+6
| | | | | | | | | | | | | | | | tests/test_subcmds_sync.py::LocalSyncState::test_prune_removed_projects was failing in Python 3.6 and 3.7 due to topdir not being set with the following error message: TypeError: expected str, bytes or os.PathLike object, not MagicMock topdir is accessed from within PruneRemovedProjects(). Test: tox with Python 3.6 to 3.11 Change-Id: I7ba5144df0a0126c01776384e2178136c3510091 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/382816 Reviewed-by: Mike Frysinger <vapier@google.com> Commit-Queue: Daniel Kutik <daniel.kutik@lavawerk.com> Tested-by: Daniel Kutik <daniel.kutik@lavawerk.com>
* tests: test_git_superproject.py: fix py3.6 & 3.7Daniel Kutik2023-09-131-2/+6
| | | | | | | | | | | | | | tests/test_git_superproject.py::SuperprojectTestCase::test_Fetch was failing in Python 3.6 and 3.7 due to attribute args only being introduced in Python 3.8. Falling back on old way of accessing the arguments. Test: tox with Python 3.6 to 3.11 Change-Id: Iae1934a7bce8cbd6b4519e4dbc92d94e21b43435 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/382818 Tested-by: Daniel Kutik <daniel.kutik@lavawerk.com> Reviewed-by: Mike Frysinger <vapier@google.com> Commit-Queue: Daniel Kutik <daniel.kutik@lavawerk.com>
* logging: Use log.formatter for coloring logsAravind Vasudevan2023-09-061-36/+0
| | | | | | | | | Bug: b/292704435 Change-Id: Iebdf8fb7666592dc5df2b36aae3185d1fc71bd66 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/385514 Tested-by: Aravind Vasudevan <aravindvasudev@google.com> Commit-Queue: Aravind Vasudevan <aravindvasudev@google.com> Reviewed-by: Mike Frysinger <vapier@google.com>
* sync: Use repo logger within syncAravind Vasudevan2023-08-311-24/+7
| | | | | | | | | Bug: b/292704435 Change-Id: Iceb3ad5111e656a1ff9730ae5deb032a9b43b4a5 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/383454 Commit-Queue: Aravind Vasudevan <aravindvasudev@google.com> Tested-by: Aravind Vasudevan <aravindvasudev@google.com> Reviewed-by: Mike Frysinger <vapier@google.com>
* isort: format codebasev2.36Mike Frysinger2023-08-227-11/+17
| | | | | | | | Change-Id: I6f11d123b68fd077f558d3c21349c55c5f251019 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/383715 Reviewed-by: Gavin Mak <gavinmak@google.com> Tested-by: Mike Frysinger <vapier@google.com> Commit-Queue: Mike Frysinger <vapier@google.com>
* tweak stdlib imports to follow Google style guideMike Frysinger2023-08-222-7/+9
| | | | | | | | | | | | Google Python style guide says to import modules. Clean up all our stdlib imports. Leave the repo ones alone for now as that's a much bigger shave. Change-Id: Ida42fc2ae78b86e6b7a6cbc98f94ca04b295f8cc Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/383714 Reviewed-by: Gavin Mak <gavinmak@google.com> Commit-Queue: Mike Frysinger <vapier@google.com> Tested-by: Mike Frysinger <vapier@google.com>
* upload: Suggest full sync if hooks fail with partially synced treeGavin Mak2023-08-221-2/+2
| | | | | | | | | | | Pre-upload hooks may fail because of partial syncs. Bug: b/271507654 Change-Id: I124cd386c5af2c34e1dcaa3e86916624e235b1e3 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/383474 Reviewed-by: Mike Frysinger <vapier@google.com> Commit-Queue: Gavin Mak <gavinmak@google.com> Tested-by: Gavin Mak <gavinmak@google.com>
* sync: Ignore repo project when checking partial syncsGavin Mak2023-08-221-2/+20
| | | | | | | | | | | | The repo project is fetched at most once a day and should be ignored when checking if the tree is partially synced. Bug: b/286126621, b/271507654 Change-Id: I684ed1669c3b3b9605162f8cc9d57185bb3dfe8e Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/383494 Commit-Queue: Gavin Mak <gavinmak@google.com> Tested-by: Gavin Mak <gavinmak@google.com> Reviewed-by: Josip Sokcevic <sokcevic@google.com>
* upload: fix error handlingJason Chang2023-08-211-0/+69
| | | | | | | | | | | | There was a bug in error handeling code that caused an uncaught exception to be raised. Bug: b/296316540 Change-Id: I49c72f29c00f26ba60de552f958bc6eddf841162 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/383254 Reviewed-by: Mike Frysinger <vapier@google.com> Commit-Queue: Jason Chang <jasonnc@google.com> Tested-by: Jason Chang <jasonnc@google.com>
* gitc: drop supportJason Chang2023-08-151-5/+3
| | | | | | | | | Bug: b/282775958 Change-Id: Ib6383d6fd82a017d0a6670d6558a905d41be321f Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/375314 Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: Jason Chang <jasonnc@google.com> Commit-Queue: Jason Chang <jasonnc@google.com>
* sync: Warn if partial sync state is detectedGavin Mak2023-08-101-0/+61
| | | | | | | | | | | | | | | Partial syncs are not supported and can lead to strange behavior like deleting files. Explicitly warn users on partial sync. Bug: b/286126621, b/271507654 Change-Id: I471f78ac5942eb855bc34c80af47aa561dfa61e8 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/382154 Reviewed-by: Jason Chang <jasonnc@google.com> Reviewed-by: Aravind Vasudevan <aravindvasudev@google.com> Tested-by: Gavin Mak <gavinmak@google.com> Commit-Queue: Gavin Mak <gavinmak@google.com> Reviewed-by: Mike Frysinger <vapier@google.com> Reviewed-by: Josip Sokcevic <sokcevic@google.com>
* Raise repo exit errors in place of sys.exitJason Chang2023-08-072-2/+6
| | | | | | | | | Bug: b/293344017 Change-Id: I92d81c78eba8ff31b5252415f4c9a515a6c76411 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/381774 Tested-by: Jason Chang <jasonnc@google.com> Reviewed-by: Joanna Wang <jojwang@google.com> Commit-Queue: Jason Chang <jasonnc@google.com>
* Prefix error events with RepoErrorEvent:Jason Chang2023-08-071-2/+2
| | | | | | | | | | | | Prior to this change there is no way to distinguish between git sessions logs generated from repo source v.s. from git. Bug: b/294446468 Change-Id: I309f59e146c30cb08a0637e8d0b9c5d9efd5cada Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/381794 Commit-Queue: Jason Chang <jasonnc@google.com> Reviewed-by: Joanna Wang <jojwang@google.com> Tested-by: Jason Chang <jasonnc@google.com>
* Refactor errors for sync commandJason Chang2023-08-021-0/+83
| | | | | | | | | | | | | | | | | | Per discussion in go/repo-error-update updated aggregated and exit errors for sync command. Aggregated errors are errors that result in eventual command failure. Exit errors are errors that result in immediate command failure. Also updated main.py to log aggregated and exit errors to git sessions log Bug: b/293344017 Change-Id: I77a21f14da32fe2e68c16841feb22de72e86a251 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/379614 Reviewed-by: Aravind Vasudevan <aravindvasudev@google.com> Tested-by: Jason Chang <jasonnc@google.com> Commit-Queue: Jason Chang <jasonnc@google.com>
* Update errors to extend BaseRepoErrorJason Chang2023-07-312-4/+65
| | | | | | | | | | | | | | | | | | | In order to better analyze and track repo errors, repo command failures need to be tied to specific errors in repo source code. Additionally a new GitCommandError was added to differentiate between general git related errors to failed git commands. Git commands that opt into verification will raise a GitCommandError if the command failed. The first step in this process is a general error refactoring Bug: b/293344017 Change-Id: I46944b1825ce892757c8dd3f7e2fab7e460760c0 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/380994 Commit-Queue: Jason Chang <jasonnc@google.com> Reviewed-by: Aravind Vasudevan <aravindvasudev@google.com> Tested-by: Jason Chang <jasonnc@google.com> Reviewed-by: Joanna Wang <jojwang@google.com>
* [repo logging] Add logging moduleAravind Vasudevan2023-07-311-0/+115
| | | | | | | | | Bug: b/292704435 Change-Id: I8834591f661c75449f8be5de1c61ecd43669026d Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/380714 Tested-by: Aravind Vasudevan <aravindvasudev@google.com> Reviewed-by: Joanna Wang <jojwang@google.com> Commit-Queue: Aravind Vasudevan <aravindvasudev@google.com>
* sync: Track last completed fetch/checkoutGavin Mak2023-07-281-0/+75
| | | | | | | | | | | | Save the latest time any project is fetched and checked out. This will be used to detect partial checkouts. Bug: b/286126621 Change-Id: I53b264dc70ba168d506076dbd693ef79a696b61d Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/380514 Commit-Queue: Gavin Mak <gavinmak@google.com> Reviewed-by: Joanna Wang <jojwang@google.com> Tested-by: Gavin Mak <gavinmak@google.com>
* manifest: enable remove-project using pathFredrik de Groot2023-06-211-0/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | A something.xml that gets included by two different files, that both remove and add same shared project to two different locations, would not work prior to this change. Reason is that remove killed all name keys, even though reuse of same repo in different locations is allowed. Solve by adding optional attrib path to <remove-project name="foo" path="only_this_path" /> and tweak remove-project. Behaves as before without path, and deletes more selectively when remove path is supplied. As secondary feature, a project can now also be removed by only using path, assuming a matching project name can be found. Change-Id: I502d9f949f5d858ddc1503846b170473f76dc8e2 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/375694 Tested-by: Fredrik de Groot <fredrik.de.groot@aptiv.com> Reviewed-by: Mike Frysinger <vapier@google.com>
* Parse OpenSSH versions with no SSH_EXTRAVERSIONSaagar Jha2023-05-241-0/+2
| | | | | | | | | | | If the Debian banner is not used, then there won't be a space after the version number: it'll be followed directly by a comma. Bug: https://crbug.com/gerrit/16903 Change-Id: I12b873f32afc9424f42b772399c346f96ca95a96 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/372875 Tested-by: Saagar Jha <saagarjha@google.com> Reviewed-by: Mike Frysinger <vapier@google.com>
* manifest: add support for revision in includeShuchuan Zeng2023-05-051-0/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Attribute groups can now be added to manifest include, thus all projects in an included manifest file can easily modify default branch without modifying all projects in that manifest file. For example, the main manifest.xml has an include node contain revision attribute, ``` <include name="include.xml" revision="r1" /> ``` and the include.xml has some projects, ``` <project path="project1_path" name="project1_name" revision="r2" /> <project path="project2_path" name="project2_name" /> ``` With this change, the final manifest will have revision="r1" for project2. ``` <project name="project1_name" path="project1_path" revision="r2" /> <project name="project2_name" path="project2_path" revision="r1" /> ``` Test: added unit tests to cover the inheritance Change-Id: I4b8547a7198610ec3a3c6aeb2136e0c0f3557df0 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/369714 Reviewed-by: Mike Frysinger <vapier@google.com> Commit-Queue: Shuchuan Zeng <zengshuchuan@allwinnertech.com> Tested-by: Shuchuan Zeng <zengshuchuan@allwinnertech.com>
* tests: do not allow underscores in cli optionsMike Frysinger2023-04-191-0/+14
| | | | | | | | | | | We use dashes in --long-options, not underscores, so add a test to make sure people don't accidentally add them. Change-Id: Iffbce474d22cf1f6c2042f7882f215875c8df3cf Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/369734 Reviewed-by: Gavin Mak <gavinmak@google.com> Tested-by: Mike Frysinger <vapier@google.com> Commit-Queue: Mike Frysinger <vapier@google.com>
* Format codebase with black and check formatting in CQGavin Mak2023-03-2218-2815/+3275
| | | | | | | | | | | | Apply rules set by https://gerrit-review.googlesource.com/c/git-repo/+/362954/ across the codebase and fix any lingering errors caught by flake8. Also check black formatting in run_tests (and CQ). Bug: b/267675342 Change-Id: I972d77649dac351150dcfeb1cd1ad0ea2efc1956 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/363474 Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: Gavin Mak <gavinmak@google.com> Commit-Queue: Gavin Mak <gavinmak@google.com>