diff options
-rw-r--r-- | git_command.py | 11 | ||||
-rwxr-xr-x | repo | 13 | ||||
-rw-r--r-- | subcmds/init.py | 14 | ||||
-rw-r--r-- | wrapper.py | 6 |
4 files changed, 19 insertions, 25 deletions
diff --git a/git_command.py b/git_command.py index 09ed1a79..1ec7c3ed 100644 --- a/git_command.py +++ b/git_command.py | |||
@@ -33,17 +33,6 @@ from wrapper import Wrapper | |||
33 | 33 | ||
34 | 34 | ||
35 | GIT = "git" | 35 | GIT = "git" |
36 | # NB: These do not need to be kept in sync with the repo launcher script. | ||
37 | # These may be much newer as it allows the repo launcher to roll between | ||
38 | # different repo releases while source versions might require a newer git. | ||
39 | # | ||
40 | # The soft version is when we start warning users that the version is old and | ||
41 | # we'll be dropping support for it. We'll refuse to work with versions older | ||
42 | # than the hard version. | ||
43 | # | ||
44 | # git-1.7 is in (EOL) Ubuntu Precise. git-1.9 is in Ubuntu Trusty. | ||
45 | MIN_GIT_VERSION_SOFT = (1, 9, 1) | ||
46 | MIN_GIT_VERSION_HARD = (1, 7, 2) | ||
47 | GIT_DIR = "GIT_DIR" | 36 | GIT_DIR = "GIT_DIR" |
48 | 37 | ||
49 | LAST_GITDIR = None | 38 | LAST_GITDIR = None |
@@ -210,7 +210,6 @@ GIT = "git" # our git command | |||
210 | # NB: The version of git that the repo launcher requires may be much older than | 210 | # NB: The version of git that the repo launcher requires may be much older than |
211 | # the version of git that the main repo source tree requires. Keeping this at | 211 | # the version of git that the main repo source tree requires. Keeping this at |
212 | # an older version also makes it easier for users to upgrade/rollback as needed. | 212 | # an older version also makes it easier for users to upgrade/rollback as needed. |
213 | # See requirements.json for versions. | ||
214 | MIN_GIT_VERSION = (1, 7, 9) # minimum supported git version | 213 | MIN_GIT_VERSION = (1, 7, 9) # minimum supported git version |
215 | repodir = ".repo" # name of repo's private directory | 214 | repodir = ".repo" # name of repo's private directory |
216 | S_repo = "repo" # special repo repository | 215 | S_repo = "repo" # special repo repository |
@@ -1237,13 +1236,13 @@ class Requirements: | |||
1237 | 1236 | ||
1238 | return cls(json_data) | 1237 | return cls(json_data) |
1239 | 1238 | ||
1240 | def _get_soft_ver(self, pkg): | 1239 | def get_soft_ver(self, pkg): |
1241 | """Return the soft version for |pkg| if it exists.""" | 1240 | """Return the soft version for |pkg| if it exists.""" |
1242 | return self.requirements.get(pkg, {}).get("soft", ()) | 1241 | return tuple(self.requirements.get(pkg, {}).get("soft", ())) |
1243 | 1242 | ||
1244 | def _get_hard_ver(self, pkg): | 1243 | def get_hard_ver(self, pkg): |
1245 | """Return the hard version for |pkg| if it exists.""" | 1244 | """Return the hard version for |pkg| if it exists.""" |
1246 | return self.requirements.get(pkg, {}).get("hard", ()) | 1245 | return tuple(self.requirements.get(pkg, {}).get("hard", ())) |
1247 | 1246 | ||
1248 | @staticmethod | 1247 | @staticmethod |
1249 | def _format_ver(ver): | 1248 | def _format_ver(ver): |
@@ -1253,8 +1252,8 @@ class Requirements: | |||
1253 | def assert_ver(self, pkg, curr_ver): | 1252 | def assert_ver(self, pkg, curr_ver): |
1254 | """Verify |pkg|'s |curr_ver| is new enough.""" | 1253 | """Verify |pkg|'s |curr_ver| is new enough.""" |
1255 | curr_ver = tuple(curr_ver) | 1254 | curr_ver = tuple(curr_ver) |
1256 | soft_ver = tuple(self._get_soft_ver(pkg)) | 1255 | soft_ver = tuple(self.get_soft_ver(pkg)) |
1257 | hard_ver = tuple(self._get_hard_ver(pkg)) | 1256 | hard_ver = tuple(self.get_hard_ver(pkg)) |
1258 | if curr_ver < hard_ver: | 1257 | if curr_ver < hard_ver: |
1259 | print( | 1258 | print( |
1260 | f'repo: error: Your version of "{pkg}" ' | 1259 | f'repo: error: Your version of "{pkg}" ' |
diff --git a/subcmds/init.py b/subcmds/init.py index e53d0338..7617bc1f 100644 --- a/subcmds/init.py +++ b/subcmds/init.py | |||
@@ -21,10 +21,9 @@ from command import MirrorSafeCommand | |||
21 | from error import RepoUnhandledExceptionError | 21 | from error import RepoUnhandledExceptionError |
22 | from error import UpdateManifestError | 22 | from error import UpdateManifestError |
23 | from git_command import git_require | 23 | from git_command import git_require |
24 | from git_command import MIN_GIT_VERSION_HARD | ||
25 | from git_command import MIN_GIT_VERSION_SOFT | ||
26 | from repo_logging import RepoLogger | 24 | from repo_logging import RepoLogger |
27 | from wrapper import Wrapper | 25 | from wrapper import Wrapper |
26 | from wrapper import WrapperDir | ||
28 | 27 | ||
29 | 28 | ||
30 | logger = RepoLogger(__file__) | 29 | logger = RepoLogger(__file__) |
@@ -331,13 +330,17 @@ to update the working directory files. | |||
331 | self.OptionParser.error("too many arguments to init") | 330 | self.OptionParser.error("too many arguments to init") |
332 | 331 | ||
333 | def Execute(self, opt, args): | 332 | def Execute(self, opt, args): |
334 | git_require(MIN_GIT_VERSION_HARD, fail=True) | 333 | wrapper = Wrapper() |
335 | if not git_require(MIN_GIT_VERSION_SOFT): | 334 | |
335 | reqs = wrapper.Requirements.from_dir(WrapperDir()) | ||
336 | git_require(reqs.get_hard_ver("git"), fail=True) | ||
337 | min_git_version_soft = reqs.get_soft_ver("git") | ||
338 | if not git_require(min_git_version_soft): | ||
336 | logger.warning( | 339 | logger.warning( |
337 | "repo: warning: git-%s+ will soon be required; " | 340 | "repo: warning: git-%s+ will soon be required; " |
338 | "please upgrade your version of git to maintain " | 341 | "please upgrade your version of git to maintain " |
339 | "support.", | 342 | "support.", |
340 | ".".join(str(x) for x in MIN_GIT_VERSION_SOFT), | 343 | ".".join(str(x) for x in min_git_version_soft), |
341 | ) | 344 | ) |
342 | 345 | ||
343 | rp = self.manifest.repoProject | 346 | rp = self.manifest.repoProject |
@@ -350,7 +353,6 @@ to update the working directory files. | |||
350 | 353 | ||
351 | # Handle new --repo-rev requests. | 354 | # Handle new --repo-rev requests. |
352 | if opt.repo_rev: | 355 | if opt.repo_rev: |
353 | wrapper = Wrapper() | ||
354 | try: | 356 | try: |
355 | remote_ref, rev = wrapper.check_repo_rev( | 357 | remote_ref, rev = wrapper.check_repo_rev( |
356 | rp.worktree, | 358 | rp.worktree, |
@@ -18,8 +18,12 @@ import importlib.util | |||
18 | import os | 18 | import os |
19 | 19 | ||
20 | 20 | ||
21 | def WrapperDir(): | ||
22 | return os.path.dirname(__file__) | ||
23 | |||
24 | |||
21 | def WrapperPath(): | 25 | def WrapperPath(): |
22 | return os.path.join(os.path.dirname(__file__), "repo") | 26 | return os.path.join(WrapperDir(), "repo") |
23 | 27 | ||
24 | 28 | ||
25 | @functools.lru_cache(maxsize=None) | 29 | @functools.lru_cache(maxsize=None) |