summaryrefslogtreecommitdiffstats
path: root/project.py
Commit message (Collapse)AuthorAgeFilesLines
* project: use --netrc-optional instead of --netrcv2.54stableGavin Mak2025-04-101-1/+8
| | | | | | | | | | | | | | | | | Some users are reporting a "curl: (26) .netrc error: no such file" message on sync caused by an change to curl behavior. See https://github.com/curl/curl/issues/16163. Use --netrc-optional which was introduced in curl version 7.9.8 released in 2002. Bug: 409354839 Change-Id: I8365c6e806968a4ee765a7e023b4bced30489c20 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/467026 Reviewed-by: Mike Frysinger <vapier@google.com> Commit-Queue: Gavin Mak <gavinmak@google.com> Tested-by: Gavin Mak <gavinmak@google.com> Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
* Sync: Fix full submodule sync while shallow specifiedv2.53Albert Akmukhametov2025-03-131-8/+20
| | | | | | | | | | | | | | | | | | | | Git allows to clone submodules as shallow clone [1]. On the other hand, when repo synchronize a projcet with submodules inside, it ignores the shallow parameter. When a project contains submodules, project.py parses the .gitmodules file for URL and path. This parsing does not consider the shallow option. Consequently, this parameter is not propgated to newly created Project instance for that submodule. [1] https://git-scm.com/docs/gitmodules#Documentation/gitmodules.txt-submoduleltnamegtshallow Change-Id: I54fc9c69ae1b8e3cda2801202e3f0c7693b718d2 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/454261 Tested-by: Albert Akmukhametov <alb.02057@gmail.com> Commit-Queue: Albert Akmukhametov <alb.02057@gmail.com> Reviewed-by: Josip Sokcevic <sokcevic@chromium.org> Reviewed-by: Никита Сказкоподателев (Nask) <skazkopodatelev@gmail.com>
* Activate submodulesKaushik Lingarkar2025-02-041-0/+22
| | | | | | | | | | | | | | This change moves further towards ensuring Git can understand repo's submodules. 'submodule init' is used to make the submodules active[1]. [1] https://git-scm.com/docs/gitsubmodules#_active_submodules Change-Id: I0c20ff1991101fc5be171e566d8fb644aab47200 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/446182 Tested-by: Kaushik Lingarkar <kaushikl@qti.qualcomm.com> Reviewed-by: Nasser Grainawi <nasser.grainawi@oss.qualcomm.com> Reviewed-by: Josip Sokcevic <sokcevic@chromium.org> Reviewed-by: Mike Frysinger <vapier@google.com>
* Use 'gitfile' in submodule checkoutsKaushik Lingarkar2025-02-041-7/+42
| | | | | | | | | | | | | | | | | | This change takes another step towards ensuring Git can understand repo's submodules to some extent. Replace the old '.git' symlink with gitfile[1] pointing to the bare checkout of the submodule. This is required for Git's 'recurse submodules' opts to work with repo's submodules as '.git' is expected to be writable by Git when recursing over submodules. [1] https://git-scm.com/docs/gitrepository-layout#_description Change-Id: I52d15451768ee7bd6db289f4d2b3be5907370d42 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/446181 Tested-by: Kaushik Lingarkar <kaushikl@qti.qualcomm.com> Reviewed-by: Josip Sokcevic <sokcevic@chromium.org> Reviewed-by: Mike Frysinger <vapier@google.com> Reviewed-by: Nasser Grainawi <nasser.grainawi@oss.qualcomm.com>
* Update internal filesystem layout for submodulesKaushik Lingarkar2025-02-041-0/+27
| | | | | | | | | | | | | | Change the bare checkout directory for submodules from 'subprojects' to 'modules'. Git expects bare submodule checkouts to be in the 'modules' directory. If old subproject directories are found, they will be migrated to the new modules directory. This change is the first step in ensuring Git can understand repo's submodules to some extent. Change-Id: I385029f1bb55d040616d970d6ffb4bb856692520 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/444881 Tested-by: Kaushik Lingarkar <kaushikl@qti.qualcomm.com> Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
* sync: Recover from errors during read-treev2.51Josip Sokcevic2025-01-161-5/+12
| | | | | | | | | | | | | | | | | | | | | When repo is initializing a git repository, it calls `git read-tree`. During such operation, git is restoring workspace based on the current index. However, some things can go wrong: a user can run out of disk space, or, in case of partial clone, user may no longer reach the remote host. That will leave affected repository in a bad state with partially checked out workspace. The follow up repo sync won't try to fix such state. This change removes .git symlink, which will force the next `repo sync` to redo Git repository setup. Bug: b/363171216 Bug: b/390161127 Change-Id: I57db4b6cae0ef21826dc7cede4d3bf02cfc3d955 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/447801 Reviewed-by: Scott Lee <ddoman@google.com> Tested-by: Josip Sokcevic <sokcevic@chromium.org> Commit-Queue: Josip Sokcevic <sokcevic@chromium.org>
* Remove gitc support from repoJosip Sokcevic2024-12-031-3/+0
| | | | | | | | | | 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>
* worktree: Do not try to fix relative pathsv2.49.1Allen Webb2024-10-301-18/+23
| | | | | | | | | | | | | --worktree was broken with incorrect paths in the .git files whenever the local copy of git populated gitdir with relative paths instead of absoulte paths. Bug: 376251410 Change-Id: Id32dc1576315218967de2a9bfe43bf7a5a0e7aa6 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/440801 Commit-Queue: Allen Webb <allenwebb@google.com> Reviewed-by: Josip Sokcevic <sokcevic@google.com> Tested-by: Allen Webb <allenwebb@google.com>
* Fix incremental syncs for prjs with submodulesKaushik Lingarkar2024-10-181-1/+3
| | | | | | | | | | | | | | | | | | | When performing an incremental sync (re-running repo init with an updated manifest revision) with --fetch-submodules or sync-s=true, there is an attempt to get a list of all projects (including submodules) before projects are actually fetched. However, we can only list submodules of a project if we have already fetched its revision. Instead of throwing an error when we don't have the revision, assume there are no submodules for that project. In the sync cmd, we already update the list of projects to include submodules after fetching superprojects. Change-Id: I48bc68c48b5b10117356b18f5375d17f9a89ec05 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/439761 Commit-Queue: Kaushik Lingarkar <kaushik.lingarkar@linaro.org> Tested-by: Kaushik Lingarkar <kaushik.lingarkar@linaro.org> Reviewed-by: Josip Sokcevic <sokcevic@google.com> Reviewed-by: Nasser Grainawi <nasser.grainawi@linaro.org>
* sync: Always use WORKER_BATCH_SIZEv2.48Josip Sokcevic2024-10-071-10/+9
| | | | | | | | | | | | | | | | | | | 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>
* project: Handle git sso auth failures as repo exitJosip Sokcevic2024-10-031-0/+15
| | | | | | | | | | | | | | | | If a user is not authenticated, repo continues execution and it will likely result in more of the same errors being printed. A user is also likely to SIGTERM the process resulting in more errors. This change stops repo sync if any of repositories can't be fetched to Git authentcation using sso helper. We could extend this to all Git authentication Change-Id: I9e471e063450c0a51f25a5e7f12a83064dfb170c Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/438522 Reviewed-by: Gavin Mak <gavinmak@google.com> Tested-by: Josip Sokcevic <sokcevic@google.com> Commit-Queue: Josip Sokcevic <sokcevic@google.com>
* project: run fetch --refetch on unable to not parse commitJosip Sokcevic2024-10-031-1/+4
| | | | | | | | | | | | | | | Similarly to e59e2ae757623e64f625a9cdadf1c2010ef82b34, handle missing gc'ed commits by running `git fetch --refetch`. R=jojwang@google.com Bug: b/360889369 Bug: b/371000949 Change-Id: I108b870b855d3b9f23665afa134c6e35f7cd2830 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/438461 Reviewed-by: Joanna Wang <jojwang@google.com> Tested-by: Josip Sokcevic <sokcevic@google.com> Commit-Queue: Josip Sokcevic <sokcevic@google.com>
* Disable git terminal prompt during fetch/cloneJosip Sokcevic2024-09-261-0/+13
| | | | | | | | | | | | | | | | | | | | git fetch operation may prompt user to enter username and password. This won't be visible to user when repo sync operation since stdout and stderr are redirected. If that happens, user may think repo is doing work and likely won't realize it's stuck on user's input. This patch disables prompt for clone and fetch operations, and repo will fail fast. R=gavinmak@google.com Bug: b/368644181 Change-Id: I2efa88ae66067587a00678eda155d861034b9127 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/438001 Reviewed-by: Nasser Grainawi <nasser.grainawi@linaro.org> Tested-by: Josip Sokcevic <sokcevic@google.com> Commit-Queue: Josip Sokcevic <sokcevic@google.com> Reviewed-by: Gavin Mak <gavinmak@google.com>
* project: Copy and link files even with local branchesBrian Norris2024-09-191-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In the winding maze that constitutes Sync_LocalHalf(), there are paths in which we don't copy-and-link files. Examples include something like: cd some/project/ repo start head . # do some work, make some commit, upload that commit to Gerrit [[ ... in the meantime, someone addes a <linkfile ...> for some/project/ in the manifest ... ]] cd some/project/ git pull --rebase repo sync In this case, we never hit a `repo rebase` case, which might have saved us. Instead, the developer is left confused why some/project/ never had its <linkfile>s created. Notably, this opens up one more corner case in which <linkfile ... /> or <copyfile ... /> could potentially clobber existing work in the destination directory, but there are existing cases where that's true, and frankly, those seem like bigger holes than this new one. Change-Id: I394b0e4529023a8ee319dc25d03d513a19251a4a Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/437421 Reviewed-by: Josip Sokcevic <sokcevic@google.com> Tested-by: Brian Norris <briannorris@google.com> Commit-Queue: Brian Norris <briannorris@google.com>
* project: run fetch --refetch onacould not parse commitJosip Sokcevic2024-09-121-0/+11
| | | | | | | | | | | | | | | | git may gc reachable objects in partial clone repository due to a bug (report: https://lore.kernel.org/git/20240802073143.56731-1-hanyang.tony@bytedance.com/ ). Until git is properly patched and released, force --refetch iff "could not parse commit" is part of git output. --refetch will will ensure that gc'ed objects are retrieved. Bug: b/360889369 Change-Id: I0fc911c591060f859235dcd8d019881106f0858e Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/437017 Commit-Queue: Josip Sokcevic <sokcevic@google.com> Reviewed-by: Sam Saccone <samccone@google.com> Tested-by: Josip Sokcevic <sokcevic@google.com>
* Add a `--rebase` option to sync commandJeroen Dhollander2024-08-301-2/+4
| | | | | | | | | | | | | | | | Previously repo would abort a sync if there were published changes not merged upstream. The --rebase option allows the modification of published commits. This is a copy of http://go/grev/369694 with the merge conflicts resolved. Bug: 40014610 Change-Id: Idac8199400346327b530abea33f1ed794e5bb4c2 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/435838 Reviewed-by: Josip Sokcevic <sokcevic@google.com> Tested-by: Jeroen Dhollander <jeroendh@google.com> Commit-Queue: Jeroen Dhollander <jeroendh@google.com>
* sync: Fix git command for aborting rebase being called incorrectly.Erik Elmeke2024-08-281-1/+1
| | | | | | | | | | | | The argument list was incorrectly destructured so only the first element of the list was considered a git-cmd, split up by each character in the string. Change-Id: Idee8a95a89a7da8b8addde07135354fc506c2758 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/435839 Reviewed-by: Josip Sokcevic <sokcevic@google.com> Commit-Queue: Erik Elmeke <erik@haleytek.corp-partner.google.com> Tested-by: Erik Elmeke <erik@haleytek.corp-partner.google.com>
* project: ignore more curl failure modesv2.46Mike Frysinger2024-07-021-4/+13
| | | | | | | | | | | | | Current clone bundle fetches from Google storage results HTTP/404 and curl exiting 56. This is basically WAI, so stop emitting verbose error output whenever that happens. Also add a few more curl exit statuses based on chromite history, and document them. Change-Id: I3109f8a8a19109ba9bbd62780b40bbcd4fce9b76 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/432197 Commit-Queue: Mike Frysinger <vapier@google.com> Reviewed-by: Gavin Mak <gavinmak@google.com> Tested-by: Mike Frysinger <vapier@google.com>
* upload: add a --topic option for setting topic explicitlyMike Frysinger2024-07-011-5/+5
| | | | | | | | | | | | | | Let people specify the exact topic when uploading CLs. The existing -t option only supports setting the topic to the current local branch. Add a --topic-branch long option to the existing -t to align it a bit better with --hashtag & --hashtag-branch. Change-Id: I010abc4a7f3c685021cae776dd1e597c22b79135 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/431997 Tested-by: Mike Frysinger <vapier@google.com> Reviewed-by: Gavin Mak <gavinmak@google.com> Commit-Queue: Mike Frysinger <vapier@google.com>
* sync: Abort rebase in progress if force-checkout is setErik Elmeke2024-05-231-1/+31
| | | | | | | | | | | | | This will make "repo sync -d --force-checkout" more reliable in CI automation, as there are fewer things in the way that may need manual intervention. Bug: b/40015382 Change-Id: I8a79971724a3d9a8e2d682b7a0c04deda9e34177 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/423317 Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: Erik Elmeke <erik@haleytek.corp-partner.google.com> Commit-Queue: Erik Elmeke <erik@haleytek.corp-partner.google.com>
* git: raise hard version to 1.9.1Mike Frysinger2024-05-011-8/+2
| | | | | | | | | | | | | | | | | | Debian 7 Wheezy went EOL in May 2018. We don't need to carry support for that anymore as there have been 5 major releases since. Ubuntu Precise went EOL in Apr 2019 (including the extended support phase). That means we can bump the required git version from 1.7.9 to 1.9.1. git-1.7.9 was released in 2012 while git-1.9.1 was released in 2014. So that shouldn't be a problem either. And we've been warning people using git versions older than 1.9.1 for 3 years now that they need to upgrade. Change-Id: Ifbbf72f51010b0a944c2785895d1b605333f9146 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/415637 Reviewed-by: Josip Sokcevic <sokcevic@google.com> Tested-by: Mike Frysinger <vapier@google.com> Commit-Queue: Mike Frysinger <vapier@google.com>
* gitc: delete a few more dead referencesMike Frysinger2024-04-181-2/+0
| | | | | | | | Change-Id: I1da6f2ee799c735a63ac3ca6e5abd1211af10433 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/419217 Reviewed-by: Josip Sokcevic <sokcevic@google.com> Tested-by: Mike Frysinger <vapier@google.com> Commit-Queue: Mike Frysinger <vapier@google.com>
* Remove platform_utils.realpathKaiyi Li2024-03-271-16/+12
| | | | | | | | | | ... since it's just a simple wrapper of os.path.realpath now. Change-Id: I7433e5fe09c64b130f06e2541151dce1961772c9 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/416637 Tested-by: Kaiyi Li <kaiyili@google.com> Reviewed-by: Greg Edelston <gredelston@google.com> Commit-Queue: Kaiyi Li <kaiyili@google.com>
* project: Check if dotgit exists w/out symlink checkv2.45Josip Sokcevic2024-03-201-1/+1
| | | | | | | | | | | | | | | | | | | | os.path.exists returns false on a broken symlink. This is not what repo needs when checking if a project is setup properly. For example, if src/foo/.git can't be resolved, repo tries to create symlink and that results in FileExistsError. Use lexists which returns True even if symlink is broken. That will force path where repo checks where symlink is pointing to and will fix it to the correct location. Bug: b/281746795 Change-Id: Id3f7dc3a3cb6499d02ce7335eca992ddc7deb645 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/415197 Tested-by: Josip Sokcevic <sokcevic@google.com> Commit-Queue: Josip Sokcevic <sokcevic@google.com> Reviewed-by: George Engelbrecht <engeg@google.com> Reviewed-by: Greg Edelston <gredelston@google.com>
* main: Stringify project name in error_infoJosip Sokcevic2024-03-151-2/+2
| | | | | | | | | | | | | | | | | | If a project can't be removed from checkout due to uncommitted changes present, error.project is type of Project and not a string (as it is in some cases). Project is not JSON serializable, resulting in exception within exception handler: TypeError: Object of type Project is not JSON serializable This change casts project to string as a defensive mechanism. It also passes project name instead of project object. Change-Id: Ie7b782d73dc3647975755d5a3774d16ea6cd5348 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/413877 Tested-by: Josip Sokcevic <sokcevic@google.com> Reviewed-by: Gavin Mak <gavinmak@google.com> Commit-Queue: Josip Sokcevic <sokcevic@google.com>
* sync: introduce --force-checkoutv2.43Josip Sokcevic2024-03-071-2/+5
| | | | | | | | | | | | | | In some cases (e.g. in a CI system), it's desirable to be able to instruct repo to force checkout. This flag passes --force flag to `git checkout` operations. Bug: b/327624021 Change-Id: I579edda546fb8147c4e1a267e2605fcf6e597421 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/411518 Commit-Queue: Josip Sokcevic <sokcevic@google.com> Reviewed-by: Gavin Mak <gavinmak@google.com> Reviewed-by: George Engelbrecht <engeg@google.com> Tested-by: Josip Sokcevic <sokcevic@google.com>
* upload: Add support for setting patchset descriptionSergiy Belozorov2024-03-041-0/+32
| | | | | | | | | 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>
* project: Rename if deletion failsv2.41Josip Sokcevic2024-01-251-10/+22
| | | | | | | | | | | | | If a project contains files not owned by the current user, remove will fail. In order to ensure repo sync continues to work, rename the affected project instead, and let user know about it. Bug: 321273512 Change-Id: I0779d61fc67042308a0226adea7d98167252a5d3 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/404372 Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: Josip Sokcevic <sokcevic@google.com> Commit-Queue: Josip Sokcevic <sokcevic@google.com>
* Clean up remaining `repo sync` log spam.Tomasz Wasilczyk2024-01-051-16/+21
| | | | | | | | | | | | | There are still some verbose messages (e.g. "remote: ...") when doing repo sync after a couple days. Let's hide them behind verbose flag. Bug: N/A Test: repo sync Change-Id: I1408472c95ed80d9555adfe8f92211245c03cf41 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/400855 Reviewed-by: Josip Sokcevic <sokcevic@google.com> Tested-by: Tomasz Wasilczyk <twasilczyk@google.com> Commit-Queue: Tomasz Wasilczyk <twasilczyk@google.com>
* project: Check references during syncJosip Sokcevic2024-01-031-1/+14
| | | | | | | | | | | | | | | Symbolic references need to be checked each time sync is called, not only for newly created repositories. For example, it is possible to change a project name to the already existing name, and that will result in a broken git setup without this patch: refs/ will still point to the old repository, whereas all objects will point to the new repository. Bug: 40013418 Change-Id: I596d29d182986804989f0562fb45090224549b0f Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/395798 Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: Josip Sokcevic <sokcevic@google.com> Commit-Queue: Josip Sokcevic <sokcevic@google.com>
* Don't log spam `repo sync` by defaultv2.40Tomasz Wasilczyk2023-12-081-9/+14
| | | | | | | | | | | | | | | Most times a repo sync after some time (week+) results in a bunch of messages, which are not very useful for average user: - discarding 1 commits - Deleting obsolete checkout. Bug: N/A Test: repo sync Change-Id: I881eab61f9f261e98f3656c09e73ddd159ce288c Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/397038 Reviewed-by: Josip Sokcevic <sokcevic@google.com> Commit-Queue: Josip Sokcevic <sokcevic@google.com> Tested-by: Tomasz Wasilczyk <twasilczyk@google.com>
* cleanup: Update codebase to expect Python 3.6Jason R. Coombs2023-10-311-40/+29
| | | | | | | | | | | - 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>
* project: Speculative fix for project corruptionJosip Sokcevic2023-10-231-0/+11
| | | | | | | | | | | | | | | | When a new shared project is added to manifest, there's a short window where objects can be deleted that are used by other projects. To close that window, set preciousObjects during git init. For non-shared projects, repo should correct the state in the same execution instance. Bug: 288102993 Change-Id: I366f524535ac58c820d51a88599ae2108df9ab48 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/390234 Commit-Queue: Josip Sokcevic <sokcevic@google.com> Tested-by: Josip Sokcevic <sokcevic@google.com> Reviewed-by: Mike Frysinger <vapier@google.com>
* cleanup: convert exceptions to OSErrorJason R. Coombs2023-10-211-5/+5
| | | | | | | | | | | In Python 3, these exceptions were merged into OSError, so switch everything over to that. Change-Id: If876a28b692de5aa5c62a3bdc8c000793ce52c63 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/390376 Reviewed-by: Aravind Vasudevan <aravindvasudev@google.com> Commit-Queue: Mike Frysinger <vapier@google.com> Tested-by: Mike Frysinger <vapier@google.com>
* cleanup: delete redundant "r" open modeJason R. Coombs2023-10-211-1/+1
| | | | | | | | 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>
* project: using --depth results in error when including submanifestsRoberto Vladimir Prado Carranza2023-10-201-1/+1
| | | | | | | | | | | 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-201-13/+13
| | | | | | | | | 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>
* Update logger.warn to logger.warningAravind Vasudevan2023-10-131-6/+6
| | | | | | | | | Bug: 305035810 Change-Id: Ic2b35d5c3cbe92480c24da612f29382f5d26d4aa Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/389414 Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: Aravind Vasudevan <aravindvasudev@google.com> Commit-Queue: Aravind Vasudevan <aravindvasudev@google.com>
* git_command: Augment underlying git errors with suggestionsAravind Vasudevan2023-10-061-1/+1
| | | | | | | | | | | | | | | 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>
* project: Invoke realpath on dotgit for symmetry with gitdir to ensure a ↵Jason R. Coombs2023-10-051-1/+2
| | | | | | | | | | | | short relpath. Bug: 302680231 Change-Id: Icd01dd2ce62d737a4acb114e729189cd31f6bde9 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/388234 Tested-by: Jason R. Coombs <jaraco@google.com> Reviewed-by: Mike Frysinger <vapier@google.com> Commit-Queue: Jason R. Coombs <jaraco@google.com>
* Track expected git errors in logsJason Chang2023-09-271-7/+24
| | | | | | | | | | | | Sometimes it is expected that a GitCommand executed in repo fails. In such cases indicate in trace logs that the error was expected. Bug: b/293344017 Change-Id: If137fae9ef9769258246f5b4494e070345db4a71 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/387714 Commit-Queue: Jason Chang <jasonnc@google.com> Reviewed-by: Gavin Mak <gavinmak@google.com> Tested-by: Jason Chang <jasonnc@google.com>
* project: Use repo loggerAravind Vasudevan2023-09-141-103/+69
| | | | | | | | | Bug: b/292704435 Change-Id: I510fc911530db2c84a7ee099fa2905ceac35d0b7 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/386295 Reviewed-by: Jason Chang <jasonnc@google.com> Tested-by: Aravind Vasudevan <aravindvasudev@google.com> Commit-Queue: Aravind Vasudevan <aravindvasudev@google.com>
* project: Use IsId instead of ID_RE.matchSylvain2023-09-111-14/+7
| | | | | | | | Change-Id: I8ca83a034400da0cb97cba41415bfc50858a898b Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/385857 Tested-by: Sylvain Desodt <sylvain.desodt@gmail.com> Commit-Queue: Sylvain Desodt <sylvain.desodt@gmail.com> Reviewed-by: Mike Frysinger <vapier@google.com>
* project: Optimise GetCommitRevisionId when revisionId is setSylvain2023-09-111-0/+2
| | | | | | | | | | | | | | | | | | | When comparing 2 manifests, most of the time is spent getting the relevant commit id as it relies on _allrefs which ends up loading all git references. However, the value from `revisionIs` (when it is valid) could be used directly leading to a huge performance improvement (from 180+ seconds to less than 0.01 sec which is more than 25000 times faster for manifests with 700+ projects). Bug: 295282548 Change-Id: I5881aa4b2326cc17bbb4ee91d23293111f76ad7e Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/385834 Tested-by: Sylvain Desodt <sylvain.desodt@gmail.com> Reviewed-by: Mike Frysinger <vapier@google.com> Commit-Queue: Sylvain Desodt <sylvain.desodt@gmail.com>
* project: Preserve stderr on uploadv2.36.1Jason Chang2023-08-281-3/+1
| | | | | | | | | | | | | A previous change captured stderr when uploading git projects. This change ensures stderr is sent to stderr. Bug: b/297097597 Change-Id: I8314e1017d2a42b7b655fe43ce3c312d397894ca Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/384134 Reviewed-by: Mike Frysinger <vapier@google.com> Commit-Queue: Jason Chang <jasonnc@google.com> Tested-by: Jason Chang <jasonnc@google.com> Reviewed-by: Sam Saccone <samccone@google.com>
* isort: format codebasev2.36Mike Frysinger2023-08-221-19/+23
| | | | | | | | 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>
* upload: fix error handlingJason Chang2023-08-211-4/+6
| | | | | | | | | | | | 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>
* Raise RepoExitError in place of sys.exitJason Chang2023-08-101-26/+28
| | | | | | | | | | Bug: b/293344017 Change-Id: Icae4932b00e4068cba502a5ab4a0274fd7854d9d Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/382214 Reviewed-by: Gavin Mak <gavinmak@google.com> Tested-by: Jason Chang <jasonnc@google.com> Reviewed-by: Aravind Vasudevan <aravindvasudev@google.com> Commit-Queue: Jason Chang <jasonnc@google.com>
* Raise repo exit errors in place of sys.exitJason Chang2023-08-071-12/+10
| | | | | | | | | 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>
* Refactor errors for sync commandJason Chang2023-08-021-87/+196
| | | | | | | | | | | | | | | | | | 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>