summaryrefslogtreecommitdiff
path: root/meta
diff options
context:
space:
mode:
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>2016-08-15 13:56:58 +0300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-08-25 22:59:56 +0100
commit044c81bd916fbe7140d184eb103f74786cfef604 (patch)
tree2e3701d64e685a1f58f318bd195cd0cf93b8fa15 /meta
parentdcba2302adab47b398f1ce7d09c38828ea9ae426 (diff)
downloadopenembedded-core-044c81bd916fbe7140d184eb103f74786cfef604.tar.gz
openembedded-core-044c81bd916fbe7140d184eb103f74786cfef604.tar.bz2
openembedded-core-044c81bd916fbe7140d184eb103f74786cfef604.zip
oeqa.utils.git.GitRepo: new arg to require topdir
Add a new 'is_topdir' argument to the GitRepo init method which validates that the given path is the top directory of a Git repository. Without this argument GitRepo also accepts subdirectories of a Git repository (in which case GitRepo will point to the parent directory that is the top directory of this repository) which may have undesired in some cases. Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
Diffstat (limited to 'meta')
-rw-r--r--meta/lib/oeqa/utils/git.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/meta/lib/oeqa/utils/git.py b/meta/lib/oeqa/utils/git.py
index 0fc8112321..ca84680118 100644
--- a/meta/lib/oeqa/utils/git.py
+++ b/meta/lib/oeqa/utils/git.py
@@ -4,6 +4,8 @@
# Released under the MIT license (see COPYING.MIT)
#
"""Git repository interactions"""
+import os
+
from oeqa.utils.commands import runCmd
@@ -13,9 +15,12 @@ class GitError(Exception):
class GitRepo(object):
"""Class representing a Git repository clone"""
- def __init__(self, cwd):
+ def __init__(self, path, is_topdir=False):
self.top_dir = self._run_git_cmd_at(['rev-parse', '--show-toplevel'],
- cwd)
+ path)
+ realpath = os.path.realpath(path)
+ if is_topdir and realpath != self.top_dir:
+ raise GitError("{} is not a Git top directory".format(realpath))
@staticmethod
def _run_git_cmd_at(git_args, cwd, **kwargs):