From 4a1fba912e1477ca325ed6aeb001766c2e29b3c2 Mon Sep 17 00:00:00 2001 From: Jan Kiszka Date: Fri, 24 Aug 2018 19:18:07 +0200 Subject: [PATCH] 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 --- kas/repos.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kas/repos.py b/kas/repos.py index 46550ce..417280b 100644 --- a/kas/repos.py +++ b/kas/repos.py @@ -123,7 +123,7 @@ class Repo: raise NotImplementedError('Repo typ "%s" not supported.' % typ) @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. """ @@ -137,7 +137,7 @@ class Repo: if ret == 0: return output.strip() - return path + return path if fallback else None class RepoImpl(Repo):