summaryrefslogtreecommitdiff
path: root/meta/lib
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:27 -0800
commita223b4d26c8834485cbec1f10defca42301550f7 (patch)
treebbd4da782911da122e3008d2657a03ecc0b3e797 /meta/lib
parent801e612b137b9d5366639d5b1635151347da5983 (diff)
downloadopenembedded-core-a223b4d26c8834485cbec1f10defca42301550f7.tar.gz
openembedded-core-a223b4d26c8834485cbec1f10defca42301550f7.tar.bz2
openembedded-core-a223b4d26c8834485cbec1f10defca42301550f7.zip
oeqa.utils.git: support bare repos
[YOCTO #10582] Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
Diffstat (limited to 'meta/lib')
-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):
class GitRepo(object):
"""Class representing a Git repository clone"""
def __init__(self, path, is_topdir=False):
- self.top_dir = self._run_git_cmd_at(['rev-parse', '--show-toplevel'],
- path)
git_dir = self._run_git_cmd_at(['rev-parse', '--git-dir'], path)
git_dir = git_dir if os.path.isabs(git_dir) else os.path.join(path, git_dir)
self.git_dir = os.path.realpath(git_dir)
+ if self._run_git_cmd_at(['rev-parse', '--is-bare-repository'], path) == 'true':
+ self.bare = True
+ self.top_dir = self.git_dir
+ else:
+ self.bare = False
+ self.top_dir = self._run_git_cmd_at(['rev-parse', '--show-toplevel'],
+ path)
realpath = os.path.realpath(path)
if is_topdir and realpath != self.top_dir:
raise GitError("{} is not a Git top directory".format(realpath))
@@ -40,9 +45,12 @@ class GitRepo(object):
return ret.output.strip()
@staticmethod
- def init(path):
+ def init(path, bare=False):
"""Initialize a new Git repository"""
- GitRepo._run_git_cmd_at('init', cwd=path)
+ cmd = ['init']
+ if bare:
+ cmd.append('--bare')
+ GitRepo._run_git_cmd_at(cmd, cwd=path)
return GitRepo(path, is_topdir=True)
def run_cmd(self, git_args, env_update=None):