summaryrefslogtreecommitdiffstats
path: root/project.py
Commit message (Collapse)AuthorAgeFilesLines
* Move RepoHook class from project.py file to dedicated fileRemy Bohmer2020-11-031-403/+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-0/+21
| | | | | | | | | | | | | | | | 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-0/+7
| | | | | | | | | | | | | 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>
* Fix Git base version for worktreeconfig extensionAdrien Bioteau2020-07-301-1/+1
| | | | | | | | | worktreeconfig extension only appears with version Git 2.20.0 Change-Id: I3ea8b7d9f8a1f7953e536edd77b09cbc4f8f3158 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/276700 Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: Adrien Bioteau <adrien.bioteau@gmail.com>
* project.py: Fix check for wild cardsv2.7Angel Petkov2020-05-051-3/+3
| | | | | | | | | | | | | | The intention of the check is to verify whether the target file name contains a wild card. The code, however, assumes that if the file is non-existent - it contains a wild card. This has the side effect that a target file that does not exist at the moment of the check is considered to contain a wild card, this leads itself to softlink not being created. Change-Id: I4e4cd7b5e1b8ce2e4b2edc9abf5a1147cd86242f Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/265736 Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: Angel Petkov <apetkov86@gmail.com>
* project.py: Remove extraneous ','v2.6George Engelbrecht2020-04-151-1/+1
| | | | | | | | | | Bug: https://crbug.com/1061473 Change-Id: I0f02f122d6313679c1ae5ad6fb4e05f68b764186 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/263112 Tested-by: George Engelbrecht <engeg@google.com> Reviewed-by: George Engelbrecht <engeg@google.com> Reviewed-by: SPA SARC <spanc.sarc@gmail.com> Reviewed-by: Mike Frysinger <vapier@google.com>
* project: have clone.bundle failures print better diagnosticsGeorge Engelbrecht2020-04-151-1/+3
| | | | | | | | | Bug: https://crbug.com/1061473 Change-Id: If066dc56ca575720bfb25c1a9892dbd6f4af15c6 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/261852 Tested-by: George Engelbrecht <engeg@google.com> Reviewed-by: Mike Frysinger <vapier@google.com>
* sync: add retry to fetch operationsGeorge Engelbrecht2020-04-021-9/+41
| | | | | | | | | | | | | 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>
* download: support -x when cherry-pickingMike Frysinger2020-03-231-1/+3
| | | | | | | | | | | 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/+3
| | | | | | | | | | | 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>
* repo/init/sync: rework default git download outputMike Frysinger2020-03-141-6/+9
| | | | | | | | | | | | | | | | When we download git sources, we get a progress bar (good) and we get a dump of all the refs we downloaded (bad) as it can easily be 100+ if not 1000+ depending on the project (for each git repo!). Lets rework the output behavior so that: * quiet: Only errors. * default: Progress bars (if on a tty). * verbose: Full output (progress bars & downloaded refs). Bug: https://crbug.com/gerrit/11293 Change-Id: I87a380075e79de6805f91095876dd1b37d32873a Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/256456 Tested-by: Mike Frysinger <vapier@google.com> Reviewed-by: Michael Mortensen <mmortensen@google.com>
* project: fix m/ pseudo ref handling with git worktreesMike Frysinger2020-02-291-10/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since most ref namespaces are shared among all worktrees, trying to set the pseudo m/<branch> in the common git repo ends up clobbering each other when using shared checkouts. For example, in CrOS: <project path="src/third_party/kernel/v3.8" name="chromiumos/third_party/kernel" revision="refs/heads/chromeos-3.8" /> <project path="src/third_party/kernel/v3.10" name="chromiumos/third_party/kernel" revision="refs/heads/chromeos-3.10" /> Trying to set m/master in chromiumos/third_party/kernel.git/ will keep clobbering the other. Instead, when using git worktrees, lets set the m/ pseudo ref to point into the refs/worktree/ namespace which is unique to each git worktree. So we have in the common dir: chromiumos/third_party/kernel.git/: refs/remotes/m/master: ref: refs/worktree/m/master And then in each worktree we point refs/worktree/m/master to the respective manifest revision expression. Now people can use the m/master in each git worktree and have it resolve to the right commit for that worktree. Bug: https://crbug.com/gerrit/12404 Change-Id: I78814bdd5dd67bb13218c4c6ccd64f8a15dd0a52 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/256952 Tested-by: Mike Frysinger <vapier@google.com> Reviewed-by: David Pursehouse <dpursehouse@collab.net>
* upload: drop support for draftsMike Frysinger2020-02-251-9/+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-0/+4
| | | | | | | | | 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>
* project: replace GetHeadPath with new git helperv2.4Mike Frysinger2020-02-241-14/+3
| | | | | | | Change-Id: I79931cb484508c78f6a8b8413d05b85ed8bc6d98 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/256533 Reviewed-by: David Pursehouse <dpursehouse@collab.net> Tested-by: Mike Frysinger <vapier@google.com>
* project: fix rebase check with worktreesMike Frysinger2020-02-241-8/+23
| | | | | | | | | | Add a helper to our git wrapper to find the .git subdir, and then use that to detect internal rebase state. Change-Id: I3b3b6ed4c1f45cc8c3c98dc19c7ca3aabdc46905 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/256532 Reviewed-by: David Pursehouse <dpursehouse@collab.net> Tested-by: Mike Frysinger <vapier@google.com>
* project: fix worktree init under WindowsMike Frysinger2020-02-221-0/+3
| | | | | | | | | | | Git likes to create .git files with read-only permissions which makes it difficult to open+truncate+write in situ under Windows. Delete it before we write the file content to workaround. Change-Id: I3effd96525f0dfe0b90e298b6bf0b856ea26aa03 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/256412 Tested-by: Mike Frysinger <vapier@google.com> Reviewed-by: David Pursehouse <dpursehouse@collab.net>
* project: fallback to hardlinks with git hooksMike Frysinger2020-02-211-5/+9
| | | | | | | | | | | | | | Windows requires Administrator access to create symlinks. We can mitigate this a bit by falling back to hardlinks as those may be created by any user on the system. Do this with the git hooks as these are supposed to be internal only and people shouldn't be modifying them. If they do, they'll have to delink first. This seems worth it to allow repo usage without extra privileges. Change-Id: I996ea9c9238f7bd7d27d1d9b1f2786593bf75ef7 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/256312 Reviewed-by: David Pursehouse <dpursehouse@collab.net> Tested-by: Mike Frysinger <vapier@google.com>
* manifest/tests: get them passing under WindowsMike Frysinger2020-02-211-1/+6
| | | | | | | | | | | | | | We also need to check more things in the manifest/project handlers, and use platform_utils in a few places to address Windows behavior. Drop Python 2.7 from Windows testing as it definitely doesn't work and we won't be fixing it. Change-Id: I83d00ee9f1612312bb3f7147cb9535fc61268245 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/256113 Tested-by: Mike Frysinger <vapier@google.com> Reviewed-by: Jonathan Nieder <jrn@google.com> Reviewed-by: David Pursehouse <dpursehouse@collab.net>
* project: unify StartBranch flows behind git-update-refMike Frysinger2020-02-211-13/+5
| | | | | | | | | | | We're using this for git worktrees because it handles the .git file format, but it should work for all flows. Unify to simplify. This also fixes the worktree logic which duplicated .git/config settings. Change-Id: Ie3af2e206710859dccfc376b3593f415d6830738 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/256034 Tested-by: Mike Frysinger <vapier@google.com> Reviewed-by: Jonathan Nieder <jrn@google.com>
* project/sync: move DeleteProject helper to ProjectMike Frysinger2020-02-201-0/+116
| | | | | | | | | | | | 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/+20
| | | | | | | | | | | 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>
* add experimental git worktree supportMike Frysinger2020-02-191-11/+59
| | | | | | | | | | | | | | | | | 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>
* upload: add support for standard --dry-runMike Frysinger2020-02-191-2/+7
| | | | | | | 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/+4
| | | | | | | | | | | 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>
* project: handle verbose with initial clone bundleMike Frysinger2020-02-191-9/+17
| | | | | | | | | | | If we're not in --verbose mode with repo sync, then omit the per-project clone bundle progress bar. Bug: https://crbug.com/gerrit/11293 Change-Id: Ibdf3be86d35fcbccbf6788c192189f38c577e6e9 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/255854 Tested-by: Mike Frysinger <vapier@google.com> Reviewed-by: David Pursehouse <dpursehouse@collab.net>
* avoid negative variablesMike Frysinger2020-02-191-7/+6
| | | | | | | | | | | 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>
* project: Fix E125 continuation line with same indent as next logical lineDavid Pursehouse2020-02-181-5/+5
| | | | | | | Change-Id: I71d2b105baacf6968a29391e9e2a74bba1b4fd0b Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/255555 Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: David Pursehouse <dpursehouse@collab.net>
* project: move successful fetch output behind verboseMike Frysinger2020-02-181-1/+4
| | | | | | | | | | | | | 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>
* sync: introduce --verbose optionMike Frysinger2020-02-171-22/+21
| | | | | | | | | | | | | 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>
* project: disable stat output when fast forwarding mergesMike Frysinger2020-02-171-1/+1
| | | | | | | | | | Our sync output is pretty chatty, and the stat output on fast forward merges doesn't really help. Suppress it to tighten up the output. Change-Id: I91e50639b3cd8db9df3d13a7da6d1aaa70d7932f Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/255412 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>
* project: Don't emit locally modified hook warning in quiet modeDavid Pursehouse2020-02-131-10/+12
| | | | | | | Change-Id: I0f6db037b85f2a015fc7b7fd37472df848a58266 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/254698 Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: David Pursehouse <dpursehouse@collab.net>
* drop old git_require checksMike Frysinger2020-02-121-3/+0
| | | | | | | | | | 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-2/+2
| | | | | | | | | | | | | | | | | | | | | | 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-121-9/+1
| | | | | | | | | | | | | | | | | | | | - 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-1/+1
| | | | | | | | | | | | | | | | | | | | | - 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>
* project: make syncing a little more self-healingMike Frysinger2020-02-121-2/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | We have a few files that we optionally symlink from the work tree .git/ to the .repo/projects/ path. If they don't exist when we first initialize, then we skip creating symlinks. If the files are created later on under the work tree .git/, repo gets upset. This can happen with the packed-refs file: if we don't have any packed refs initially, we don't symlink it. But if git tries to pack refs later on and creates the file, the project gets wedged. We could create an empty file initially and then symlink it, but for some files, it's not clear we want to always do that (e.g. the .git/shallow setting). Instead, lets make handling of these paths more dynamic. If they show up later on in the work tree .git/ only, we'll take care of relocating & symlinking. This also makes repo a little more robust and autorecovers incase a path goes missing in one of the dirs. Ideally we wouldn't monkey around at all here, but considering the only option we give to users currently is to blow things away with --force-sync, this seems a bit better. Bug: https://crbug.com/gerrit/12324 Change-Id: Ia6960f1896ac6d890c762d7d053684a1c6ab2c87 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/254632 Reviewed-by: David Pursehouse <dpursehouse@collab.net> Tested-by: Mike Frysinger <vapier@google.com>
* Revert "Save cookies back to jar when fetching clone.bundle"v2.2Mike Frysinger2020-02-121-1/+1
| | | | | | | | | | | | | | | This reverts commit 4abf8e6ef81e78469148b156ae2d2da70ace627a. The curl process for updating the cookie file is not atomic. When fetching many bundles in parallel, we can sometimes corrupt the file causing it to be cleared. Since users should manage gitcookies on their own, leave it read-only. Bug: https://crbug.com/gerrit/12300 Change-Id: Id472c99b197bc4cf8533c649f8881509f38643c1 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/254092 Reviewed-by: David Pursehouse <dpursehouse@collab.net> Tested-by: Mike Frysinger <vapier@google.com>
* project: fix bytes/str encoding when updating git submodulesMike Frysinger2020-02-111-1/+1
| | | | | | | | | | | | Since tempfile.mkstemp() returns a file handle in binary mode, make sure we turn our strings into bytes before writing. Bug: https://crbug.com/gerrit/12043 Change-Id: I3e84d595e84b8bc12a1fbc7fd0bb3ea0ba2832b0 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/254393 Reviewed-by: Michael Mortensen <mmortensen@google.com> Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: Mike Frysinger <vapier@google.com>
* project: allow src=. with symlinksv2.1.1Mike Frysinger2020-02-111-1/+6
| | | | | | | | | | | | | Some Android/Nest manifests are using <linkfile> with src="." to create stable paths to specific projects. Allow that specific use case as it seems reasonable to support. Bug: https://crbug.com/gerrit/11218 Change-Id: I16dbe8d9fe42ea45440afcb61404c753bff1930d Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/254330 Reviewed-by: Chanho Park <parkch98@gmail.com> Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: Mike Frysinger <vapier@google.com>
* project: unify HEAD path managementMike Frysinger2020-02-091-7/+16
| | | | | | | | | | | | Add a helper function to unify the duplication of finding the full path to the symbolic HEAD ref. This makes it easy to handle git worktrees where .git is a file rather than a dir/symlink. Bug: https://crbug.com/gerrit/11486 Change-Id: I9f794f1295ad0d98c7c13622f01ded51e4ba7846 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/254074 Tested-by: Mike Frysinger <vapier@google.com> Reviewed-by: David Pursehouse <dpursehouse@collab.net>
* 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>
* Do not try to fetch default revision for mirrors alwaysChirayu Desai2020-02-051-1/+4
| | | | | | | | | | | | | | | | | * Mirrors may contain multiple projects, some of which may not always contain the default revision. * Only fetch the default revision explicitly if '--current-branch' is set. * Fixes breakage casued by commit 6856f98467aa5c98085cdee02587dbab984cebb1 "Fix repo mirror with --current-branch" Bug: https://crbug.com/gerrit/12274 Change-Id: Iaafabe2992f76f3644b841f24245d3e19c9515a9 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/253093 Reviewed-by: Kuang-che Wu <kcwu@chromium.org> Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: Chirayu Desai <chirayudesai1@gmail.com>
* project: add basic path checks for <copyfile> & <linkfile>Mike Frysinger2020-02-041-38/+108
| | | | | | | | | | | | | | | | | | Reject paths in <copyfile> & <linkfile> that try to use symlinks or non-file or non-dirs. We don't fully validate <linkfile> when src is a glob as it's a bit complicated -- any component in the src could be the glob. We make sure the destination is a directory, and that any paths in that dir are created as symlinks. So while this can be used to read any path, it can't be abused to write to any paths. Bug: https://crbug.com/gerrit/11218 Change-Id: I68b6d789b5ca4e43f569e75e8b293b3e13d3224b Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/233074 Tested-by: Mike Frysinger <vapier@google.com> Reviewed-by: Mike Frysinger <vapier@google.com> Reviewed-by: Michael Mortensen <mmortensen@google.com>
* Fix docstring of project.Project.PrintWorkTreeStatus()v1.13.9Rostislav Krasny2020-01-251-1/+1
| | | | | | | Change-Id: I1a9139d2ea3b3331a6f3ad3cae9e0ac37074d716 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/251837 Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: Rostislav Krasny <rostigm@gmail.com>
* Fix repo mirror with --current-branchKuang-che Wu2019-11-251-23/+28
| | | | | | | | | | | | | | | | | | | | | | Before a2cd6aeae8, "repo mirror with --current-branch" fetches git data using command git fetch --progress --update-head-ok cros --tags No refspec is specified, thus it fetches default refspec, which is +refs/heads/*:refs/heads/* After a2cd6aeae8, the fetch command became git fetch --progress --update-head-ok cros --tags +refs/tags/*:refs/tags/* It did not only add tags refspec, but also suppressed the fetching of default refspec. In other words, repo mirrors doesn't work if current_branch_only=True. This CL explicitly adds the default refspec to command line if none is specified. Bug: https://crbug.com/gerrit/11990 Change-Id: Iadcf7b9aa50f53c47132cfe6c53b3fb2076ebca2 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/246632 Reviewed-by: David Pursehouse <dpursehouse@collab.net> Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: Kuang-che Wu <kcwu@chromium.org>
* prune: handle branches that track missing branchesMike Frysinger2019-11-161-8/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | 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: try to fast forward merge branches before checking published stateMike Frysinger2019-11-131-1/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | If the local branch changed state since its last upload, the data cached in .git/config related to the last uploaded CL might not be that relevant. If we're able to fast forward merge to the latest tree state, then let's do that. This would be akin to checking out a detached head before syncing where we already switch state. If we aren't able to fast forward merge, then it's not a big deal as we'll continue on to the existing branch checking logic. This would be easy to reproduce by doing something like: $ repo start foo . $ git revert HEAD $ repo upload --cbr . $ git reset --hard HEAD^ <CL is merged> $ repo sync . <we can fast forward> Change-Id: I7d62f3d1ba5314a349d85b4dbb0ec8352eca18bb Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/238552 Tested-by: Mike Frysinger <vapier@google.com> Reviewed-by: Michael Mortensen <mmortensen@google.com> Reviewed-by: Mike Frysinger <vapier@google.com>
* sync: add sanity check for local checkouts missing networkMike Frysinger2019-11-121-0/+7
| | | | | | | | | | | If you run `repo sync -l foo` without first `repo sync -n foo`, repo sets up an invalid gitdir tree that gets wedged and requires manual recovery. Add a sanity check to abort cleanly first. Change-Id: Iad865ea860a3f1fd2f39ce683fe66bd4380745a5 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/244732 Reviewed-by: David Pursehouse <dpursehouse@collab.net> Tested-by: Mike Frysinger <vapier@google.com>