summaryrefslogtreecommitdiffstats
path: root/subcmds
Commit message (Collapse)AuthorAgeFilesLines
...
* resort a few module imports to follow PEP8Mike Frysinger2020-02-182-6/+7
| | | | | | | | | All the stdlib imports are supposed to come before any local imports. Change-Id: I10c0335ba2ff715fd34c9eb91bfe6560e904df08 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/255593 Tested-by: Mike Frysinger <vapier@google.com> Reviewed-by: David Pursehouse <dpursehouse@collab.net>
* diff: delete unused nested funcMike Frysinger2020-02-171-4/+0
| | | | | | | Change-Id: I43ab4bc944269e43a6cd7b2ac350c09b7c700a6c Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/255492 Tested-by: Mike Frysinger <vapier@google.com> Reviewed-by: David Pursehouse <dpursehouse@collab.net>
* sync: introduce --verbose optionMike Frysinger2020-02-171-3/+10
| | | | | | | | | | | | | This allows us to control sync output better by having three levels of output: quiet (only errors), default (progress bars), verbose (all the things). For now, we just put the chatty "already have persistent ref" message behind the verbose level. Bug: https://crbug.com/gerrit/11293 Change-Id: Ia61333fd8085719f3e99edb7b466cdb04031b67f Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/255414 Reviewed-by: David Pursehouse <dpursehouse@collab.net> Tested-by: Mike Frysinger <vapier@google.com>
* flake8: Suppress "F821 undefined name" inline for Python 2 namesDavid Pursehouse2020-02-152-2/+2
| | | | | | | | | | | | | | | | All of the instances of this are related to Python 2 names that don't exist in Python 3, and the warnings are raised when running flake8 on Python 3. All of these will go away once we completely remove support for Python 2, so just suppress them inline. We don't globally suppress the check so that we will still see legitimate errors if/when they occur in new code. Change-Id: Iccf955f50abfc9f83b371fc0af6cceb51037456f Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/255039 Tested-by: David Pursehouse <dpursehouse@collab.net> Reviewed-by: Mike Frysinger <vapier@google.com>
* pyflakes: Fix remaining "E501 line too long" warningsDavid Pursehouse2020-02-132-2/+4
| | | | | | | | | | | We increased the max line length to 100 columns which got rid of the majority of these warnings, but there were still a few lines that exceeded 100 columns. Change-Id: Ib3372868ca2297f83073a14f91c8ae3df9d0d0e6 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/254699 Tested-by: David Pursehouse <dpursehouse@collab.net> Reviewed-by: Mike Frysinger <vapier@google.com>
* sync: add a "finished" messageMike Frysinger2020-02-121-0/+3
| | | | | | | | | | | | | Some people find the existing output to be a bit confusing. It spews a lot of git output before exiting, but it's not exactly clear what the final state is when things pass. Add an explicit message. Bug: https://crbug.com/gerrit/10501 Change-Id: I9de83b595d3185feb820005b8fc81c6adc55b357 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/254732 Reviewed-by: Michael Mortensen <mmortensen@google.com> Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: Mike Frysinger <vapier@google.com>
* drop old git_require checksMike Frysinger2020-02-122-4/+3
| | | | | | | | | | We've been requiring git-1.7.2 since Oct 2012, so we can safely drop the individual checks sprinkled throughout the code base for older. Change-Id: I1737fff7b3f27f475960b0bff9cb300aefd5d108 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/253135 Reviewed-by: David Pursehouse <dpursehouse@collab.net> Tested-by: Mike Frysinger <vapier@google.com>
* Fix usage of bare 'except'David Pursehouse2020-02-121-1/+1
| | | | | | | | | | | | | | | | | | | | | | flake8 reports: E722 do not use bare 'except' Replace them with 'except Exception' per [1] which says: Bare except will catch exceptions you almost certainly don't want to catch, including KeyboardInterrupt (the user hitting Ctrl+C) and Python-raised errors like SystemExit If you don't have a specific exception you're expecting, at least except Exception, which is the base type for all "Regular" exceptions. [1] https://stackoverflow.com/a/54948581 Change-Id: Ic555ea9482645899f5b04040ddb6b24eadbf9062 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/254606 Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: David Pursehouse <dpursehouse@collab.net>
* Fix blank line issues reported by flake8David Pursehouse2020-02-1224-2/+44
| | | | | | | | | | | | | | | | | | | | - 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-1211-75/+75
| | | | | | | | | | | | | | | | | | | | | - 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-129-16/+16
| | | | | | | | | | | | | | | | | | | | | | - 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>
* Remove redundant backslashesDavid Pursehouse2020-02-123-5/+5
| | | | | | | | | | | | | | | fleka8 reports: E502 the backslash is redundant between brackets Fixed automatically with autopep8: git-repo $ git ls-files | grep py$ | xargs autopep8 --in-place --select E502 Change-Id: I1486ae1d17206918474363daf518274c5be8daed Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/254602 Tested-by: David Pursehouse <dpursehouse@collab.net> Reviewed-by: Mike Frysinger <vapier@google.com>
* Remove unused importsDavid Pursehouse2020-02-121-1/+0
| | | | | | | | | | | flake8 reports: F401 'name' imported but unused Change-Id: Id45d6efa87ddf53f2c4a0f0c4136ea361ab1b746 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/254592 Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: David Pursehouse <dpursehouse@collab.net>
* Fix tests for membership to use 'not in'David Pursehouse2020-02-122-2/+2
| | | | | | | | | | | flake8 reports: E713 test for membership should be 'not in' Change-Id: I4446be67c431b7267105b53478d2ceba2af758d7 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/254451 Tested-by: David Pursehouse <dpursehouse@collab.net> Reviewed-by: Mike Frysinger <vapier@google.com>
* upload: Fix tests for object identity to use 'is not'David Pursehouse2020-02-121-2/+2
| | | | | | | | | | | flake8 reports: E714 test for object identity should be 'is not' Change-Id: Ib8c4100babaf952bbfe65fd56555ece8a958e4b0 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/254450 Tested-by: David Pursehouse <dpursehouse@collab.net> Reviewed-by: Mike Frysinger <vapier@google.com>
* Fix flake8 E251 unexpected spaces around keyword / parameter equalsDavid Pursehouse2020-02-128-41/+41
| | | | | | | | | | | 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>
* upload: Fix flake8 E241 multiple spaces after ','David Pursehouse2020-02-121-3/+3
| | | | | | | Change-Id: I3a65869f9d006027270a7826d7982950c0e6759a Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/254597 Tested-by: David Pursehouse <dpursehouse@collab.net> Reviewed-by: Mike Frysinger <vapier@google.com>
* info: Fix formatting of block commentDavid Pursehouse2020-02-121-1/+1
| | | | | | | | | | | | | flake8 reports: E265 block comment should start with '# ' While we're at it, add a period at the end of the comment sentence. Change-Id: Icb7119079a1d64e6defafc3f6d24e99dbf16139d Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/254596 Tested-by: David Pursehouse <dpursehouse@collab.net> Reviewed-by: Mike Frysinger <vapier@google.com>
* upload: add a --ignore-hooks optionMike Frysinger2020-02-121-6/+22
| | | | | | | | | | | | | | | | When upload hooks fail, people are forced to use --no-verify to upload CLs anyways. When projects have flaky hooks, this trains people to always use that option. This is obviously bad: hooks might get fixed, or some of the hooks are always good & people should review. Lets add an --ignore-hooks option. This still runs the hooks, but any failures will be ignored and allow the user to upload anyways. Bug: https://crbug.com/gerrit/12230 Change-Id: Ide2ac8a40a656bfcd6aae20c3ce8118e06bf909b Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/254452 Tested-by: Mike Frysinger <vapier@google.com> Reviewed-by: David Pursehouse <dpursehouse@collab.net>
* Remove trailing blank linesDavid Pursehouse2020-02-121-1/+0
| | | | | | | | | | | flake8 reports: W391 blank line at end of file Change-Id: I5498b2de2d1268d4f1f4b9e1760f9fa93a6da4cd Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/254594 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/+7
| | | | | | | | | | | | | | | | | | | | | | 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>
* sync: change how we preserve objects in shared reposMike Frysinger2020-02-111-2/+13
| | | | | | | | | | | | | | | | | | | Some automatic git operations will prune objects on us, and not just the gc step. Normally we don't care, but with shared projects, we will have multiple git checkouts with refs that the others cannot see, but with a shared object dir. Any pruning of objects based on refs in just one repo can easily break the others. git-2.7.0 introduced a preciousObjects setting which tells git to never prune objects for this exact scenario: there might be refs in some location that git is unable to see. Change-Id: I781de27c5bbe1d4c70f0187566141c9cce088bd8 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/254392 Reviewed-by: Nasser Grainawi <nasser@codeaurora.org> Reviewed-by: David Riley <davidriley@google.com> Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: Mike Frysinger <vapier@google.com>
* Fixing forall subcommand for Py3v2.0Jiri Tyr2020-02-101-1/+1
| | | | | | | | | | | | | | | | Execution of 'repo forall -p -c' doesn't work with Py3 and ends up with an error: Got an error, terminating the pool: TypeError: can only concatenate str (not "bytes") to str That's fixed by using the decode() method. Change-Id: Ice01aaa1822dde8d957b5bf096021dd5a2b7dd51 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/253659 Reviewed-by: Mike Frysinger <vapier@google.com> Reviewed-by: David Pursehouse <dpursehouse@collab.net> Tested-by: Jiri Tyr <jiri.tyr@gmail.com>
* remove spurious +x bitsMike Frysinger2020-02-091-0/+0
| | | | | | | | | These files are not directly executable, so drop the +x bits. Change-Id: Iaf19a03a497686cc21103e7ddf08073173440dd1 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/254076 Tested-by: Mike Frysinger <vapier@google.com> Reviewed-by: David Pursehouse <dpursehouse@collab.net>
* Fix inverted logic around [gitc-]init and -cDan Willemsen2020-02-071-1/+1
| | | | | | | | | | | | | Instead of not using '-c' for '--current-branch' when using gitc, we were only using '-c' when using gitc, so we still had the conflict with the gitc option, and other users still couldn't use '-c'. Test: repo init -u https://android.googlesource.com/platform/manifest; repo init -c Test: repo gitc-init -u ... -b ... -c testing Change-Id: I71e4950a49c281418249f0783c6a2ea34f0d3e2b Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/253795 Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: Dan Willemsen <dwillemsen@google.com>
* sync: try to checkout repos across sync failuresMike Frysinger2020-02-051-29/+57
| | | | | | | | | | | | | | | | | | | | | | Currently our default behavior is: * Try to sync all repos * If any errors seen, exit * Try to garbage collect all repos * If any errors seen, exit * Try to update local project list * If any errors seen, exit * Try to checkout out all local repos * If any errors seen, exit Users find these incomplete syncs confusing, so lets try to complete as much as possible by default and printing out summaries at the end. Bug: https://crbug.com/gerrit/11293 Change-Id: Idd17cc9c3bbc574d8a0f08a30225dec7bfe414cb Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/238554 Reviewed-by: Michael Mortensen <mmortensen@google.com> Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: Mike Frysinger <vapier@google.com>
* sync: add option to skip manifest updateFredrik de Groot2020-02-051-1/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | The use case is any situation where your manifest does not exist on server, but where you still want to do full sync for the projects, without having your workspace manifest switched to other branch or forwarded to latest or similar. This allows syncing to a historical manifest in git log, that does not have a branch, as well as when integrating something together that has not been pushed upstream yet. Changes can also exist locally on a manifest that is behind head, meaning not requiring rebase to latest. Tested using: $ cd .repo/manifests/ $ git checkout <any hash 1> $ <do local modifications> $ repo sync --no-manifest-update $ git checkout <any hash 2> $ repo sync --no-manifest-update Change-Id: I0c9773aa8bc5876813a2e7d7fec697abcb2d9e94 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/246445 Tested-by: Fredrik de Groot <fredrik.de.groot@volvocars.com> Reviewed-by: Mike Frysinger <vapier@google.com>
* init: handle -c conflicts with gitc-initMike Frysinger2020-02-052-3/+8
| | | | | | | | | | | | We keep getting requests for init to support -c. This conflicts with gitc-init which allocates -c for its own use. Lets make this dynamic so we keep it with "init" but omit it for "gitc-init". Bug: https://crbug.com/gerrit/10200 Change-Id: Ibf69c2bbeff638e28e63cb08926fea0c622258db Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/253252 Reviewed-by: David Pursehouse <dpursehouse@collab.net> Tested-by: Mike Frysinger <vapier@google.com>
* init: Add '-c' as an alias to '--current-branch'Diogo Ferreira2020-01-241-1/+1
| | | | | | | | | | | This makes it consistent with the short option for current-branch in repo sync. Change-Id: I2848e87f45a66ef8d829576d0c0c4c0f7a8636a0 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/241700 Tested-by: Diogo Ferreira <deovferreira@gmail.com> Reviewed-by: David Pursehouse <dpursehouse@collab.net> Reviewed-by: Mike Frysinger <vapier@google.com>
* info: Add the manifest revisionDiogo Ferreira2020-01-241-0/+4
| | | | | | | | | | | | | | After Ib546f5ebbc8a23875fbd14bf166fbe95b7dd244e, repo info now displays the current project revision in the 'Current revision' field. While the output is more consistent, there are use cases for the revision expression as shown in the manifest. This patch re-adds the manifest revision as a new 'Manifest revision' field. Change-Id: I50c1559dcb7ceb69af07352b956d78f85b8f592e Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/240799 Tested-by: Diogo Ferreira <deovferreira@gmail.com> Reviewed-by: Mike Frysinger <vapier@google.com>
* help: unify command displayMike Frysinger2019-12-031-17/+9
| | | | | | | | | No functional changes, just unifying duplicate code paths. Change-Id: I6afa797ca1e1eb90abdc0236325003ae070cbfb3 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/247293 Reviewed-by: David Pursehouse <dpursehouse@collab.net> Tested-by: Mike Frysinger <vapier@google.com>
* upload/editor: fix bytes/string confusionMike Frysinger2019-11-161-5/+0
| | | | | | | | | | | | | | | | The upload module tries to turn the strings into bytes before passing to EditString, but it combines bytes & strings causing an error. The return value might be bytes or string, but the caller only expects a string. Lets simplify this by sticking to strings everywhere and have EditString take care of converting to/from bytes when reading/writing the underlying files. This also avoids possible locale confusion when reading the file by forcing UTF-8 everywhere. Bug: https://crbug.com/gerrit/11929 Change-Id: I07b146170c5e8b5b0500a2c79e4213cd12140a96 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/245621 Reviewed-by: David Pursehouse <dpursehouse@collab.net> Tested-by: Mike Frysinger <vapier@google.com>
* prune: handle branches that track missing branchesMike Frysinger2019-11-161-4/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | Series of steps: * Create a local "b1" branch with `repo start b1` that tracks a remote branch (totally fine) * Manually create a local "b2" branch with `git branch --track b1 b2` that tracks the local "b1" (uh-oh...) * Delete the local "b1" branch manually or via `repo prune` (....) * Try to process the "b2" branch with `repo prune` Since b2 tracks a branch that no longer exists, everything blows up at this point as we try to probe the non-existent ref. Instead, we should flag this as unknown and leave it up to the user to resolve. This probably could come up if a local branch was tracking a remote branch that was deleted from the server, and users ran something like `repo sync --prune` which cleaned up the remote refs. Bug: https://crbug.com/gerrit/11485 Change-Id: I6b6b6041943944b8efa6e2ad0b8b10f13a75a5c2 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/236793 Reviewed-by: David Pursehouse <dpursehouse@collab.net> Reviewed-by: Kirtika Ruchandani <kirtika@google.com> Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: Mike Frysinger <vapier@google.com>
* sync: merge project updates with status barMike Frysinger2019-11-121-11/+4
| | | | | | | | | | | | | | The current sync output displays "Fetching project" and "Checking out project" messages and progress bar updates independently leading to a lot of spam. Lets merge these periodic outputs with the status bar to get a little bit tighter output in the normal case. This doesn't solve all our problems, but gets us closer. Bug: https://crbug.com/gerrit/11293 Change-Id: Icd627830af4dd934a9355b7ace754b56dc96cfef Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/244934 Reviewed-by: David Pursehouse <dpursehouse@collab.net> Tested-by: Mike Frysinger <vapier@google.com>
* sync: report list of failing git treesVadim Bendebury2019-11-121-2/+11
| | | | | | | | | | | | | | | | | | When repo sync fails because some git trees are not in clean state and as such can not be rebased automatically, it is a pain to figure out which trees are the culprits. With this patch the list of offending trees is printed when repo sync reports checkout errors. TEST=ran 'repo sync' and observed the proper list of directories show up after the final error message Bug: https://crbug.com/gerrit/11293 Change-Id: Icdf1a03e9014ecb184f331f513cc9a2efc7d11ed Signed-off-by: Vadim Bendebury <vbendeb@google.com> Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/244053 Reviewed-by: Mike Frysinger <vapier@google.com>
* use open context managers in more placesMike Frysinger2019-11-122-24/+8
| | | | | | | | | | Use open() as a context manager to simplify the close logic and make the code easier to read & understand. This is also more Pythonic. Change-Id: I579d03cca86f99b2c6c6a1f557f6e5704e2515a7 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/244734 Reviewed-by: David Pursehouse <dpursehouse@collab.net> Tested-by: Mike Frysinger <vapier@google.com>
* forall: add an --ignore-missing optionv1.13.7.1Mike Frysinger2019-10-221-0/+7
| | | | | | | | | | | | | | | In CrOS, our infra has to deal with partial checkouts constantly (for a variety of reasons). To help reset back to a good state, we run git commands via `repo forall`, but don't care about the missing checkouts. Add a flag so we can disambiguate between missing repos and failing git subcommands. Bug: https://crbug.com/1013377 Bug: https://crbug.com/1013623 Change-Id: Ie3498c6d111276c60d2ecedbba21bfa778588d50 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/241935 Reviewed-by: David Pursehouse <dpursehouse@collab.net> Tested-by: Mike Frysinger <vapier@google.com>
* info: fix "current" outputMike Frysinger2019-10-051-2/+8
| | | | | | | | | | | | | The "Current revision" field shows the revision as listed in the manifest. I think most users expect this to show the revision that the git tree is checked out to instead. Switch the output to show that revision instead, and add a "Current branch" if it matches a local branch. Change-Id: Ib546f5ebbc8a23875fbd14bf166fbe95b7dd244e Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/239240 Reviewed-by: David Pursehouse <dpursehouse@collab.net> Tested-by: Mike Frysinger <vapier@google.com>
* info: allow NoSuchProjectError to bubble upMike Frysinger2019-10-011-5/+2
| | | | | | | | | | | If the user passes in bad projects like `repo info asdf`, we currently silently swallow those and do nothing. Allow NoSuchProjectError to bubble up to main which will handle & triage this correctly for us. Change-Id: Ie04528e7b7a164293063a636813a73eaabdd5bc3 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/239238 Reviewed-by: David Pursehouse <dpursehouse@collab.net> Tested-by: Mike Frysinger <vapier@google.com>
* version: add source versions & User-Agents to the outputMike Frysinger2019-10-011-2/+10
| | | | | | | | | | | | | | | | Depending on where/how repo is invoked, the active version might be from a git tree, and it might be different from the .repo/repo.git/ version in the current repo client checkout. Report both if they're different so it's clearer. Lets also include the two different User-Agent's that we set up when talking to networked services. Bug: https://crbug.com/gerrit/11144 Change-Id: I2ebb6e3ac30e374a8406cab3e4438087246a8c57 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/239234 Reviewed-by: David Pursehouse <dpursehouse@collab.net> Tested-by: Mike Frysinger <vapier@google.com>
* grep: handle errors gracefullyMike Frysinger2019-10-011-7/+23
| | | | | | | | | | | | If `git grep` fails in any project checkout (e.g. an incomplete sync), make sure we print that error clearly rather than blowing up, and exit non-zero in the process. Bug: https://crbug.com/gerrit/11613 Change-Id: I31de1134fdcc7aaa9814cf2eb6a67d398eebf9cf Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/239237 Reviewed-by: David Pursehouse <dpursehouse@collab.net> Tested-by: Mike Frysinger <vapier@google.com>
* diff: handle errors gracefullyMike Frysinger2019-10-011-1/+4
| | | | | | | | | | | | If `git diff` fails in any project checkout (e.g. an incomplete sync), make sure we print that error clearly rather than blowing up, and exit non-zero in the process. Bug: https://crbug.com/gerrit/11613 Change-Id: I12f278427cced20f23f8047e7e3dba8f442ee25e Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/239236 Reviewed-by: David Pursehouse <dpursehouse@collab.net> Tested-by: Mike Frysinger <vapier@google.com>
* forall: exit 1 if we skip any reposMike Frysinger2019-10-011-3/+3
| | | | | | | | | | If a repo doesn't exist (e.g. an incomplete sync), make sure we exit non-zero when they get skipped. Change-Id: Ifff711e374416b1e6b9b8da4fdc6f14b27ced450 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/239235 Reviewed-by: David Pursehouse <dpursehouse@collab.net> Tested-by: Mike Frysinger <vapier@google.com>
* rebase: add basic coloring outputMike Frysinger2019-09-241-3/+20
| | | | | | | | | This uses coloring style like we use in grep/forall already. Change-Id: I317e2e47567a30c513083c48e7c7c40b091bb29a Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/238555 Reviewed-by: David Pursehouse <dpursehouse@collab.net> Tested-by: Mike Frysinger <vapier@google.com>
* rebase: add --fail-fast supportMike Frysinger2019-09-241-3/+16
| | | | | | | | | | | | Lets switch the default rebase behavior to align with our new sync behavior: we try to rebase all projects by default and exit/summarize things at the very end if there were any errors. Or if people want to exit immediately, they can use the new --fail-fast option. Change-Id: I436ac563f972b45de6ce9ad74da1e4870e584902 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/238553 Reviewed-by: David Pursehouse <dpursehouse@collab.net> Tested-by: Mike Frysinger <vapier@google.com>
* sync: create dedicated manifest project update funcMike Frysinger2019-09-191-24/+28
| | | | | | | | | | | Cut out some more standalone code from Execute to make this func a bit more manageable. The manifest project update is pretty simple and standalone, but still takes up a good chunk of what's left. Change-Id: Idc2442d9def495eccd0a49cda203c44aef16f129 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/236614 Tested-by: Mike Frysinger <vapier@google.com> Reviewed-by: David Pursehouse <dpursehouse@collab.net>
* sync: create dedicated smart sync funcMike Frysinger2019-09-111-96/+100
| | | | | | | | | | | | The smart sync logic takes up about 45% of the overall Execute func and is about 100 lines of code. The only effect it has on the rest of the code is to set the manifest_name variable. Since this func is already quite huge, split the smart sync logic out. Change-Id: Id861849b0011ab47387d74e92c2ac15afcc938ba Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/234835 Tested-by: Mike Frysinger <vapier@google.com> Reviewed-by: David Pursehouse <dpursehouse@collab.net>
* Add repo start option to create the branch based off HEADTheodore Dubois2019-09-041-1/+6
| | | | | | | | | | | | This makes it way easier to recover from forgetting to run repo start before committing: just run `repo start -b new-branch`, instead of all that tedious mucking around with reflogs. Change-Id: I56d49dce5d027e28fbba0507ac10cd763ccfc36d Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/232712 Reviewed-by: Mike Frysinger <vapier@google.com> Reviewed-by: David Pursehouse <dpursehouse@collab.net> Tested-by: Mike Frysinger <vapier@google.com>
* sync: fix deprecated command line option -fv1.13.5.1Stefan Müller-Klieser2019-08-301-0/+1
| | | | | | | | | | | | | | | | | In commit d9e5cf0e ("sync: invert --force-broken with --fail-fast") the force-broken option has been deprecated. Accidentally the option has been changed from Boolean to Value. This breaks all users of repo with: main.py: error: -f option requires an argument This is easy to avoid by keeping the type. Signed-off-by: Stefan Müller-Klieser <s.mueller-klieser@phytec.de> Change-Id: Ia8b589cf41ac756d10c61e17ec8d76ba8f7031f9 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/235043 Reviewed-by: David Pursehouse <dpursehouse@collab.net> Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: Mike Frysinger <vapier@google.com>
* split out cli validation from executionv1.13.5Mike Frysinger2019-08-2810-52/+44
| | | | | | | | | | | | | | | | | | | A common pattern in our subcommands is to verify the arguments & options before executing things. For some subcommands, that check stage is quite long which makes the execution function even bigger. Lets split that logic out of the execute phase so it's easier to manage these. This is most noticeable in the sync subcommand whose Execute func is quite large, and the option checking makes up ~15% of it. The manifest command's Execute can be simplified significantly as the optparse configuration always sets output_file to a string. Change-Id: I7097847ff040e831345e63de6b467ee17609990e Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/234834 Reviewed-by: David Pursehouse <dpursehouse@collab.net> Tested-by: Mike Frysinger <vapier@google.com>