summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>2017-02-03 16:40:35 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-02-15 20:06:41 -0800
commit3c862c647c03df6ed6c01f3d06fc9adf11f0f6da (patch)
tree0a0a4355b55a9e348539176e37fab60e65d5a729
parente3f06659c26c5758c7eeac060283dd8e3bfd7f8f (diff)
downloadpoky-3c862c647c03df6ed6c01f3d06fc9adf11f0f6da.tar.gz
scripts/oe-git-archive: support creating bare repositories
[YOCTO #10582] (From OE-Core rev: 995cb3bf2b3303067828a1358051e5e11caad843) 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>
-rwxr-xr-xscripts/oe-git-archive11
1 files changed, 7 insertions, 4 deletions
diff --git a/scripts/oe-git-archive b/scripts/oe-git-archive
index 419332ded1..117118b04e 100755
--- a/scripts/oe-git-archive
+++ b/scripts/oe-git-archive
@@ -55,7 +55,7 @@ def format_str(string, fields):
55 string, err, ', '.join(sorted(fields.keys())))) 55 string, err, ', '.join(sorted(fields.keys()))))
56 56
57 57
58def init_git_repo(path, no_create): 58def init_git_repo(path, no_create, bare):
59 """Initialize local Git repository""" 59 """Initialize local Git repository"""
60 path = os.path.abspath(path) 60 path = os.path.abspath(path)
61 if os.path.isfile(path): 61 if os.path.isfile(path):
@@ -72,7 +72,7 @@ def init_git_repo(path, no_create):
72 raise ArchiveError("Failed to mkdir {}: {}".format(path, err)) 72 raise ArchiveError("Failed to mkdir {}: {}".format(path, err))
73 if not os.listdir(path): 73 if not os.listdir(path):
74 log.info("Initializing a new Git repo at %s", path) 74 log.info("Initializing a new Git repo at %s", path)
75 repo = GitRepo.init(path) 75 repo = GitRepo.init(path, bare)
76 try: 76 try:
77 repo = GitRepo(path, is_topdir=True) 77 repo = GitRepo(path, is_topdir=True)
78 except GitError: 78 except GitError:
@@ -108,7 +108,7 @@ def git_commit_data(repo, data_dir, branch, message):
108 repo.run_cmd(git_cmd) 108 repo.run_cmd(git_cmd)
109 109
110 # Update current HEAD, if we're on branch 'branch' 110 # Update current HEAD, if we're on branch 'branch'
111 if repo.get_current_branch() == branch: 111 if not repo.bare and repo.get_current_branch() == branch:
112 log.info("Updating %s HEAD to latest commit", repo.top_dir) 112 log.info("Updating %s HEAD to latest commit", repo.top_dir)
113 repo.run_cmd('reset --hard') 113 repo.run_cmd('reset --hard')
114 114
@@ -158,6 +158,9 @@ def parse_args(argv):
158 parser.add_argument('--no-create', action='store_true', 158 parser.add_argument('--no-create', action='store_true',
159 help="If GIT_DIR is not a valid Git repository, do not " 159 help="If GIT_DIR is not a valid Git repository, do not "
160 "try to create one") 160 "try to create one")
161 parser.add_argument('--bare', action='store_true',
162 help="Initialize a bare repository when creating a "
163 "new one")
161 parser.add_argument('--push', '-p', nargs='?', default=False, const=True, 164 parser.add_argument('--push', '-p', nargs='?', default=False, const=True,
162 help="Push to remote") 165 help="Push to remote")
163 parser.add_argument('--branch-name', '-b', 166 parser.add_argument('--branch-name', '-b',
@@ -195,7 +198,7 @@ def main(argv=None):
195 if not os.path.isdir(args.data_dir): 198 if not os.path.isdir(args.data_dir):
196 raise ArchiveError("Not a directory: {}".format(args.data_dir)) 199 raise ArchiveError("Not a directory: {}".format(args.data_dir))
197 200
198 data_repo = init_git_repo(args.git_dir, args.no_create) 201 data_repo = init_git_repo(args.git_dir, args.no_create, args.bare)
199 202
200 # Get keywords to be used in tag and branch names and messages 203 # Get keywords to be used in tag and branch names and messages
201 metadata = metadata_from_bb() 204 metadata = metadata_from_bb()