repos: also move version control call out of config.py
Signed-off-by: Henning Schild <henning.schild@siemens.com>
This commit is contained in:
		
				
					committed by
					
						 Daniel Wagner
						Daniel Wagner
					
				
			
			
				
	
			
			
			
						parent
						
							941fa38a2d
						
					
				
				
					commit
					b5b2766b24
				
			| @@ -49,7 +49,7 @@ except ImportError: | |||||||
|         return platform.dist()[0] |         return platform.dist()[0] | ||||||
|  |  | ||||||
| from .repos import Repo | from .repos import Repo | ||||||
| from .libkas import run_cmd, repos_fetch | from .libkas import repos_fetch | ||||||
|  |  | ||||||
| __license__ = 'MIT' | __license__ = 'MIT' | ||||||
| __copyright__ = 'Copyright (c) Siemens AG, 2017' | __copyright__ = 'Copyright (c) Siemens AG, 2017' | ||||||
| @@ -193,17 +193,8 @@ class Config: | |||||||
|             if url is None: |             if url is None: | ||||||
|                 # No git operation on repository |                 # No git operation on repository | ||||||
|                 if path is None: |                 if path is None: | ||||||
|                     # In-tree configuration |                     path = Repo.get_root_path(os.path.dirname(self.filename), | ||||||
|                     path = os.path.dirname(self.filename) |                                               self.environ) | ||||||
|                     (ret, output) = run_cmd(['git', |  | ||||||
|                                              'rev-parse', |  | ||||||
|                                              '--show-toplevel'], |  | ||||||
|                                             cwd=path, |  | ||||||
|                                             env=self.environ, |  | ||||||
|                                             fail=False, |  | ||||||
|                                             liveupdate=False) |  | ||||||
|                     if ret == 0: |  | ||||||
|                         path = output.strip() |  | ||||||
|                     logging.info('Using %s as root for repository %s', path, |                     logging.info('Using %s as root for repository %s', path, | ||||||
|                                  name) |                                  name) | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										17
									
								
								kas/repos.py
									
									
									
									
									
								
							
							
						
						
									
										17
									
								
								kas/repos.py
									
									
									
									
									
								
							| @@ -155,3 +155,20 @@ class Repo: | |||||||
|         run_cmd(['git', 'checkout', '-q', |         run_cmd(['git', 'checkout', '-q', | ||||||
|                  '{refspec}'.format(refspec=self.refspec)], |                  '{refspec}'.format(refspec=self.refspec)], | ||||||
|                 cwd=self.path) |                 cwd=self.path) | ||||||
|  |  | ||||||
|  |     @staticmethod | ||||||
|  |     def get_root_path(path, environ): | ||||||
|  |         """ | ||||||
|  |             Check if path is a version control repo and return its root path. | ||||||
|  |         """ | ||||||
|  |         (ret, output) = run_cmd(['git', | ||||||
|  |                                  'rev-parse', | ||||||
|  |                                  '--show-toplevel'], | ||||||
|  |                                 cwd=path, | ||||||
|  |                                 env=environ, | ||||||
|  |                                 fail=False, | ||||||
|  |                                 liveupdate=False) | ||||||
|  |         if ret == 0: | ||||||
|  |             return output.strip() | ||||||
|  |  | ||||||
|  |         return path | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user