summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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):