From afd1b4023f3b96a845ffec997359ab6ede46e6a2 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Tue, 4 Feb 2020 14:40:30 -0500 Subject: [PATCH 01/12] repo: point default branch to repo-1 Since this will be feature-frozen for Python 2 users, lets point the default update branch to "repo-1" rather than "stable" as the latter will follow the master development (and Python 3-only). Bug: https://crbug.com/gerrit/10418 Change-Id: Iceff0983684a580dc5c9ec1c60acfb5eda5ce2c4 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/253172 Reviewed-by: David Pursehouse Tested-by: Mike Frysinger --- repo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/repo b/repo index e7239861..c910bd90 100755 --- a/repo +++ b/repo @@ -16,7 +16,7 @@ import os REPO_URL = os.environ.get('REPO_URL', None) if not REPO_URL: REPO_URL = 'https://gerrit.googlesource.com/git-repo' -REPO_REV = 'stable' +REPO_REV = 'repo-1' # Copyright (C) 2008 Google Inc. # From 75c02fe4cb5a22135e292c3083220e1f3d4cb349 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Wed, 5 Feb 2020 00:01:59 -0500 Subject: [PATCH 02/12] init: handle -c conflicts with gitc-init 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 (cherry picked from commit 66098f707a1a3f352aac4c4bb2c4f88da070ca2a) Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/253392 Tested-by: Mike Frysinger Reviewed-by: Mike Frysinger --- subcmds/gitc_init.py | 2 +- subcmds/init.py | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/subcmds/gitc_init.py b/subcmds/gitc_init.py index df7b2587..378f9236 100644 --- a/subcmds/gitc_init.py +++ b/subcmds/gitc_init.py @@ -50,7 +50,7 @@ use for this GITC client. """ def _Options(self, p): - super(GitcInit, self)._Options(p) + super(GitcInit, self)._Options(p, gitc_init=True) g = p.add_option_group('GITC options') g.add_option('-f', '--manifest-file', dest='manifest_file', diff --git a/subcmds/init.py b/subcmds/init.py index 3e2c9d70..f4229f62 100644 --- a/subcmds/init.py +++ b/subcmds/init.py @@ -81,7 +81,7 @@ manifest, a subsequent `repo sync` (or `repo sync -d`) is necessary to update the working directory files. """ - def _Options(self, p): + def _Options(self, p, gitc_init=False): # Logging g = p.add_option_group('Logging options') g.add_option('-q', '--quiet', @@ -96,7 +96,12 @@ to update the working directory files. g.add_option('-b', '--manifest-branch', dest='manifest_branch', help='manifest branch or revision', metavar='REVISION') - g.add_option('-c', '--current-branch', + cbr_opts = ['--current-branch'] + # The gitc-init subcommand allocates -c itself, but a lot of init users + # want -c, so try to satisfy both as best we can. + if gitc_init: + cbr_opts += ['-c'] + g.add_option(*cbr_opts, dest='current_branch_only', action='store_true', help='fetch only current manifest branch from server') g.add_option('-m', '--manifest-name', From ab15e42fa4403a0354c936d8740f864300b00929 Mon Sep 17 00:00:00 2001 From: Chirayu Desai Date: Tue, 4 Feb 2020 17:50:57 +0530 Subject: [PATCH 03/12] Do not try to fetch default revision for mirrors always * 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 Reviewed-by: Mike Frysinger Tested-by: Chirayu Desai (cherry picked from commit f7b64e3350a622ee87e1927cdbc8d854a5696d85) --- project.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/project.py b/project.py index d12d4666..281ba4b7 100755 --- a/project.py +++ b/project.py @@ -2252,7 +2252,10 @@ class Project(object): spec.append('tag') spec.append(tag_name) - branch = self.revisionExpr + if self.manifest.IsMirror and not current_branch_only: + branch = None + else: + branch = self.revisionExpr if (not self.manifest.IsMirror and is_sha1 and depth and git_require((1, 8, 3))): # Shallow checkout of a specific commit, fetch from that commit and not From 619a2b58871e03ecc4f40b93a183206b51853fa5 Mon Sep 17 00:00:00 2001 From: Dan Willemsen Date: Thu, 6 Feb 2020 17:00:00 -0800 Subject: [PATCH 04/12] Fix inverted logic around [gitc-]init and -c 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 Tested-by: Dan Willemsen (cherry picked from commit 93293ca47f3a898b30eecf21e7b4e1038780c867) --- subcmds/init.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subcmds/init.py b/subcmds/init.py index f4229f62..6594a602 100644 --- a/subcmds/init.py +++ b/subcmds/init.py @@ -99,7 +99,7 @@ to update the working directory files. cbr_opts = ['--current-branch'] # The gitc-init subcommand allocates -c itself, but a lot of init users # want -c, so try to satisfy both as best we can. - if gitc_init: + if not gitc_init: cbr_opts += ['-c'] g.add_option(*cbr_opts, dest='current_branch_only', action='store_true', From 471a7ed5f77ac6b38fc9ef60d9fff2c9924a2df8 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Fri, 7 Feb 2020 23:18:23 -0500 Subject: [PATCH 05/12] git_config: fix encoding handling in GetUrlCookieFile Make sure we decode the bytes coming from the subprocess.Popen as we're treating them as strings. Change-Id: I44100ca5cd94f68a35d489936292eb641006edbe Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/253973 Reviewed-by: Jonathan Nieder Tested-by: Mike Frysinger (cherry picked from commit ded477dbb9c6993cbe8b93b10654682b04fdeea8) --- git_config.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/git_config.py b/git_config.py index 680de90f..8de3200c 100644 --- a/git_config.py +++ b/git_config.py @@ -528,7 +528,7 @@ def GetUrlCookieFile(url, quiet): cookiefile = None proxy = None for line in p.stdout: - line = line.strip() + line = line.strip().decode('utf-8') if line.startswith(cookieprefix): cookiefile = os.path.expanduser(line[len(cookieprefix):]) if line.startswith(proxyprefix): @@ -540,7 +540,7 @@ def GetUrlCookieFile(url, quiet): finally: p.stdin.close() if p.wait(): - err_msg = p.stderr.read() + err_msg = p.stderr.read().decode('utf-8') if ' -print_config' in err_msg: pass # Persistent proxy doesn't support -print_config. elif not quiet: From a06ab7d28b224d3400742f5e8c66f6e0e930d8ff Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Sat, 8 Feb 2020 03:38:48 -0500 Subject: [PATCH 06/12] find python via env This allows these scripts to run through the active version of the virtualenv python when invoked via tox. Change-Id: Ib52f475b7b20c34d62cfd179a1341da1a08a8b5c Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/253974 Reviewed-by: David Pursehouse Tested-by: Mike Frysinger (cherry picked from commit 1b117db767804856a310210c012fdd40addae66a) --- run_tests | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/run_tests b/run_tests index 1b35aded..d7144b3c 100755 --- a/run_tests +++ b/run_tests @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python # -*- coding:utf-8 -*- # Copyright 2019 The Android Open Source Project # diff --git a/setup.py b/setup.py index e48aa303..f4d7728d 100755 --- a/setup.py +++ b/setup.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python # -*- coding:utf-8 -*- # Copyright 2019 The Android Open Source Project # From ef412624e953db6afdf402b18b004c0beabc5917 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Sun, 9 Feb 2020 04:35:57 -0500 Subject: [PATCH 07/12] remove spurious +x bits 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 Reviewed-by: David Pursehouse (cherry picked from commit e7c91889a6ff23931d3fbc25481b276e50ed8229) --- pager.py | 0 project.py | 0 subcmds/download.py | 0 3 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 pager.py mode change 100755 => 100644 project.py mode change 100755 => 100644 subcmds/download.py diff --git a/pager.py b/pager.py old mode 100755 new mode 100644 diff --git a/project.py b/project.py old mode 100755 new mode 100644 diff --git a/subcmds/download.py b/subcmds/download.py old mode 100755 new mode 100644 From 68744dbc01490dc283db7c965c5cfe07135814ac Mon Sep 17 00:00:00 2001 From: Jiri Tyr Date: Thu, 6 Feb 2020 16:32:46 +0000 Subject: [PATCH 08/12] Fixing forall subcommand for Py3 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 Reviewed-by: David Pursehouse Tested-by: Jiri Tyr (cherry picked from commit 83a3227b62c936b346b825b333fc2ca65528ecfd) --- subcmds/forall.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subcmds/forall.py b/subcmds/forall.py index 96eac541..131ba676 100644 --- a/subcmds/forall.py +++ b/subcmds/forall.py @@ -366,7 +366,7 @@ def DoWork(project, mirror, opt, cmd, shell, cnt, config): while not s_in.is_done: in_ready = s_in.select() for s in in_ready: - buf = s.read() + buf = s.read().decode() if not buf: s.close() s_in.remove(s) From 19607b28172c3be8153fa0c44326052929fe8653 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Wed, 5 Feb 2020 23:52:07 -0500 Subject: [PATCH 09/12] repo: allow REPO_REV to be an env var We do this for REPO_URL already. Bug: https://crbug.com/gerrit/10233 Change-Id: I53410645474b00d900467c96fa5d8446f3a607d3 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/253552 Reviewed-by: David Pursehouse Tested-by: Mike Frysinger (cherry picked from commit 563f1a651298eaa3616f92c3cd7b264fe5442379) --- repo | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/repo b/repo index c910bd90..b9e29ba6 100755 --- a/repo +++ b/repo @@ -16,7 +16,9 @@ import os REPO_URL = os.environ.get('REPO_URL', None) if not REPO_URL: REPO_URL = 'https://gerrit.googlesource.com/git-repo' -REPO_REV = 'repo-1' +REPO_REV = os.environ.get('REPO_REV') +if not REPO_REV: + REPO_REV = 'repo-1' # Copyright (C) 2008 Google Inc. # @@ -235,10 +237,10 @@ group.add_option('--no-tags', group = init_optparse.add_option_group('repo Version options') group.add_option('--repo-url', dest='repo_url', - help='repo repository location', metavar='URL') + help='repo repository location ($REPO_URL)', metavar='URL') group.add_option('--repo-branch', dest='repo_branch', - help='repo branch or revision', metavar='REVISION') + help='repo branch or revision ($REPO_REV)', metavar='REVISION') group.add_option('--no-repo-verify', dest='no_repo_verify', action='store_true', help='do not verify repo source code') From 45d1c372a79fe35e1deb4956708432bc9ae80ea0 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Tue, 11 Feb 2020 03:35:24 -0500 Subject: [PATCH 10/12] project: fix bytes/str encoding when updating git submodules 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 Reviewed-by: Mike Frysinger Tested-by: Mike Frysinger (cherry picked from commit 163d42eb43ba79677aae22fa859896010badba9b) --- project.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project.py b/project.py index 281ba4b7..77b97f73 100644 --- a/project.py +++ b/project.py @@ -1989,7 +1989,7 @@ class Project(object): gitmodules_lines = [] fd, temp_gitmodules_path = tempfile.mkstemp() try: - os.write(fd, p.stdout) + os.write(fd, p.stdout.encode('utf-8')) os.close(fd) cmd = ['config', '--file', temp_gitmodules_path, '--list'] p = GitCommand(None, cmd, capture_stdout=True, capture_stderr=True, From aeb2eee9d355b5753d04ef5045f91e98de1bf95b Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Tue, 11 Feb 2020 14:44:50 -0500 Subject: [PATCH 11/12] repo: bump launcher version This way we can push out the updated stable branch change. Change-Id: I72d5dab4523a10dfeb6529796892096aa80eba3c Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/254492 Reviewed-by: David Pursehouse Tested-by: Mike Frysinger --- repo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/repo b/repo index b9e29ba6..15d2ff85 100755 --- a/repo +++ b/repo @@ -35,7 +35,7 @@ if not REPO_REV: # limitations under the License. # increment this whenever we make important changes to this script -VERSION = (1, 26) +VERSION = (1, 27) # increment this if the MAINTAINER_KEYS block is modified KEYRING_VERSION = (1, 2) From d92076d930af11bb9a3025a6b2f12ca139c0436f Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Sun, 9 Feb 2020 16:20:06 -0500 Subject: [PATCH 12/12] Revert "Save cookies back to jar when fetching clone.bundle" 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 Tested-by: Mike Frysinger (cherry picked from commit dc1d0e0c7fffa5109048ac52a67aa97bb362ae3a) --- project.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project.py b/project.py index 77b97f73..8fdacc65 100644 --- a/project.py +++ b/project.py @@ -2398,7 +2398,7 @@ class Project(object): platform_utils.remove(tmpPath) with GetUrlCookieFile(srcUrl, quiet) as (cookiefile, proxy): if cookiefile: - cmd += ['--cookie', cookiefile, '--cookie-jar', cookiefile] + cmd += ['--cookie', cookiefile] if proxy: cmd += ['--proxy', proxy] elif 'http_proxy' in os.environ and 'darwin' == sys.platform: