summaryrefslogtreecommitdiffstats
path: root/git_command.py
Commit message (Collapse)AuthorAgeFilesLines
* black: update to v25Mike Frysinger2025-03-251-6/+6
| | | | | | | | | | 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>
* Disable git terminal prompt during fetch/cloneJosip Sokcevic2024-09-261-6/+9
| | | | | | | | | | | | | | | | | | | | 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>
* git_command: unify soft/hard versions with requirements.jsonMike Frysinger2024-03-211-11/+0
| | | | | | | | | | | Use the requirements logic in the wrapper to load versions out of the requirements.json file to avoid duplicating them in git_command.py. Change-Id: Ib479049fc54ebc6f52c2c30d1315cf1734ff1990 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/415617 Reviewed-by: Josip Sokcevic <sokcevic@google.com> Commit-Queue: Mike Frysinger <vapier@google.com> Tested-by: Mike Frysinger <vapier@google.com>
* git_command: Return None from GetEventTargetPath() if set to empty stringPeter Collingbourne2024-02-261-0/+2
| | | | | | | | | | | | If trace2.eventTarget was set to the empty string, match git behavior and don't write a trace. Bug: 319673783 Change-Id: I02b3884ad97551f8a9d7363c2cbe6b0adee6f73e Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/410518 Reviewed-by: Josip Sokcevic <sokcevic@google.com> Commit-Queue: Josip Sokcevic <sokcevic@google.com> Tested-by: Peter Collingbourne <pcc@google.com>
* cleanup: Update codebase to expect Python 3.6Jason R. Coombs2023-10-311-8/+6
| | | | | | | | | | | - 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>
* delete Python 2 (object) compatMike Frysinger2023-10-201-3/+3
| | | | | | | | | 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>
* git_command: read1 needs a size in py3.6Daniel Kutik2023-10-091-2/+3
| | | | | | | | | | | | | | | | | Not setting size causes "TypeError: read1() takes exactly one argument (0 given)" in Python 3.6. In Python 3.7 onwards size defaults to -1, which means an arbitrary number of bytes will be returned. Compare https://docs.python.org/3.6/library/io.html#io.BufferedReader.read1 and https://docs.python.org/3.7/library/io.html#io.BufferedIOBase.read1 for more details. Change-Id: Ia4aaf8140ead9493ec650fac167c641569e6a9d8 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/388718 Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: Daniel Kutik <daniel.kutik@lavawerk.com> Commit-Queue: Daniel Kutik <daniel.kutik@lavawerk.com>
* git_command: lru_cache needs maxsize for py36 & 37Daniel Kutik2023-10-091-1/+1
| | | | | | | | | | | | Python 3.6 and 3.7 do not have a default value for lru_cache maxsize. Not setting it would cause: TypeError: Expected maxsize to be an integer or None Change-Id: I32d4fb6a0040a0c24da0b2f29f22f85a36c96531 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/388737 Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: Daniel Kutik <daniel.kutik@lavawerk.com> Commit-Queue: Daniel Kutik <daniel.kutik@lavawerk.com>
* git_command: Augment underlying git errors with suggestionsAravind Vasudevan2023-10-061-30/+136
| | | | | | | | | | | | | | | 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>
* Track expected git errors in logsJason Chang2023-09-271-0/+2
| | | | | | | | | | | | 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>
* Log ErrorEvent for failing GitCommandsJason Chang2023-09-061-11/+109
| | | | | | | | Change-Id: I270af7401cff310349e736bef87e9b381cc4d016 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/385054 Reviewed-by: Gavin Mak <gavinmak@google.com> Commit-Queue: Jason Chang <jasonnc@google.com> Tested-by: Jason Chang <jasonnc@google.com>
* isort: format codebasev2.36Mike Frysinger2023-08-221-2/+5
| | | | | | | | 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>
* Raise repo exit errors in place of sys.exitJason Chang2023-08-071-6/+15
| | | | | | | | | 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>
* Update errors to extend BaseRepoErrorJason Chang2023-07-311-2/+72
| | | | | | | | | | | | | | | | | | | 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>
* Format codebase with black and check formatting in CQGavin Mak2023-03-221-265/+296
| | | | | | | | | | | | 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>
* Fix flake8 warnings for some filesSergiy Belozorov2023-01-051-21/+21
| | | | | | | Change-Id: If67f8660cfb0479f0e710b3566285ef401fcf077 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/355969 Tested-by: Sergiy Belozorov <sergiyb@chromium.org> Reviewed-by: Mike Frysinger <vapier@google.com>
* Extract env building into a testable helper.v2.30Sam Saccone2022-11-161-29/+56
| | | | | | | | | | | | | Previously env dict building was untested and mixed with other mutative actions. Extract the dict building into a dedicated function and author tests to ensure the functionality is working as expected. BUG: b/255376186 BUG: https://crbug.com/gerrit/16247 Change-Id: I0c88e53eb285c5c3fb27f8e6b3a903aedb8e02a8 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/351874 Reviewed-by: LaMont Jones <lamontjones@google.com> Tested-by: Sam Saccone <samccone@google.com>
* Do not set ALT object dirs when said path resolves to the same dir.Sam Saccone2022-11-161-2/+4
| | | | | | | | | | | Due to symlink resolution git was treating this as two different directories even if the paths were the same. This mitigates the git core bug inside of repo (while the git core fix is being worked on). Bug: b/255376186 Bug: https://crbug.com/gerrit/16247 Change-Id: I12458ee04c307be916851dddd36231997bc8839e Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/351836 Tested-by: Sam Saccone <samccone@google.com> Reviewed-by: LaMont Jones <lamontjones@google.com>
* Set tracing to always on and save to .repo/TRACE_FILE.Joanna Wang2022-11-031-24/+23
| | | | | | | | | | | | - add `--trace_to_stderr` option so stderr will include trace outputs and any other errors that get sent to stderr - while TRACE_FILE will only include trace outputs piggy-backing on: https://gerrit-review.googlesource.com/c/git-repo/+/349154 Change-Id: I3895a84de4b2784f17fac4325521cd5e72e645e2 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/350114 Reviewed-by: LaMont Jones <lamontjones@google.com> Tested-by: Joanna Wang <jojwang@google.com>
* git_command: fix input passingMike Frysinger2022-08-221-6/+1
| | | | | | | | | | | | | | | | After reworking this function to use subprocess for output capturing in commit c87c1863b1df392042c8859b81475a65315c8a9d ("git_command: switch process capturing over to subprocess"), passing input via stdin write no longer works. We have to pass it via communicate(), and we have to pass it a string instead of bytes (since we always use encoding='utf-8' now). This is fine since the only user of the input= setting today is already passing in a string. Bug: https://crbug.com/gerrit/16151 Change-Id: Ic58db1e568b8f8aa840a6d62c5a157c14aa6d9bc Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/343515 Tested-by: Mike Frysinger <vapier@google.com> Reviewed-by: LaMont Jones <lamontjones@google.com>
* add a few more docs to existing funcsMike Frysinger2022-08-181-0/+2
| | | | | | | Change-Id: I27317a59aba67c05ca1fd333e8f064c0edccb209 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/343185 Reviewed-by: LaMont Jones <lamontjones@google.com> Tested-by: Mike Frysinger <vapier@google.com>
* project: store objects in project-objects directlyMike Frysinger2022-01-191-4/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In order to stop sharing objects/ directly between shared projects, we have to fetch the remote objects into project-objects/ manually. So instead of running git operations in the individual project dirs and relying on .git/objects being symlinked to project-objects/, tell git to store any objects it fetches in project-objects/. We do this by leveraging the GIT_OBJECT_DIRECTORY override. This has been in git forever, or at least since v1.7.2 which is what we already hard require. This tells git to save new objects to the specified path no matter where it's being run otherwise. We still otherwise run git in the project-specific dir so that it can find the right set of refs that it wants to compare against, including local refs. For that reason, we also have to leverage GIT_ALTERNATE_OBJECT_DIRECTORIES to tell git where to find objects that are not in the upstream remote. This way git doesn't blow up when it can't find objects only associated with local commits. As it stands right now, the practical result is the same: since we symlink the project objects/ dir to the project-objects/ tree, the default objects dir, the one we set $GIT_OBJECT_DIRECTORY to, and the one we set $GIT_ALTERNATE_OBJECT_DIRECTORIES to are actually all the same. So this commit by itself should be safe. But in a follow up commit, we can replace the symlink with a separate dir and git will keep working. Bug: https://crbug.com/gerrit/15553 Change-Id: Ie4e654aec3e1ee307eee925a54908a2db6a5869f Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/328100 Reviewed-by: Jack Neus <jackneus@google.com> Tested-by: Mike Frysinger <vapier@google.com>
* Add the ability to administratively enroll repo into using superproject.Xin Li2021-07-011-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Repo will remember a choice and an expiration time of the choice, per user, about whether to use superproject by default. When not specified from command line and the choice is not expired, repo would use the user default value. When a user default value is not present and when the system wide enable default is provided in git's system configuration, repo would ask the user for a confirmation which will be valid for two weeks. git_config.py: Add support for system config. When reading system config, we would use --system to avoid hardcoding a path as the value may be different on some other distributions. git_superproject.py: Add a new subroutine, _UseSuperproject(), which returns whether superproject should be used and whether it is from a user configuration. The value is determined in the following order: 1. If the user specifies either --use-superproject or --no-use-superproject, then that choice is being used. 2. If neither is specified, we would then check the saved value (upon repo init) and use that choice when there was a choice. 3. We then check if there is a saved and unexpired value for user's choice in their ~/.gitconfig, and use the unexpired choice, if available. 4. Finally, if all the above didn't give us a decision, and if the git system configuration is providing a rollout hint, present a prompt to user for their decision and save it in ~/.gitconfig. subcmds/sync.py: Make use of the new UseSuperproject() provided by git_superproject.py. While there also silent stderr from git describe when determining the version of repo. Bug: [google internal] b/190688390 Change-Id: Iad3ee03026342ee500e5d65e2f0fa600d7637613 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/309762 Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: Xin Li <delphij@google.com>
* ssh: rewrite proxy management for multiprocessing usagev2.15Mike Frysinger2021-05-101-6/+6
| | | | | | | | | | | | | | | | We changed sync to use multiprocessing for parallel work. This broke the ssh proxy code as it's all based on threads. Rewrite the logic to be multiprocessing safe. Now instead of the module acting as a stateful object, callers have to instantiate a new ProxyManager class that holds all the state, an pass that down to any users. Bug: https://crbug.com/gerrit/12389 Change-Id: I4b1af116f7306b91e825d3c56fb4274c9b033562 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/305486 Tested-by: Mike Frysinger <vapier@google.com> Reviewed-by: Chris Mcdonald <cjmcdonald@google.com>
* ssh: move all ssh logic to a common placeMike Frysinger2021-05-061-86/+5
| | | | | | | | | | | | We had ssh logic sprinkled between two git modules, and neither was quite the right home for it. This largely moves the logic as-is to its new home. We'll leave major refactoring to followup commits. Bug: https://crbug.com/gerrit/12389 Change-Id: I300a8f7dba74f2bd132232a5eb1e856a8490e0e9 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/305483 Reviewed-by: Chris Mcdonald <cjmcdonald@google.com> Tested-by: Mike Frysinger <vapier@google.com>
* git_command: switch version caches to functoolsMike Frysinger2021-05-061-19/+13
| | | | | | | | | Simplifies the code a bit to use the stdlib cache helper. Change-Id: I778e90100ce748a71cc3a5a5d67dda403334315e Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/305482 Reviewed-by: Raman Tenneti <rtenneti@google.com> Tested-by: Mike Frysinger <vapier@google.com>
* git_command: pass GIT_DIR on Windows with /Mike Frysinger2021-02-281-0/+3
| | | | | | | | | | | | | | | | | | | When using Git under Windows, it seems that Git doesn't always parse GIT_DIR correctly when it uses the Windows \ form, but does when it uses / only. For example, when using worktrees: $ GIT_DIR='C:\Users\vapier\Desktop\repo\breakpad\tools\test\.git' git worktree list fatal: not a git repository: ..\..\.repo\worktrees\linux-syscall-support.git\worktrees\test $ GIT_DIR='C:/Users/vapier/Desktop/repo/breakpad/tools/test/.git' git worktree list C:/Users/vapier/Desktop/repo/breakpad/.repo/worktrees/linux-syscall-support.git fd00dbbd0c06 (detached HEAD) ..\..\..\..\..\src\src\third_party\lss\.git fd00dbbd0c06 (detached HEAD) ..\..\..\..\..\tools\test\.git fd00dbbd0c06 (detached HEAD) Change-Id: I666c03ae845ecb55d7f9800731ea6987d3e7f401 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/298622 Reviewed-by: Michael Mortensen <mmortensen@google.com> Tested-by: Mike Frysinger <vapier@google.com>
* git_command: switch process capturing over to subprocessMike Frysinger2021-02-231-33/+7
| | | | | | | | | | | | Now that these code paths are all synchronous, there's no need to run our own poll loop to read & pass thru/save output. Delete all of that and just let the subprocess module take care of it all. Change-Id: Ic27fe71b6f964905cf280ce2b183bb7ee46f4a0d Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/297422 Reviewed-by: Michael Mortensen <mmortensen@google.com> Reviewed-by: Jonathan Nieder <jrn@google.com> Tested-by: Mike Frysinger <vapier@google.com>
* git_command: make execution synchronousMike Frysinger2021-02-201-6/+6
| | | | | | | | | | | | | Every use of GitCommand in the tree just calls Wait as soon as it's instantiated. Move the bulk of the logic into the init path to make the call synchronous to simplify. We'll cleanup the users of the Wait API to follup commits -- having this split makes it easier to track down regressions. Change-Id: I1e8c519efa912da723749ff7663558c04c1f491c Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/297244 Reviewed-by: Jonathan Nieder <jrn@google.com> Tested-by: Mike Frysinger <vapier@google.com>
* git_command: rework stdin handlingMike Frysinger2021-02-171-7/+7
| | | | | | | | | | | We only provide input to GitCommand in one place, so inline the logic to be more synchronous and similar to subprocess.run. This makes the code simpler and easier to understand. Change-Id: Ibe498fedf608774bae1f807fc301eb67841c468b Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/297142 Reviewed-by: Michael Mortensen <mmortensen@google.com> Tested-by: Mike Frysinger <vapier@google.com>
* git_command: use subprocess.run for version infoMike Frysinger2021-02-161-5/+4
| | | | | | | | | The code is a bit simpler & easier to reason about. Change-Id: If125ea7d776cdfa38a0440a2b03583de079c4839 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/297023 Reviewed-by: Michael Mortensen <mmortensen@google.com> Tested-by: Mike Frysinger <vapier@google.com>
* git_command.py: Handle unicode decode errorGaurav Pathak2021-01-281-1/+1
| | | | | | | | | | | | | | | | | repo diffmanifests saves git commit messages in buf and uses default utf-8 decoding, in some scenarios git commit message can itself contain a non UTF-8 character due to a typo or incorrect i18n.commitEncoding. e.g. d354d9afe923 [PATCH] fbcon: don\xb4t call set_par() in fbcon_init() if vc_mode == KD_GRAPHICS Convert the buf containing git commits to string if decoding to utf-8 encounters an error. Signed-off-by: Gaurav Pathak <gaurav.pathak@pantacor.com> Change-Id: If818562f0faaa5062c765fbea11dc0e1c86a24d7 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/294742 Reviewed-by: Mike Frysinger <vapier@google.com>
* strip python2-only coding:utf-8 & print_function settingsMike Frysinger2021-01-061-3/+0
| | | | | | | | | | We're committed to Python 3 at this point, so clean up boilerplate. Bug: https://crbug.com/gerrit/10418 Change-Id: Ib1719ba2eb65c53b94881a1a1bf203ddfcaaafed Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/292382 Reviewed-by: Chris Mcdonald <cjmcdonald@google.com> Tested-by: Mike Frysinger <vapier@google.com>
* Use hash for ControlPath instead of full variablesAnders Björklund2020-04-151-1/+35
| | | | | | | | | | | | | | | | | The generated socket path can be too long, if your FQDN is very long... Typical error message from ssh client: unix_listener: path "/tmp/ssh-fqduawon/master-USER@HOST:PORT.qfCZ51OAZgTzVLbg" too long for Unix domain socket Use a hashed version instead, to keep within the socket file path limit. This requires OpenSSH_6.7p1, or later. Change-Id: Ia4bb9ae8aac6c4ee31d5a458f917f3753f40001b Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/255632 Reviewed-by: Mike Frysinger <vapier@google.com> Reviewed-by: David Pursehouse <dpursehouse@collab.net> Tested-by: Anders Björklund <anders.bjorklund.2@volvocars.com>
* assume environment always accepts stringsMike Frysinger2020-02-191-13/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Different Python & OS versions have different environ behavior wrt accepted types & encoding. Since we're migrating to be Python 3 only, lets change our code to assume strings always work as that's what the newer Python 3 does. This will fail under Python 2 for some env vars, mostly on Windows, but the effort of maintaining shim layers that can handle these edge cases isn't worth it when we're dropping that code. We leave the logic in the `repo` launcher for now as it is simple, and we want it to be able to switch versions a bit longer than the rest of the tree. Here's the support table: | *NIX | Windows | Python 2 | ASCII string | str or bytes, not unicode | Python 3 | str or bytes | str only | Windows uses strings natively in its environment all the time. But it doesn't allow unicode strings under Python 2, so we have to encode. Python 2 on *NIX is funky in that it always lowers to ASCII, so we had to manually encode to avoid errors regardless of unicode or str. Python 3 on Windows & *NIX will accept strings. *NIX will also accept bytes but Windows will not. Bug: https://crbug.com/gerrit/12145 Change-Id: I3cf8f95a06902754ea1f08ad4b28503f7063531b Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/248972 Tested-by: Mike Frysinger <vapier@google.com> Reviewed-by: Michael Mortensen <mmortensen@google.com> Reviewed-by: Mike Frysinger <vapier@google.com>
* project: move successful fetch output behind verboseMike Frysinger2020-02-181-2/+6
| | | | | | | | | | | | | Syncing projects works fine the majority of the time. So rather than dump all of that noisy output to stdout, lets capture it and only show when things fail or in verbose mode. This tidies up the default `repo sync` output. Bug: https://crbug.com/gerrit/11293 Change-Id: I8314dd92e1e6aadeb26e36a8c92610da419684e6 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/255413 Reviewed-by: David Pursehouse <dpursehouse@collab.net> Tested-by: Mike Frysinger <vapier@google.com>
* Fix blank line issues reported by flake8David Pursehouse2020-02-121-0/+14
| | | | | | | | | | | | | | | | | | | | - E301 expected 1 blank line - E302 expected 2 blank lines - E303 too many blank lines - E305 expected 2 blank lines after class or function definition - E306 expected 1 blank line before a nested definition Fixed automatically with autopep8: git ls-files | grep py$ | xargs autopep8 --in-place \ --select E301,E302,E303,E305,E306 Manually fix issues in project.py caused by misuse of block comments. Change-Id: Iee840fcaff48aae504ddac9c3e76d2acd484f6a9 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/254599 Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: David Pursehouse <dpursehouse@collab.net>
* Fix indentation issues reported by flake8David Pursehouse2020-02-121-4/+4
| | | | | | | | | | | | | | | | | | | | | - E121 continuation line under-indented for hanging indent - E122 continuation line missing indentation or outdented - E125 continuation line with same indent as next logical line - E126 continuation line over-indented for hanging indent - E127 continuation line over-indented for visual indent - E128 continuation line under-indented for visual indent - E129 visually indented line with same indent as next logical line - E131 continuation line unaligned for hanging indent Fixed automatically with autopep8: git ls-files | grep py$ | xargs autopep8 --in-place \ --select E121,E122,E125,E126,E127,E128,E129,E131 Change-Id: Ifd95fb8e6a1a4d6e9de187b5787d64a6326dd249 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/254605 Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: David Pursehouse <dpursehouse@collab.net>
* Fix various whitespace issues reported by pyflakesDavid Pursehouse2020-02-121-1/+1
| | | | | | | | | | | | | | | | | | | | | | - E201 whitespace after '[' - E202 whitespace before '}' - E221 multiple spaces before operator - E222 multiple spaces after operator - E225 missing whitespace around operator - E226 missing whitespace around arithmetic operator - E231 missing whitespace after ',' - E261 at least two spaces before inline comment - E271 multiple spaces after keyword Fixed automatically with autopep8: git ls-files | grep py$ | xargs autopep8 --in-place \ --select E201,E202,E221,E222,E225,E226,E231,E261,E271 Change-Id: I367113eb8c847eb460532c7c2f8643f33040308c Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/254601 Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: David Pursehouse <dpursehouse@collab.net>
* Fix flake8 E251 unexpected spaces around keyword / parameter equalsDavid Pursehouse2020-02-121-13/+13
| | | | | | | | | | | Fixed automatically with autopep8: git ls-files | grep py$ | xargs autopep8 --in-place --select E251 Change-Id: I58009e1c8c91c39745d559ac919be331d4cd9e77 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/254598 Tested-by: David Pursehouse <dpursehouse@collab.net> Reviewed-by: Mike Frysinger <vapier@google.com>
* repo: lower min version of git a bitMike Frysinger2020-02-121-2/+11
| | | | | | | | | | | | | | | | | | | | | | We were perhaps a bit too hasty to jump to git-2.10. Existing LTS releases of Ubuntu are quite old still: Trusty has 1.9 while Xenial has 2.5. While we plan on dropping support for those eventually as we migrate to Python 3.6, we don't need to be so strict just yet on the git versions. We also want to disconnect the version the repo launcher requires from the version the rest of the source tree requires. The repo launcher doesn't need as many features, and being flexible there allows us more freedom to upgrade & rollback as needed. So we'll allow git-1.7 again, but start warning on any users older than git-1.9. This aligns better with existing LTS releases, and gives users a chance to start upgrading before we cut them off. Change-Id: I140305dd8e42c9719c84e2aee0dc6a5c5b18da25 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/254573 Reviewed-by: David Pursehouse <dpursehouse@collab.net> Tested-by: Mike Frysinger <vapier@google.com>
* repo: raise min version of gitMike Frysinger2020-02-051-1/+2
| | | | | | | | | | | | The git-2.10 series was released in 2016. Since we're moving to require Python 3.6 which was also released in 2016, bumping up the git version seems reasonable. Also we don't really test any git versions close to as old as 1.7.2 which was released in 2010. Change-Id: Ib71b714de6cd0b7dd50d0b300b108a560ee27331 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/253134 Tested-by: Mike Frysinger <vapier@google.com> Reviewed-by: David Pursehouse <dpursehouse@collab.net>
* git_command: set GIT_HTTP_USER_AGENT on all requestsMike Frysinger2019-10-011-0/+13
| | | | | | | | | | | | | | | | | We've been setting the User-Agent header when making connections from repo itself, but not when running git (as the latter will set up User-Agent itself). Our Gerrit/Git admins say it'll be helpful if we pass through the repo version settings even when running git. We currently set GIT_HTTP_USER_AGENT and not GIT_USER_AGENT as it's unclear if the extended form works over all protocols. We can wait for a user request. Bug: https://crbug.com/gerrit/11144 Change-Id: I21d293f49534058dbc23225152451df26c5b7bef Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/239233 Tested-by: Mike Frysinger <vapier@google.com> Reviewed-by: David Pursehouse <dpursehouse@collab.net>
* git_command: refactor User-Agent settingsMike Frysinger2019-10-011-49/+79
| | | | | | | | | | | | | | | Convert the RepoUserAgent function into a UserAgent class. This makes it cleaner to hold internal state, and will make it easier to add a separate git User-Agent, although we don't do it here. We make the RepoSourceVersion independent of GitCommand so that it can be called by the class (later). Bug: https://crbug.com/gerrit/11144 Change-Id: Iab4e1f974b8733a36b243b2d03f5085a96effa19 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/239232 Reviewed-by: David Pursehouse <dpursehouse@collab.net> Tested-by: Mike Frysinger <vapier@google.com>
* move UserAgent to git_command for wider userMike Frysinger2019-10-011-0/+46
| | | | | | | | | | | We can't import the main module, so move the UserAgent helper out of it and into the git_command module so it can be used in more places. Bug: https://crbug.com/gerrit/11144 Change-Id: I8093c8a20bd1dc7d612d0e2a85180341817c0d86 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/231057 Tested-by: Mike Frysinger <vapier@google.com> Reviewed-by: David Pursehouse <dpursehouse@collab.net>
* rename local trace moduleMike Frysinger2019-08-271-1/+1
| | | | | | | | | | There is a standard Python "trace" module, so having a local trace.py prevents us being able to import that. Rename the module to avoid. Change-Id: I23e29ec95a2204bb168a641323d05e76968d9b57 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/234832 Reviewed-by: David Pursehouse <dpursehouse@collab.net> Tested-by: Mike Frysinger <vapier@google.com>
* Add support for partial clone.v1.13.4Xin Li2019-07-161-2/+4
| | | | | | | | | | | | | A new option, --partial-clone is added to 'repo init' which tells repo to utilize git's partial clone functionality, which reduces disk and bandwidth usage when downloading by omitting blob downloads initially. Different from restricting clone-depth, the user will have full access to change history, etc., as the objects are downloaded on demand. Change-Id: I60326744875eac16521a007bd7d5481112a98749 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/229532 Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: Xin Li <delphij@google.com>
* git_command: drop custom version helperMike Frysinger2019-07-111-12/+2
| | | | | | | | | | | | Since ParseGitVersion can call `git --version` automatically, we don't need this duplicate version() helper anymore. The only other user is the `repo version` code, so convert that to version_tuple().full. Bug: https://crbug.com/gerrit/11144 Change-Id: I9d77822fc39f4ba28884d9183359169cabf5f17d Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/231055 Reviewed-by: David Pursehouse <dpursehouse@collab.net> Tested-by: Mike Frysinger <vapier@google.com>
* set default file encoding to utf-8Mike Frysinger2019-06-131-0/+1
| | | | | | | | There's no reason to support any other encoding in these files. This only affects the files themselves and not streams they open. Bug: https://crbug.com/gerrit/10418 Change-Id: I053cb40cd3666ce5c8a0689b9dd938f24ca765bf
* Set GIT_SSH_VARIANT when setting GIT_SSHJonathan Nieder2017-10-191-0/+1
| | | | | | | | | | | | | | | | | | | | Make it explicit that the ssh wrapper we use for control master support accepts OpenSSH-compatible command line arguments instead of asking Git to guess. The GIT_SSH_VARIANT setting was introduced in Git v2.13.0-rc0~3^2~2 (2017-02-01) as a more reliable detection method than relying on the ssh command name. Fortunately the default variant was 'ssh' (i.e., OpenSSH-compatible) so this wasn't initially required. Now Git wants to start using more OpenSSH features (-o SendEnv=GIT_PROTOCOL), and in order to do so its ssh variant detection will need to be tweaked. Set GIT_SSH_VARIANT explicitly so this helper can continue to work regardless of how Git modifies its autodetection. Reported-by: William Yan <wyan@google.com> Change-Id: I6bf2c53b4eb5303a429eae6cb68e0a5ccce89064