summaryrefslogtreecommitdiffstats
path: root/subcmds/upload.py
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>
* 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>
* 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>
* 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>
* 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>
* 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>
* 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>
* flake8: Suppress "F821 undefined name" inline for Python 2 namesDavid Pursehouse2020-02-151-1/+1
| | | | | | | | | | | | | | | | 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>
* Fix blank line issues reported by flake8David Pursehouse2020-02-121-0/+4
| | | | | | | | | | | | | | | | | | | | - 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-11/+11
| | | | | | | | | | | | | | | | | | | | | - 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>
* Remove redundant backslashesDavid Pursehouse2020-02-121-2/+2
| | | | | | | | | | | | | | | 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>
* 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-121-4/+4
| | | | | | | | | | | 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>
* 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>
* 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>
* use print() instead of sys.stdout.write()Mike Frysinger2019-07-111-5/+10
| | | | | | | | | | | | | | | | We're relying on sys.stdout.write() to flush its buffer which isn't guaranteed, and is not the case in Python 3. Change to use print() everywhere to be standard, and utilize the end= keyword to get the EOL semantics we need. We can't use print's flush= keyword as that's only in Python 3. Leave behind a TODO to clean it up when we can drop Python 2. Bug: https://crbug.com/gerrit/10418 Change-Id: I562128c7f1e6d154f4a6ecdf33a70fa2811dc2af Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/230392 Tested-by: Mike Frysinger <vapier@google.com> Reviewed-by: David Pursehouse <dpursehouse@collab.net>
* 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
* Add option for git-repo to support 'silent' uploadsVadim Bendebury2018-11-051-0/+4
| | | | | | | | | | | | | | | | | | | When --ne/--no-emails is added to 'repo upload' command line, gerrit server will not generate notification emails. project.py:Project.UploadForReview method is modified to accept a string recognizable by gerrit to indicate different sets of destination email addressees, but the upload command line allows only one option - disable sending emails completely. Default repo upload behavior is not being changed. TEST=tried in the Chrome OS repo, observed that patches uploaded with --ne or --no-emails indeed do not trigger any emails, while patches uploaded without these command line options still trigger email notifications. Change-Id: I0301edec984907aedac277d883bd0e6d3099aedc
* Merge "update markdown/help header format"Jonathan Nieder2018-10-101-4/+2
|\
| * update markdown/help header formatMike Frysinger2018-10-101-4/+2
| | | | | | | | | | | | | | Since gitiles recommends using # headers over ---/=== underlines, change the manifest-format.md over and all our help texts. Change-Id: I96391d41fba769e9f26870d497cf7cf01c8d8ab3
* | update homepage URIsMike Frysinger2018-10-101-1/+1
|/ | | | Change-Id: I482a72bf296978625b1e82ef580b0e0d4d57ff25
* Remove unused pylint suppressionsDavid Pursehouse2018-07-241-2/+0
| | | | | | | | | | | pylint is not used since bb5b1a0. The pyflakes cleanup mentioned in that commit has not been done, but given that this project is no longer being actively developed I don't think it's worth spending time doing it. Leaving the pylint suppressions causes confusion because it leads people to think that we are still using pylint. Change-Id: If7d9f280a0f408c780f15915ffdb80579ae21f69
* Support --push-option in upload subcommandMasaya Suzuki2017-11-131-1/+6
| | | | Change-Id: I44836f8c66ded5a96cbf5431912e027e681f6529
* Add option '--no-cert-checks' for 'upload' sub command.Łukasz Gardoń2017-08-231-1/+6
| | | | | | | This option allow to bypass verification ssl certification while establishing connection with Gerrit to upload review. Change-Id: If2e15f5a273c18a700eb5093ca8a4d5a4cbf80cd
* Revert "Migrate git-repo to create private changes rather than drafts"Jonathan Nieder2017-08-081-3/+4
| | | | | | | | This reverts commit d88f53e2b9634b9645f80b2d8e653beac24711fe. I merged it too hastily without paying enough attention to compatibility with released Gerrit versions. Change-Id: I4028d4737df1255f11e217da183a19a010597d5b
* Migrate git-repo to create private changes rather than draftsChangcheng Xiao2017-08-071-4/+3
| | | | | | | | Considering that some users might expect changes created with '-d' option are not public. Private changes may be a better choice here than work-in-progress changes. Change-Id: I46a8fb9ae38beb41cf96d6abe82bea6db2439669
* Add options for git-repo to support private and wip changesChangcheng Xiao2017-08-071-1/+12
| | | | | | | This change adds options for git-repo tool to support private changes and work-in-progress changes. Change-Id: I343491f5949f06f1580d53f9cc0dee2dca09130f
* Fix "list comprehension redefines 'x'" warnings from pyflakesDavid Pursehouse2017-07-101-2/+2
| | | | | | | | | $ git ls-files | grep py$ | xargs pyflakes subcmds/stage.py:101: list comprehension redefines 'p' from line 63 subcmds/sync.py:784: list comprehension redefines 'p' from line 664 subcmds/upload.py:467: list comprehension redefines 'avail' from line 454 Change-Id: Ia65d1a72ed185ab3357e1a91ed4450c719e75a7c
* Tell the user if it will upload a draftNicolas Cornu2017-07-101-1/+2
| | | | Change-Id: Ie004ec9d61603f3f618c47597947b82c59f2839c
* upload: short circuit when nothing is pendingMike Frysinger2016-09-141-4/+6
| | | | | | | When nothing is pending, most of this code is already short-circuited. Hoist the single check up to make this more obvious/slightly faster. Change-Id: Iec3a7e08eacd23a7c5f964900d5776bf5252c804
* RepoHook: allow users to approve hooks via manifestsMike Frysinger2016-08-161-1/+3
| | | | | | | | | | | | | | | | | | The constant prompting when registered hooks change can be tedious and has a large multiplication factor when the project is large (e.g. the AOSP). It gets worse as people want to write more checks, hooks, docs, and tests (or fix bugs), but every CL that goes in will trigger a new prompt to approve. Let's tweak our trust model when it comes to hooks. Since people start off by calling `repo init` with a URL to a manifest, and that manifest defines all the hooks, anchor trust in that. This requires that we get the manifest over a trusted link (e.g. https or ssh) so that it can't be MITM-ed. If the user chooses to use an untrusted link (e.g. git or http), then we'll fallback to the existing hash based approval. Bug: Issue 226 Change-Id: I77be9e4397383f264fcdaefb582e345ea4069a13
* upload: report names of uncommitted filesVadim Bendebury2014-10-141-2/+6
| | | | | | | | | | | | | | | | | | | | | When there are uncommitted files in the tree, 'repo upload' stops to ask if it is OK to continue, but does not report the actual names of uncommitted files. This patch adds plumbing to have the outstanding file names reported if desired. BUG=None TEST=verified that 'repo upload' properly operates with the following conditions present in the tree: . file(s) modified locally . file(s) added to index, but not committed . files not known to git . no modified files (the upload proceeds as expected) Change-Id: If65d5f8e8bcb3300c16d85dc5d7017758545f80d Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Signed-off-by: Vadim Bendebury <vbendeb@google.com>
* Define unicode as str if using Python 3Anthony King2014-05-061-2/+4
| | | | | | The unicode object was renamed to str in Python 3 Change-Id: I1e4972fb07b313d3462587b3059bb3638d779625
* Add reviewers automatically from project's git configbijia2014-03-041-3/+14
| | | | | | | | | | | The `review.URL.autocopy` setting sends email notification to the named reviewers, but does not add them as reviewer on the uploaded change. Add a new setting `review.URL.autoreviewer`. The named reviewers will be added as reviewer on the uploaded change. Change-Id: I3fddfb49edf346f8724fe15b84be8c39d43e7e65 Signed-off-by: bijia <bijia@xiaomi.com>
* Merge "Don't backtrace when current branch is not uploadable."David Pursehouse2014-01-141-1/+10
|\
| * Don't backtrace when current branch is not uploadable.Warren Turkal2013-12-111-1/+10
| | | | | | | | | | | | | | | | | | The backtrace currently occurs when one uses the "--cbr" argument with the repo upload subcommand if the current branch is not tracking an upstream branch. There may be other cases that would backtrace as well, but this is the only one I found so far. Change-Id: Ie712fbb0ce3e7fe3b72769fca89cc4c0e3d2fce0
* | Merge "repo: Support multiple branches for the same project."Conley Owens2014-01-101-1/+3
|\ \ | |/ |/|
| * repo: Support multiple branches for the same project.David James2013-10-141-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It is often useful to be able to include the same project more than once, but with different branches and placed in different paths in the workspace. Add this feature. This CL adds the concept of an object directory. The object directory stores objects that can be shared amongst several working trees. For newly synced repositories, we set up the git repo now to share its objects with an object repo. Each worktree for a given repo shares objects, but has an independent set of references and branches. This ensures that repo only has to update the objects once; however the references for each worktree are updated separately. Storing the references separately is needed to ensure that commits to a branch on one worktree will not change the HEAD commits of the others. One nice side effect of sharing objects between different worktrees is that you can easily cherry-pick changes between the two worktrees without needing to fetch them. Bug: Issue 141 Change-Id: I5e2f4e1a7abb56f9d3f310fa6fd0c17019330ecd
* | Only check merge destination if it isn't Nonev1.12.6Conley Owens2013-10-151-9/+10
| | | | | | | | Change-Id: Ifb1dcd07142933489e93a1f4f03e38289087b609
* | Fix indentationv1.12.5David Pursehouse2013-10-151-7/+7
|/ | | | | | | git-repo uses 2 space indentation. A couple of recent changes introduced 4 space indentation in some modules. Change-Id: Ia4250157c1824c1b5e7d555068c4608f995be9da
* Don't upload when dest branch is not merge branchConley Owens2013-10-101-0/+29
| | | | | | | | | | | | Example: - `repo init -b master` / sync a project - In one project: `git checkout -b work origin/branch-thats-not-master` - make some changes, `git commit` - `repo upload .` - Upload will now be skipped with a warning instead of being uploaded to master Change-Id: I990b36217b75fe3c8b4d776e7fefa1c7d9ab7282
* don't pass project revision to UploadForReviewColin Cross2013-10-081-1/+1
| | | | | | | | | | | | | | | Passing a project revisionExpr to UploadForReview will cause it to try to push to refs/for/<sha> if the revision points to a sha instead of a branch. Pass None for dest_branch if no destination branch has been specified, which will cause UploadForReview to upload to the merge branch. There is room for further improvement, the user prompts will still print "Upload project <project> to remote branch <sha>", and then upload to the merge branch and not the sha, but that is the same behavior that was in 1.12.2. Change-Id: I06c510336ae67ff7e68b5b69e929693179d15c0b
* upload: fix display of destination branch for SingleBranchChirayu Desai2013-06-281-1/+1
| | | | | | | | | | The command `repo upload --cbr -D <some branch>` will display the default revision, and not the actual destination branch. Fix that and display the branch to which the change will be uploaded to. Change-Id: I712ed0871c819dce6774c47254dac4efec4532e0
* Merge "Fix a few issues with dest-branch and multiples"Conley Owens2013-06-101-2/+4
|\
| * Fix a few issues with dest-branch and multiplesBryan Jacobs2013-06-031-2/+4
| | | | | | | | | | | | | | This fixes dest-branch display with >1 branch being uploaded to at once, and correctly handles setting the target branch in that case. Change-Id: If5e9c7ece02cc0d903e2cb377485ebea73a07107