Compare commits

...

12 Commits

Author SHA1 Message Date
d92076d930 Revert "Save cookies back to jar when fetching clone.bundle"
This reverts commit 4abf8e6ef8.

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>
(cherry picked from commit dc1d0e0c7f)
2020-02-11 21:03:35 -05:00
aeb2eee9d3 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 <dpursehouse@collab.net>
Tested-by: Mike Frysinger <vapier@google.com>
2020-02-12 00:12:14 +00:00
45d1c372a7 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 <mmortensen@google.com>
Reviewed-by: Mike Frysinger <vapier@google.com>
Tested-by: Mike Frysinger <vapier@google.com>
(cherry picked from commit 163d42eb43)
2020-02-11 14:46:13 -05:00
19607b2817 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 <dpursehouse@collab.net>
Tested-by: Mike Frysinger <vapier@google.com>
(cherry picked from commit 563f1a6512)
2020-02-11 14:44:29 -05:00
68744dbc01 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 <vapier@google.com>
Reviewed-by: David Pursehouse <dpursehouse@collab.net>
Tested-by: Jiri Tyr <jiri.tyr@gmail.com>
(cherry picked from commit 83a3227b62)
2020-02-10 23:31:45 -05:00
ef412624e9 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 <vapier@google.com>
Reviewed-by: David Pursehouse <dpursehouse@collab.net>
(cherry picked from commit e7c91889a6)
2020-02-10 23:31:03 -05:00
a06ab7d28b 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 <dpursehouse@collab.net>
Tested-by: Mike Frysinger <vapier@google.com>
(cherry picked from commit 1b117db767)
2020-02-10 23:30:58 -05:00
471a7ed5f7 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 <jrn@google.com>
Tested-by: Mike Frysinger <vapier@google.com>
(cherry picked from commit ded477dbb9)
2020-02-10 23:28:40 -05:00
619a2b5887 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 <vapier@google.com>
Tested-by: Dan Willemsen <dwillemsen@google.com>
(cherry picked from commit 93293ca47f)
2020-02-07 15:54:52 -05:00
ab15e42fa4 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 6856f98467
  "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>
(cherry picked from commit f7b64e3350)
2020-02-06 09:19:35 -05:00
75c02fe4cb 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 66098f707a)
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/253392
Tested-by: Mike Frysinger <vapier@google.com>
Reviewed-by: Mike Frysinger <vapier@google.com>
2020-02-05 18:04:11 +00:00
afd1b4023f 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 <dpursehouse@collab.net>
Tested-by: Mike Frysinger <vapier@google.com>
2020-02-05 02:56:08 +00:00
10 changed files with 25 additions and 15 deletions

View File

@ -528,7 +528,7 @@ def GetUrlCookieFile(url, quiet):
cookiefile = None cookiefile = None
proxy = None proxy = None
for line in p.stdout: for line in p.stdout:
line = line.strip() line = line.strip().decode('utf-8')
if line.startswith(cookieprefix): if line.startswith(cookieprefix):
cookiefile = os.path.expanduser(line[len(cookieprefix):]) cookiefile = os.path.expanduser(line[len(cookieprefix):])
if line.startswith(proxyprefix): if line.startswith(proxyprefix):
@ -540,7 +540,7 @@ def GetUrlCookieFile(url, quiet):
finally: finally:
p.stdin.close() p.stdin.close()
if p.wait(): if p.wait():
err_msg = p.stderr.read() err_msg = p.stderr.read().decode('utf-8')
if ' -print_config' in err_msg: if ' -print_config' in err_msg:
pass # Persistent proxy doesn't support -print_config. pass # Persistent proxy doesn't support -print_config.
elif not quiet: elif not quiet:

0
pager.py Executable file → Normal file
View File

9
project.py Executable file → Normal file
View File

@ -1989,7 +1989,7 @@ class Project(object):
gitmodules_lines = [] gitmodules_lines = []
fd, temp_gitmodules_path = tempfile.mkstemp() fd, temp_gitmodules_path = tempfile.mkstemp()
try: try:
os.write(fd, p.stdout) os.write(fd, p.stdout.encode('utf-8'))
os.close(fd) os.close(fd)
cmd = ['config', '--file', temp_gitmodules_path, '--list'] cmd = ['config', '--file', temp_gitmodules_path, '--list']
p = GitCommand(None, cmd, capture_stdout=True, capture_stderr=True, p = GitCommand(None, cmd, capture_stdout=True, capture_stderr=True,
@ -2252,7 +2252,10 @@ class Project(object):
spec.append('tag') spec.append('tag')
spec.append(tag_name) 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 if (not self.manifest.IsMirror and is_sha1 and depth
and git_require((1, 8, 3))): and git_require((1, 8, 3))):
# Shallow checkout of a specific commit, fetch from that commit and not # Shallow checkout of a specific commit, fetch from that commit and not
@ -2395,7 +2398,7 @@ class Project(object):
platform_utils.remove(tmpPath) platform_utils.remove(tmpPath)
with GetUrlCookieFile(srcUrl, quiet) as (cookiefile, proxy): with GetUrlCookieFile(srcUrl, quiet) as (cookiefile, proxy):
if cookiefile: if cookiefile:
cmd += ['--cookie', cookiefile, '--cookie-jar', cookiefile] cmd += ['--cookie', cookiefile]
if proxy: if proxy:
cmd += ['--proxy', proxy] cmd += ['--proxy', proxy]
elif 'http_proxy' in os.environ and 'darwin' == sys.platform: elif 'http_proxy' in os.environ and 'darwin' == sys.platform:

10
repo
View File

@ -16,7 +16,9 @@ import os
REPO_URL = os.environ.get('REPO_URL', None) REPO_URL = os.environ.get('REPO_URL', None)
if not REPO_URL: if not REPO_URL:
REPO_URL = 'https://gerrit.googlesource.com/git-repo' REPO_URL = 'https://gerrit.googlesource.com/git-repo'
REPO_REV = 'stable' REPO_REV = os.environ.get('REPO_REV')
if not REPO_REV:
REPO_REV = 'repo-1'
# Copyright (C) 2008 Google Inc. # Copyright (C) 2008 Google Inc.
# #
@ -33,7 +35,7 @@ REPO_REV = 'stable'
# limitations under the License. # limitations under the License.
# increment this whenever we make important changes to this script # 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 # increment this if the MAINTAINER_KEYS block is modified
KEYRING_VERSION = (1, 2) KEYRING_VERSION = (1, 2)
@ -235,10 +237,10 @@ group.add_option('--no-tags',
group = init_optparse.add_option_group('repo Version options') group = init_optparse.add_option_group('repo Version options')
group.add_option('--repo-url', group.add_option('--repo-url',
dest='repo_url', dest='repo_url',
help='repo repository location', metavar='URL') help='repo repository location ($REPO_URL)', metavar='URL')
group.add_option('--repo-branch', group.add_option('--repo-branch',
dest='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', group.add_option('--no-repo-verify',
dest='no_repo_verify', action='store_true', dest='no_repo_verify', action='store_true',
help='do not verify repo source code') help='do not verify repo source code')

View File

@ -1,4 +1,4 @@
#!/usr/bin/python #!/usr/bin/env python
# -*- coding:utf-8 -*- # -*- coding:utf-8 -*-
# Copyright 2019 The Android Open Source Project # Copyright 2019 The Android Open Source Project
# #

View File

@ -1,4 +1,4 @@
#!/usr/bin/python #!/usr/bin/env python
# -*- coding:utf-8 -*- # -*- coding:utf-8 -*-
# Copyright 2019 The Android Open Source Project # Copyright 2019 The Android Open Source Project
# #

0
subcmds/download.py Executable file → Normal file
View File

View File

@ -366,7 +366,7 @@ def DoWork(project, mirror, opt, cmd, shell, cnt, config):
while not s_in.is_done: while not s_in.is_done:
in_ready = s_in.select() in_ready = s_in.select()
for s in in_ready: for s in in_ready:
buf = s.read() buf = s.read().decode()
if not buf: if not buf:
s.close() s.close()
s_in.remove(s) s_in.remove(s)

View File

@ -50,7 +50,7 @@ use for this GITC client.
""" """
def _Options(self, p): 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 = p.add_option_group('GITC options')
g.add_option('-f', '--manifest-file', g.add_option('-f', '--manifest-file',
dest='manifest_file', dest='manifest_file',

View File

@ -81,7 +81,7 @@ manifest, a subsequent `repo sync` (or `repo sync -d`) is necessary
to update the working directory files. to update the working directory files.
""" """
def _Options(self, p): def _Options(self, p, gitc_init=False):
# Logging # Logging
g = p.add_option_group('Logging options') g = p.add_option_group('Logging options')
g.add_option('-q', '--quiet', g.add_option('-q', '--quiet',
@ -96,7 +96,12 @@ to update the working directory files.
g.add_option('-b', '--manifest-branch', g.add_option('-b', '--manifest-branch',
dest='manifest_branch', dest='manifest_branch',
help='manifest branch or revision', metavar='REVISION') 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 not gitc_init:
cbr_opts += ['-c']
g.add_option(*cbr_opts,
dest='current_branch_only', action='store_true', dest='current_branch_only', action='store_true',
help='fetch only current manifest branch from server') help='fetch only current manifest branch from server')
g.add_option('-m', '--manifest-name', g.add_option('-m', '--manifest-name',