summaryrefslogtreecommitdiffstats
path: root/subcmds
Commit message (Collapse)AuthorAgeFilesLines
* Move RepoHook class from project.py file to dedicated fileRemy Bohmer2020-11-031-1/+1
| | | | | | | | | | | | The project.py file is huge and contains multiple classes. By moving it to seperate class files the code becomes more readable and maintainable. Signed-off-by: Remy Bohmer <github@bohmer.net> Change-Id: Ida9d99d31751d627ae1ea0373418080696d2e14b Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/281293 Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: Remy Bohmer <linux@bohmer.net>
* init: use the remote default manifest branchMike Frysinger2020-09-091-11/+15
| | | | | | | | | | | | | | | | Instead of hardcoding "master" as our default, use the remote server's default branch instead. For most people, this should be the same as "master" already. For projects moving to "main", it means we'll use the new name automatically rather than forcing people to use -b main. For repositories that never set up a default HEAD, we should still use the historical "master" default. Bug: https://crbug.com/gerrit/13339 Change-Id: I4117c81a760c9495f98dbb1111a3e6c127f45eba Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/280799 Reviewed-by: Michael Mortensen <mmortensen@google.com> Tested-by: Mike Frysinger <vapier@google.com>
* status: Use multiprocessing for `repo status -j<num>` instead of threadingKimiyuki Onaka2020-09-091-33/+15
| | | | | | | | | | | | | This change increases the speed of the command with parallelization with processes. The parallelization with threads doesn't work well, and increasing the number of jobs to many (8 threads ~) didn't increase the speed. Possibly, the global interpreter lock of Python affects. Bug: https://crbug.com/gerrit/12389 Change-Id: Icbe5df8ba037dd91422b96f4e43708068d7be924 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/279936 Tested-by: Kimiyuki Onaka <kimiyuki@google.com> Reviewed-by: Mike Frysinger <vapier@google.com>
* manifest: drop support for local_manifest.xmlMike Frysinger2020-09-081-1/+1
| | | | | | | | | | We deprecated this 8 years ago. Time to drop it to simplify the code as it'll help with refactoring in this module to not migrate it. Change-Id: I2deae5496d1f66a4491408fcdc95cd527062f8b6 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/280798 Tested-by: Mike Frysinger <vapier@google.com> Reviewed-by: Michael Mortensen <mmortensen@google.com>
* init: reject unknown argsMike Frysinger2020-09-021-0/+3
| | | | | | | | | | | If you pass args to `repo init` when first creating a checkout, the repo launcher throws an error. But the init subcommand that runs in an existing checkout silently ignores them. Throw a proper error. Change-Id: I433bfcc73902d25f6b6a2974e77f6a977a75ed16 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/279696 Reviewed-by: Jonathan Nieder <jrn@google.com> Tested-by: Mike Frysinger <vapier@google.com>
* upload: exit non-zero when preupload hooks failMike Frysinger2020-07-251-1/+1
| | | | | | | | Bug: https://crbug.com/gerrit/13159 Change-Id: Id140b619242c841223c6bc5d4aa0c37a7ce0219d Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/276294 Reviewed-by: Jonathan Nieder <jrn@google.com> Tested-by: Mike Frysinger <vapier@google.com>
* subcmds/sync.py: Fix typo in helpRoger Shimizu2020-06-061-1/+1
| | | | | | | | Change-Id: I70b63477241284249e395b8b0a220cb6f44f836b Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/270183 Reviewed-by: Mike Frysinger <vapier@google.com> Reviewed-by: David Pursehouse <dpursehouse@digital.ai> Tested-by: David Pursehouse <dpursehouse@digital.ai>
* sync: fix duplicate word in descriptionMike Frysinger2020-05-241-1/+1
| | | | | | | | Bug: https://crbug.com/gerrit/12814 Change-Id: Id722eec9a59dded588f13bc605ce2c94b4047265 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/268739 Tested-by: Mike Frysinger <vapier@google.com> Reviewed-by: David Pursehouse <dpursehouse@digital.ai>
* Make partial clone imply no-clone-bundle by default.Xin Li2020-05-212-4/+15
| | | | | | | | | | | | | | | | | | For large projects, clone bundle is useful because it provided a way to efficiently transfer a large portion of git objects through CDN, without needing to interact with git server. However, with partial clones, the intention is to not download most of the objects, so the use of clone bundles would defeat the space savings normally seen with partial clones, as they are downloaded before the first fetch. A new option, --clone-bundle is added to override this behavior. Add a new repo.clonebundle variable which remembers the choice if explicitly given from command line at repo init. Change-Id: I03638474af303a82af34579e16cd4700690b5f43 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/268452 Tested-by: Xin Li <delphij@google.com> Reviewed-by: Jonathan Nieder <jrn@google.com>
* Fix how we format the full destination branch when uploading.Sean McAllister2020-05-191-1/+5
| | | | | | | | | | | | | | | | If the dest-branch attribute is set in the project manifest, then we need to push to that branch. Previously, we would unconditionally pre-pend the refs/heads prefix to it. The dest-branch attribute is allowed to be a ref expression though, so it may already have it. Simple fix is to check if it already has the prefix before adding it. Bug: crbug.com/gerrit/12770 Change-Id: I45d6107ed6cf305cf223023b0ddad4278f7f4146 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/268152 Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: Sean McAllister <smcallis@google.com>
* repo info findRemoteLocalDiff use short branchDaniel Kutik2020-05-121-2/+5
| | | | | | | | | | | | | When running repo info -d an error would be thrown saying: fatal: bad revision 'refs/remotes/m/refs/heads/master..' Using the short branch name here instead, like 'refs/remotes/m/master..' resolves this issue. Signed-off-by: Daniel Kutik <daniel.kutik@lavawerk.com> Change-Id: I50ea92c45c011b2c3e3a63803decb88e7837a380 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/266578 Reviewed-by: Mike Frysinger <vapier@google.com>
* When writing manifest, set the dest-branch attribute for projectsSean McAllister2020-04-201-2/+9
| | | | | | | | | | | | | | When generating a revision locked manifest, we need to know what ref to push changes to when doing 'repo upload'. This information is lost when we lock the revision attribute to a particular commit hash, so we need to expose it through the dest-branch attribute. Bug: https://crbug.com/1005103 Test: manual execution Change-Id: Ib31fd77ad8c9379759c4181dac1ea97de43eec35 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/263572 Tested-by: Sean McAllister <smcallis@google.com> Reviewed-by: Mike Frysinger <vapier@google.com>
* Expose upstream and dest-branch attributes through environmentSean McAllister2020-04-162-0/+9
| | | | | | | | | | | | | | | | | | | | | | Recent changes in ChromeOS Infra to ensure we're reading from snapshot manifests properly have exposed several bugs in our assumptions about manifest files. Mainly that the revision field for a project does _not_ have to refer to a ref, it can just be a commit hash. Several places assume that the revision field can be parsed as a ref to get the branch the project is on, which isn't true. To fix this we need to be able to look at the upstream and dest-branch attributes of the repo, so we expose them through the environment variables set in `repo forall`. Test: manual 'repo forall' run Bug: https://crbug.com/1032441 Change-Id: I2c039e0f4b2e0f430602932e91b782edb6f9b1ed Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/263132 Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: Sean McAllister <smcallis@google.com>
* forall.py: Close file after removing the streamKarsten Pfeiffer-Raddatz2020-04-141-1/+1
| | | | | | | | | | | | In order to remove the stream fileno() will be called on the filedescriptor. If the file is already closed fileno() will raise an error and forall will fail. Bug: https://crbug.com/gerrit/12563 Change-Id: Ib7b895fe881c844e3eb3672b011fdcdbdae63024 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/262838 Reviewed-by: David Pursehouse <dpursehouse@collab.net> Tested-by: Karsten Pfeiffer-Raddatz <raddatz.karsten@gmail.com>
* sync: add retry to fetch operationsGeorge Engelbrecht2020-04-021-0/+5
| | | | | | | | | | | | | Add retries with exponential backoff and jitter to the fetch operations. By default don't change behavior and enable behind the new flag '--fetch-retries'. Bug: https://crbug.com/1061473 Change-Id: I492710843985d00f81cbe3402dc56f2d21a45b35 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/261576 Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: George Engelbrecht <engeg@google.com>
* version: include tag commit date for easy referenceMike Frysinger2020-03-311-0/+1
| | | | | | | | | | This is more for users trying to get a sense of how old/new their current version of repo is when debugging issues. Change-Id: Ifb413c679bb8c8dbf4f9334137adf086bb000a68 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/261192 Reviewed-by: Jonathan Nieder <jrn@google.com> Tested-by: Mike Frysinger <vapier@google.com>
* version: fix running under Python 2Mike Frysinger2020-03-251-3/+7
| | | | | | | | | This gets the unittests passing again for now. Change-Id: Ibed430a305bc26b907ad0ea424c7eec7de37e942 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/259994 Tested-by: Mike Frysinger <vapier@google.com> Reviewed-by: Jonathan Nieder <jrn@google.com>
* init: respect --repo-rev changesMike Frysinger2020-03-251-0/+11
| | | | | | | | | | | | | | We respect this option when running the first `repo init`, but then silently ignore it once the initial sync is done. Make sure users are able to change things on the fly. We refactor the wrapper API to allow reuse between the two init's. Bug: https://crbug.com/gerrit/11045 Change-Id: Icb89a8cddca32f39a760a6283152457810b2392d Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/260032 Tested-by: Mike Frysinger <vapier@google.com> Reviewed-by: Jonathan Nieder <jrn@google.com>
* download: add a --branch optionMike Frysinger2020-03-231-1/+11
| | | | | | | | | | | This allows people to quickly create new branches when pulling down changes rather than having to juggle the git calls themselves. Bug: https://crbug.com/gerrit/11609 Change-Id: Ie6a4d05e9f4e9347fe7f7119c768e6446563ae65 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/259855 Reviewed-by: David Pursehouse <dpursehouse@collab.net> Tested-by: Mike Frysinger <vapier@google.com>
* download: unify error handling with sub git callsMike Frysinger2020-03-231-11/+21
| | | | | | | | | | | | We gracefully handle cherry-pick errors, but none of the others which means people get confusing Python tracebacks. Move the main logic in a single GitError try block so we can show pretty error messages for all of them. Change-Id: I52cdf6468d21a98de7f65b86d5267b3caabd5af8 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/259854 Reviewed-by: David Pursehouse <dpursehouse@collab.net> Tested-by: Mike Frysinger <vapier@google.com>
* download: support -x when cherry-pickingMike Frysinger2020-03-231-1/+12
| | | | | | | | | | | This is a pretty common option for people to want too use, so include it as a pass-thru option when cherry-picking. Bug: https://crbug.com/gerrit/9418 Change-Id: I2a24c1ed7544541719caa4d3c0574347a151a1b0 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/259853 Reviewed-by: David Pursehouse <dpursehouse@collab.net> Tested-by: Mike Frysinger <vapier@google.com>
* download: support --ff when cherry-pickingMike Frysinger2020-03-231-1/+1
| | | | | | | | | | | The git cherry-pick already supports this, so plumb the existing repo option down. Otherwise it's confusing when people use -c --ff and it doesn't use that behavior. Change-Id: Id68932ffa09204bb30b92a21aff185c00394a520 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/259852 Reviewed-by: David Pursehouse <dpursehouse@collab.net> Tested-by: Mike Frysinger <vapier@google.com>
* init: rename --repo-branch to --repo-revMike Frysinger2020-03-182-4/+5
| | | | | | | | | | | | We refer to this as "revision" in help text, and in REPO_REV envvar, so rename to --repo-rev to be consistent. We keep --repo-branch for backwards compatibility, but as a hidden option. Bug: https://crbug.com/gerrit/11045 Change-Id: I1ecc282fba32917ed78a63850360c08469db849a Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/259352 Tested-by: Mike Frysinger <vapier@google.com> Reviewed-by: David Pursehouse <dpursehouse@collab.net>
* init: respect --repo-url changesMike Frysinger2020-03-171-0/+8
| | | | | | | | | | | | We respect this option when running the first `repo init`, but then silently ignore it once the initial sync is done. Make sure users are able to change things on the fly. Bug: https://crbug.com/gerrit/11045 Change-Id: I129ec5fec43a85067d555bb60c0d1ae02465f139 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/258893 Tested-by: David Pursehouse <dpursehouse@collab.net> Reviewed-by: David Pursehouse <dpursehouse@collab.net>
* sync: warn if not tracking a branchMike Frysinger2020-03-171-0/+7
| | | | | | | | | | | Since tracking a branch prevents repo from updating, make sure we warn people about the situation when using `repo sync`. Bug: https://crbug.com/gerrit/11045 Change-Id: I966513f510827cc93194f8df176c6745946bd739 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/258892 Tested-by: Mike Frysinger <vapier@google.com> Reviewed-by: David Pursehouse <dpursehouse@collab.net>
* subcmds: stop instantiating at import timeMike Frysinger2020-03-173-7/+8
| | | | | | | | | | | | | | | | | | The current subcmds design has singletons in all_commands. This isn't exactly unusual, but the fact that our main & help subcommand will then attach members to the classes before invoking them is. This makes it hard to keep track of what members a command has access to, and the two code paths (main & help) attach different members depending on what APIs they then invoke. Lets pull this back a step by storing classes in all_commands and leave the instantiation step to when they're used. This doesn't fully clean up the confusion, but gets us closer. Change-Id: I6a768ff97fe541e6f3228358dba04ed66c4b070a Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/259154 Tested-by: Mike Frysinger <vapier@google.com> Reviewed-by: David Pursehouse <dpursehouse@collab.net>
* subcmds: centralize all_commands logicMike Frysinger2020-03-172-8/+9
| | | | | | | | | | | | | | | The branch->branches alias is setup in the main module when that really belongs in the existing all_commands setup. For help, rather than monkey patching all_commands to the class, switch it to use the state directly from the module. This makes it a bit more obvious where it's coming from rather than this one subcommand having a |commands| member added externally to it. Change-Id: I0200def09bf4774cad8012af0f4ae60ea3089dc0 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/259153 Tested-by: Mike Frysinger <vapier@google.com> Reviewed-by: David Pursehouse <dpursehouse@collab.net>
* upload: add config setting for upload notificationsMike Frysinger2020-03-151-1/+13
| | | | | | | | | | This allows people to set default e-mail notifications via gitconfig. Bug: https://crbug.com/gerrit/12451 Change-Id: Ic04ea3b7df0c5603c491961112c5be8cabb9dddd Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/259014 Tested-by: Mike Frysinger <vapier@google.com> Reviewed-by: David Pursehouse <dpursehouse@collab.net>
* diffmanifests: honour --pretty-format when printing --rawConnor Newton2020-03-131-3/+3
| | | | | | | | | | Enable using --pretty-format to build a custom subject line even when using the --raw option. Change-Id: I0c1e682d984e56698fe65939aa6de12a653cd0f1 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/258565 Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: Connor Newton <connor@ifthenelse.io>
* sync: fix os.environ logic errorsMike Frysinger2020-03-071-3/+3
| | | | | | | | | This is a dict to index, not a function to call. Change-Id: I0117eeaaa8b2ef4762ab6f0d22f9ffdaee961f52 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/258132 Tested-by: Mike Frysinger <vapier@google.com> Reviewed-by: David Pursehouse <dpursehouse@collab.net>
* launcher/version: include OS/CPU info in outputMike Frysinger2020-02-251-0/+7
| | | | | | | | | | We often ask users what OS/version they're running when debugging. Include that in the version output to simplify the process. Change-Id: Ie480b6d1c874e6f4c6f4996a03795077b844f858 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/256732 Reviewed-by: David Pursehouse <dpursehouse@collab.net> Tested-by: Mike Frysinger <vapier@google.com>
* upload: drop support for draftsMike Frysinger2020-02-251-5/+1
| | | | | | | | | Draft CLs were replaced by private/wip CLs in Gerrit instead years ago. Change-Id: If4f3d6606aad40a6f1617a49681dfd45c64d3d37 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/256673 Reviewed-by: David Pursehouse <dpursehouse@collab.net> Tested-by: Mike Frysinger <vapier@google.com>
* upload: allow users to set labels when uploadingMike Frysinger2020-02-241-10/+33
| | | | | | | | | Bug: https://crbug.com/gerrit/11801 Change-Id: I060465105b4e68ddfc815e572f62bf5dac2c1ffd Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/256614 Tested-by: Mike Frysinger <vapier@google.com> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-by: David Pursehouse <dpursehouse@collab.net>
* manifest: support optional --manifest-nameSean McAllister2020-02-221-1/+7
| | | | | | | | | | | Still use the repo manifest by default as before, but gives us the option of overriding it to support e.g.: using a subset of the full manifest. Change-Id: Ia42cd1cb3a0a58929d31bb01c9724e9d31f68730 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/256372 Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: Sean McAllister <smcallis@google.com>
* repo/init: improve basic progress messagesMike Frysinger2020-02-221-1/+2
| | | | | | | | | | | | | We produce some simple "Get" messages that aren't super clear as to what they're doing, especially for people not familiar with repo. Rephrase these to explicitly state the thing we're doing so it's clear why we're downloading a particular source. Bug: https://crbug.com/gerrit/11293 Change-Id: I0749504f17c5385c6c65274a274e0ae25b117413 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/256455 Tested-by: Mike Frysinger <vapier@google.com> Reviewed-by: David Pursehouse <dpursehouse@collab.net>
* repo/init: add --verbose flagsMike Frysinger2020-02-221-3/+9
| | | | | | | | | | We don't use these for much yet, but init passes it down to the project sync layers which already has support for verbose mode. Change-Id: I651794f1b300be1688eeccf3941ba92c776812b5 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/256454 Tested-by: Mike Frysinger <vapier@google.com> Reviewed-by: Jonathan Nieder <jrn@google.com>
* init: hide summary output when using --quietMike Frysinger2020-02-221-15/+19
| | | | | | | Change-Id: I5e30a6d6a1c95fb8d75d8b0f4d63b497e9aac526 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/256452 Reviewed-by: David Pursehouse <dpursehouse@collab.net> Tested-by: Mike Frysinger <vapier@google.com>
* abandon: add support for --quietMike Frysinger2020-02-201-2/+8
| | | | | | | | | Also fix the normal output to write to stdout. Change-Id: I6c117eea9cec08f5be9a44b90dbe9bf1f824ec95 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/256114 Reviewed-by: David Pursehouse <dpursehouse@collab.net> Tested-by: Mike Frysinger <vapier@google.com>
* sync: Fix flake8 E125 and E129 warningsDavid Pursehouse2020-02-201-3/+3
| | | | | | | | | | | | | | - E129 visually indented line with same indent as next logical line - E125 continuation line with same indent as next logical line Fixed automatically by: autopep8 --in-place --select E125,E129 subcmds/sync.py Change-Id: Ia2f82f443e1e6a23ba22c6f9849c8485405aed0e Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/256092 Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: David Pursehouse <dpursehouse@collab.net>
* project/sync: move DeleteProject helper to ProjectMike Frysinger2020-02-201-81/+4
| | | | | | | | | | | | Since deleting a source checkout involves a good bit of internal knowledge of .repo/, move the DeleteProject helper out of the sync code and into the Project class itself. This allows us to add git worktree support to it so we can unlock/unlink project checkouts. Change-Id: If9af8bd4a9c7e29743827d8166bc3db81547ca50 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/256072 Reviewed-by: Jonathan Nieder <jrn@google.com> Tested-by: Mike Frysinger <vapier@google.com>
* project: set core.repositoryFormatVersion=1 when using extensionsMike Frysinger2020-02-191-2/+1
| | | | | | | | | | | When using extensions, make sure we set the git repo format version so git knows to check the extension compatibility. We can add a helper to the Project API to simplify this and make it foolproof. Change-Id: I9ab6c32d92fe2b8e5df6e2b080ca71556332e909 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/256035 Tested-by: Mike Frysinger <vapier@google.com> Reviewed-by: Jonathan Nieder <jrn@google.com>
* upload: add a --hashtag-branch option akin to -tMike Frysinger2020-02-191-0/+5
| | | | | | | | | | This will automatically add the current local branch name as a hashtag. Bug: https://crbug.com/gerrit/10477 Change-Id: I888f8be8419c801f2d98b7a2ad2486799e94f32c Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/255893 Tested-by: Mike Frysinger <vapier@google.com> Reviewed-by: Mike Frysinger <vapier@google.com>
* add experimental git worktree supportMike Frysinger2020-02-192-6/+42
| | | | | | | | | | | | | | | | | This provides initial support for using git worktrees internally instead of our own ad-hoc symlink tree. It's been lightly tested which is why it's not currently exposed via --help. When people opt-in to worktrees in an existing repo client checkout, no projects are migrated. Instead, only new projects will use the worktree method. This allows for limited testing/opting in without having to completely blow things away or get a second checkout. Bug: https://crbug.com/gerrit/11486 Change-Id: Ic3ff891b30940a6ba497b406b2a387e0a8517ed8 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/254075 Tested-by: Mike Frysinger <vapier@google.com> Reviewed-by: Mike Frysinger <vapier@google.com>
* assume environment always accepts stringsMike Frysinger2020-02-192-10/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* upload: add support for --yesMike Frysinger2020-02-191-3/+14
| | | | | | | | | | | This adds a CLI option to the existing autoupload gitconfig knob that allows people to automatically answer "yes" to the various prompts. Bug: https://crbug.com/gerrit/12368 Change-Id: I819ebca01b9a40240b33866ae05907c7469703e3 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/255892 Reviewed-by: David Pursehouse <dpursehouse@collab.net> Tested-by: Mike Frysinger <vapier@google.com>
* upload: add support for standard --dry-runMike Frysinger2020-02-191-0/+4
| | | | | | | Change-Id: I69ea2f3170ba17bfb9e0e3771db4ecc66a736797 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/255856 Tested-by: Mike Frysinger <vapier@google.com> Reviewed-by: David Pursehouse <dpursehouse@collab.net>
* upload: add support for setting hashtagsMike Frysinger2020-02-191-0/+24
| | | | | | | | | | | This allows users to specify custom hashtags when uploading, both via the CLI and via the same gitconfig settings as other upload options. Bug: https://crbug.com/gerrit/11174 Change-Id: Ia0959e25b463e5f29d704e4d06e0de793d4fc77c Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/255855 Reviewed-by: David Pursehouse <dpursehouse@collab.net> Tested-by: Mike Frysinger <vapier@google.com>
* upload: improve no pending CL error handlingMike Frysinger2020-02-191-2/+6
| | | | | | | | | Show clearer messages and exit non-zero if there's nothing to upload. Change-Id: Icd9c13b9b1126610a409fc13d1d11bfc66f5e802 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/255834 Reviewed-by: David Pursehouse <dpursehouse@collab.net> Tested-by: Mike Frysinger <vapier@google.com>
* avoid negative variablesMike Frysinger2020-02-194-18/+18
| | | | | | | | | | | Trying to use booleans with names like "no_xxx" are hard to follow due to the double negatives. Invert all of them so we only have positive meanings to follow. Change-Id: Ifd37d0368f97034d94aa2cf38db52c723ac0c6ed Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/255493 Tested-by: Mike Frysinger <vapier@google.com> Reviewed-by: David Pursehouse <dpursehouse@collab.net>
* Open temporary cookie file as writable in sync.pyCollin Fijalkovich2020-02-181-1/+1
| | | | | | | | | | | | | Named Temporary file defaults to mode 'w+b' which causes repo sync to fail. By opening the tmpcookiefile in PersistentTransport.request as writable, we are able to run sync successfully. Bug: https://crbug.com/gerrit/12370 Test: Ran smartsync successfully Change-Id: I01ddf915fc30eb3ff0e4d440a6f1aa261c63e88d Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/255692 Tested-by: Jonathan Nieder <jrn@google.com> Reviewed-by: Jonathan Nieder <jrn@google.com>