summaryrefslogtreecommitdiffstats
path: root/scripts/oe-git-archive
diff options
context:
space:
mode:
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>2017-03-24 16:17:29 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-03-27 08:15:06 +0100
commit746b6fbe6878de9af0c1e0b237d6fa2faebf4fb5 (patch)
treebbac6e48d2fc3a619e798646f4f86bcc387c18e1 /scripts/oe-git-archive
parente10d1ea0827c9ef22363946f917eebabfdb36a8b (diff)
downloadpoky-746b6fbe6878de9af0c1e0b237d6fa2faebf4fb5.tar.gz
scripts/oe-git-archive: implement --notes
Option for adding git-notes to the commit. [YOCTO #10582] (From OE-Core rev: 0ef7c143262a441c38235ea71832ca7714ce4a35) Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/oe-git-archive')
-rwxr-xr-xscripts/oe-git-archive21
1 files changed, 18 insertions, 3 deletions
diff --git a/scripts/oe-git-archive b/scripts/oe-git-archive
index 1805ab3260..ab19cb9aa3 100755
--- a/scripts/oe-git-archive
+++ b/scripts/oe-git-archive
@@ -83,7 +83,7 @@ def init_git_repo(path, no_create, bare):
83 return repo 83 return repo
84 84
85 85
86def git_commit_data(repo, data_dir, branch, message, exclude): 86def git_commit_data(repo, data_dir, branch, message, exclude, notes):
87 """Commit data into a Git repository""" 87 """Commit data into a Git repository"""
88 log.info("Committing data into to branch %s", branch) 88 log.info("Committing data into to branch %s", branch)
89 tmp_index = os.path.join(repo.git_dir, 'index.oe-git-archive') 89 tmp_index = os.path.join(repo.git_dir, 'index.oe-git-archive')
@@ -106,6 +106,12 @@ def git_commit_data(repo, data_dir, branch, message, exclude):
106 git_cmd += ['-p', parent] 106 git_cmd += ['-p', parent]
107 commit = repo.run_cmd(git_cmd, env_update) 107 commit = repo.run_cmd(git_cmd, env_update)
108 108
109 # Create git notes
110 for ref, filename in notes:
111 ref = ref.format(branch_name=branch)
112 repo.run_cmd(['notes', '--ref', ref, 'add',
113 '-F', os.path.abspath(filename), commit])
114
109 # Update branch head 115 # Update branch head
110 git_cmd = ['update-ref', 'refs/heads/' + branch, commit] 116 git_cmd = ['update-ref', 'refs/heads/' + branch, commit]
111 if parent: 117 if parent:
@@ -191,6 +197,13 @@ def parse_args(argv):
191 parser.add_argument('--exclude', action='append', default=[], 197 parser.add_argument('--exclude', action='append', default=[],
192 help="Glob to exclude files from the commit. Relative " 198 help="Glob to exclude files from the commit. Relative "
193 "to DATA_DIR. May be specified multiple times") 199 "to DATA_DIR. May be specified multiple times")
200 parser.add_argument('--notes', nargs=2, action='append', default=[],
201 metavar=('GIT_REF', 'FILE'),
202 help="Add a file as a note under refs/notes/GIT_REF. "
203 "{branch_name} in GIT_REF will be expanded to the "
204 "actual target branch name (specified by "
205 "--branch-name). This option may be specified "
206 "multiple times.")
194 parser.add_argument('data_dir', metavar='DATA_DIR', 207 parser.add_argument('data_dir', metavar='DATA_DIR',
195 help="Data to commit") 208 help="Data to commit")
196 return parser.parse_args(argv) 209 return parser.parse_args(argv)
@@ -229,7 +242,7 @@ def main(argv=None):
229 242
230 # Commit data 243 # Commit data
231 commit = git_commit_data(data_repo, args.data_dir, branch_name, 244 commit = git_commit_data(data_repo, args.data_dir, branch_name,
232 commit_msg, args.exclude) 245 commit_msg, args.exclude, args.notes)
233 246
234 # Create tag 247 # Create tag
235 if tag_name: 248 if tag_name:
@@ -242,7 +255,9 @@ def main(argv=None):
242 # If no remote is given we push with the default settings from 255 # If no remote is given we push with the default settings from
243 # gitconfig 256 # gitconfig
244 if args.push is not True: 257 if args.push is not True:
245 cmd.extend([args.push, branch_name]) 258 notes_refs = ['refs/notes/' + ref.format(branch_name=branch_name)
259 for ref, _ in args.notes]
260 cmd.extend([args.push, branch_name] + notes_refs)
246 log.info("Pushing data to remote") 261 log.info("Pushing data to remote")
247 data_repo.run_cmd(cmd) 262 data_repo.run_cmd(cmd)
248 263