summaryrefslogtreecommitdiffstats
path: root/tests/test_git_command.py
Commit message (Collapse)AuthorAgeFilesLines
* 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>
* isort: format codebasev2.36Mike Frysinger2023-08-221-1/+2
| | | | | | | | 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-2/+2
| | | | | | | | | 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-0/+51
| | | | | | | | | | | | | | | | | | | 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-107/+115
| | | | | | | | | | | | 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>
* Fixed wrapper related warnings in testsDaniel Kutik2022-11-281-1/+2
| | | | | | | | | | | Multiple "Could not find reference" warnings in test_wrapper.py and test_git_command.py resolved. Test: tox Signed-off-by: Daniel Kutik <daniel.kutik@lavawerk.com> Change-Id: Ic254c378bbdae6bc3f8f29682ababb37db76adfe Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/353235 Reviewed-by: Mike Frysinger <vapier@google.com>
* test: fix path seperator errors on windowsDaniel Kutik2022-11-271-5/+5
| | | | | | | | | | Fixing multiple errors when running tests on Windows related to path seperator being different ('\' instead of '/'). Signed-off-by: Daniel Kutik <daniel.kutik@lavawerk.com> Change-Id: I26b44d092b925edecab46a4d88e77dd9dcb8df28 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/353178 Reviewed-by: Mike Frysinger <vapier@google.com>
* Extract env building into a testable helper.v2.30Sam Saccone2022-11-161-0/+33
| | | | | | | | | | | | | 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>
* ssh: move all ssh logic to a common placeMike Frysinger2021-05-061-32/+0
| | | | | | | | | | | | 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-2/+7
| | | | | | | | | 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>
* strip python2-only coding:utf-8 & print_function settingsMike Frysinger2021-01-061-4/+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-0/+27
| | | | | | | | | | | | | | | | | 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>
* tests: add git_require coverageMike Frysinger2020-02-201-0/+48
| | | | | | | Change-Id: I0c8fb45f6d5808caf361240a3a0b68eef670eeaa Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/256112 Reviewed-by: David Pursehouse <dpursehouse@collab.net> Tested-by: Mike Frysinger <vapier@google.com>
* repo: raise min version of gitMike Frysinger2020-02-051-1/+1
| | | | | | | | | | | | 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/+8
| | | | | | | | | | | | | | | | | 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-5/+13
| | | | | | | | | | | | | | | 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/+13
| | | | | | | | | | | 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>
* tests: add docstrings & print_function (for Python 3)Mike Frysinger2019-08-011-0/+4
| | | | | | | | Bug: https://crbug.com/gerrit/10418 Change-Id: Id98183597a9b0201ca98ec0bf5033a5f5ac6bda2 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/232892 Tested-by: Mike Frysinger <vapier@google.com> Reviewed-by: David Pursehouse <dpursehouse@collab.net>
* git_command: drop custom version helperMike Frysinger2019-07-111-0/+45
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>