[gnome-continuous-yocto/gnomeostree-3.28-rocko: 2082/8267] oeqa.utils.git.GitRepo: new arg to require topdir
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-continuous-yocto/gnomeostree-3.28-rocko: 2082/8267] oeqa.utils.git.GitRepo: new arg to require topdir
- Date: Sat, 16 Dec 2017 22:43:50 +0000 (UTC)
commit 979c735678e49a5b579dbfdc3d478aef8183531f
Author: Markus Lehtonen <markus lehtonen linux intel com>
Date: Mon Aug 15 13:56:58 2016 +0300
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.
(From OE-Core rev: 044c81bd916fbe7140d184eb103f74786cfef604)
Signed-off-by: Markus Lehtonen <markus lehtonen linux intel com>
Signed-off-by: Ross Burton <ross burton intel com>
Signed-off-by: Richard Purdie <richard purdie linuxfoundation org>
meta/lib/oeqa/utils/git.py | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
---
diff --git a/meta/lib/oeqa/utils/git.py b/meta/lib/oeqa/utils/git.py
index 0fc8112..ca84680 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):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]