superproject: require git version 2.28.0 or higher.

Tested the code with the following commands.

$ repo init --use-superproject -u https://android.googlesource.com/platform/manifest

+ Tested for the wrong git version.
  $ repo_dev init --use-superproject -u https://android.googlesource.com/platform/manifest
  WARNING: --use-superproject is experimental and not for general use
  superproject requires a git version 2.28 or later
  error: git update of superproject failed

$ ./run_tests -v

Bug: https://crbug.com/gerrit/14617
Bug: [google internal] b/189846687
Change-Id: I5cd4158ea29b3b3c8c81234f4e818165de346e63
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/308442
Tested-by: Raman Tenneti <rtenneti@google.com>
Reviewed-by: Mike Frysinger <vapier@google.com>
This commit is contained in:
Raman Tenneti 2021-06-02 10:05:54 -07:00
parent 5d58c18146
commit e253b43e17

View File

@ -26,7 +26,7 @@ import hashlib
import os import os
import sys import sys
from git_command import GitCommand from git_command import git_require, GitCommand
from git_refs import R_HEADS from git_refs import R_HEADS
_SUPERPROJECT_GIT_NAME = 'superproject.git' _SUPERPROJECT_GIT_NAME = 'superproject.git'
@ -120,6 +120,9 @@ class Superproject(object):
print('git fetch missing drectory: %s' % self._work_git, print('git fetch missing drectory: %s' % self._work_git,
file=sys.stderr) file=sys.stderr)
return False return False
if not git_require((2, 28, 0)):
print('superproject requires a git version 2.28 or later', file=sys.stderr)
return False
cmd = ['fetch', url, '--depth', '1', '--force', '--no-tags', '--filter', 'blob:none'] cmd = ['fetch', url, '--depth', '1', '--force', '--no-tags', '--filter', 'blob:none']
if self._branch: if self._branch:
cmd += [self._branch + ':' + self._branch] cmd += [self._branch + ':' + self._branch]