summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>2017-02-03 10:53:32 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-02-15 20:06:41 -0800
commite3f06659c26c5758c7eeac060283dd8e3bfd7f8f (patch)
tree909a5d0f10df815d4fdb0b40e4ddd7ebd5e1b04d /meta
parent69c7907bd9c8ea49d1499a8ef044a89d71c84885 (diff)
downloadpoky-e3f06659c26c5758c7eeac060283dd8e3bfd7f8f.tar.gz
oeqa.utils.git: support bare repos
[YOCTO #10582] (From OE-Core rev: a223b4d26c8834485cbec1f10defca42301550f7) 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>
Diffstat (limited to 'meta')
-rw-r--r--meta/lib/oeqa/utils/git.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/meta/lib/oeqa/utils/git.py b/meta/lib/oeqa/utils/git.py
index 5dd90e0d83..e0cb3f0db2 100644
--- a/meta/lib/oeqa/utils/git.py
+++ b/meta/lib/oeqa/utils/git.py
@@ -16,12 +16,17 @@ class GitError(Exception):
16class GitRepo(object): 16class GitRepo(object):
17 """Class representing a Git repository clone""" 17 """Class representing a Git repository clone"""
18 def __init__(self, path, is_topdir=False): 18 def __init__(self, path, is_topdir=False):
19 self.top_dir = self._run_git_cmd_at(['rev-parse', '--show-toplevel'],
20 path)
21 git_dir = self._run_git_cmd_at(['rev-parse', '--git-dir'], path) 19 git_dir = self._run_git_cmd_at(['rev-parse', '--git-dir'], path)
22 git_dir = git_dir if os.path.isabs(git_dir) else os.path.join(path, git_dir) 20 git_dir = git_dir if os.path.isabs(git_dir) else os.path.join(path, git_dir)
23 self.git_dir = os.path.realpath(git_dir) 21 self.git_dir = os.path.realpath(git_dir)
24 22
23 if self._run_git_cmd_at(['rev-parse', '--is-bare-repository'], path) == 'true':
24 self.bare = True
25 self.top_dir = self.git_dir
26 else:
27 self.bare = False
28 self.top_dir = self._run_git_cmd_at(['rev-parse', '--show-toplevel'],
29 path)
25 realpath = os.path.realpath(path) 30 realpath = os.path.realpath(path)
26 if is_topdir and realpath != self.top_dir: 31 if is_topdir and realpath != self.top_dir:
27 raise GitError("{} is not a Git top directory".format(realpath)) 32 raise GitError("{} is not a Git top directory".format(realpath))
@@ -40,9 +45,12 @@ class GitRepo(object):
40 return ret.output.strip() 45 return ret.output.strip()
41 46
42 @staticmethod 47 @staticmethod
43 def init(path): 48 def init(path, bare=False):
44 """Initialize a new Git repository""" 49 """Initialize a new Git repository"""
45 GitRepo._run_git_cmd_at('init', cwd=path) 50 cmd = ['init']
51 if bare:
52 cmd.append('--bare')
53 GitRepo._run_git_cmd_at(cmd, cwd=path)
46 return GitRepo(path, is_topdir=True) 54 return GitRepo(path, is_topdir=True)
47 55
48 def run_cmd(self, git_args, env_update=None): 56 def run_cmd(self, git_args, env_update=None):