repos: Add fallback parameter to get_root_path()
This allows the caller to differentiate between "no repo found" and "result points to repo". Default behavior remain unchanged (return provided path itself if no repo is found). Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
This commit is contained in:
		
				
					committed by
					
						
						Daniel Wagner
					
				
			
			
				
	
			
			
			
						parent
						
							b349f86457
						
					
				
				
					commit
					4a1fba912e
				
			@@ -123,7 +123,7 @@ class Repo:
 | 
				
			|||||||
        raise NotImplementedError('Repo typ "%s" not supported.' % typ)
 | 
					        raise NotImplementedError('Repo typ "%s" not supported.' % typ)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @staticmethod
 | 
					    @staticmethod
 | 
				
			||||||
    def get_root_path(path):
 | 
					    def get_root_path(path, fallback=True):
 | 
				
			||||||
        """
 | 
					        """
 | 
				
			||||||
            Check if path is a version control repo and return its root path.
 | 
					            Check if path is a version control repo and return its root path.
 | 
				
			||||||
        """
 | 
					        """
 | 
				
			||||||
@@ -137,7 +137,7 @@ class Repo:
 | 
				
			|||||||
        if ret == 0:
 | 
					        if ret == 0:
 | 
				
			||||||
            return output.strip()
 | 
					            return output.strip()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return path
 | 
					        return path if fallback else None
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class RepoImpl(Repo):
 | 
					class RepoImpl(Repo):
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user