add support to override refspec of repos
This patch adds the top-level `overrides` entry, which is used to override (or pin) the refspec of repositories. The main difference to a direct override is that this logic only applies to repos that are already defined. By that, a superset of all repos can be added to this entry (similar to a global lockfile), but only the currently active ones are affected. A new top-level keyword is required because everything below the "repos" keyword is potentially defined by "default" values. For the locking mechanism, a clear separation between overrides (only override if existing) and definitions is required to be able to define a global lockfile with all possible repos, while just defining some repos. Proposed-by: Ross Burton <ross@burtonini.com> Signed-off-by: Felix Moessbauer <felix.moessbauer@siemens.com> [Jan: also bump __file_version__] Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
This commit is contained in:
		
				
					committed by
					
						 Jan Kiszka
						Jan Kiszka
					
				
			
			
				
	
			
			
			
						parent
						
							6131038c00
						
					
				
				
					commit
					3e0dd10416
				
			| @@ -28,5 +28,5 @@ __copyright__ = 'Copyright (c) Siemens AG, 2017-2020' | ||||
| __version__ = '3.2.3' | ||||
|  | ||||
| # Please update docs/format-changelog.rst when changing the file version. | ||||
| __file_version__ = 13 | ||||
| __file_version__ = 14 | ||||
| __compatible_file_version__ = 1 | ||||
|   | ||||
| @@ -104,11 +104,14 @@ class Config: | ||||
|             `name`. | ||||
|         """ | ||||
|         repo_defaults = self._config.get('defaults', {}).get('repos', {}) | ||||
|         overrides = self._config.get('overrides', {}) \ | ||||
|                                 .get('repos', {}).get(name, {}) | ||||
|         config = self.get_repos_config()[name] or {} | ||||
|         return Repo.factory(name, | ||||
|                             config, | ||||
|                             repo_defaults, | ||||
|                             self.top_repo_path) | ||||
|                             self.top_repo_path, | ||||
|                             overrides) | ||||
|  | ||||
|     def _get_repo_dict(self): | ||||
|         """ | ||||
|   | ||||
| @@ -90,7 +90,8 @@ class Repo: | ||||
|                                 self.path, self._layers) | ||||
|  | ||||
|     @staticmethod | ||||
|     def factory(name, repo_config, repo_defaults, repo_fallback_path): | ||||
|     def factory(name, repo_config, repo_defaults, repo_fallback_path, | ||||
|                 repo_overrides={}): | ||||
|         """ | ||||
|             Returns a Repo instance depending on params. | ||||
|         """ | ||||
| @@ -119,8 +120,8 @@ class Repo: | ||||
|         url = repo_config.get('url', None) | ||||
|         name = repo_config.get('name', name) | ||||
|         typ = repo_config.get('type', 'git') | ||||
|         refspec = repo_config.get('refspec', | ||||
|                                   repo_defaults.get('refspec', None)) | ||||
|         refspec = repo_overrides.get('refspec', repo_config.get('refspec', | ||||
|                                      repo_defaults.get('refspec', None))) | ||||
|         if refspec is None and url is not None: | ||||
|             logging.error('No refspec specified for repository "%s". This is ' | ||||
|                           'only allowed for local repositories.', name) | ||||
|   | ||||
| @@ -89,6 +89,24 @@ | ||||
|                 } | ||||
|             } | ||||
|         }, | ||||
|         "overrides": { | ||||
|             "type": "object", | ||||
|             "additionalProperties": false, | ||||
|             "properties": { | ||||
|                 "repos": { | ||||
|                     "type": "object", | ||||
|                     "additionalProperties": { | ||||
|                         "type": "object", | ||||
|                         "additionalProperties": false, | ||||
|                         "properties": { | ||||
|                             "refspec" : { | ||||
|                                 "type": "string" | ||||
|                             } | ||||
|                         } | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|         }, | ||||
|         "machine": { | ||||
|             "type": "string" | ||||
|         }, | ||||
|   | ||||
		Reference in New Issue
	
	Block a user