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>
This commit is contained in:
parent
e10d1ea082
commit
746b6fbe68
|
@ -83,7 +83,7 @@ def init_git_repo(path, no_create, bare):
|
||||||
return repo
|
return repo
|
||||||
|
|
||||||
|
|
||||||
def git_commit_data(repo, data_dir, branch, message, exclude):
|
def git_commit_data(repo, data_dir, branch, message, exclude, notes):
|
||||||
"""Commit data into a Git repository"""
|
"""Commit data into a Git repository"""
|
||||||
log.info("Committing data into to branch %s", branch)
|
log.info("Committing data into to branch %s", branch)
|
||||||
tmp_index = os.path.join(repo.git_dir, 'index.oe-git-archive')
|
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):
|
||||||
git_cmd += ['-p', parent]
|
git_cmd += ['-p', parent]
|
||||||
commit = repo.run_cmd(git_cmd, env_update)
|
commit = repo.run_cmd(git_cmd, env_update)
|
||||||
|
|
||||||
|
# Create git notes
|
||||||
|
for ref, filename in notes:
|
||||||
|
ref = ref.format(branch_name=branch)
|
||||||
|
repo.run_cmd(['notes', '--ref', ref, 'add',
|
||||||
|
'-F', os.path.abspath(filename), commit])
|
||||||
|
|
||||||
# Update branch head
|
# Update branch head
|
||||||
git_cmd = ['update-ref', 'refs/heads/' + branch, commit]
|
git_cmd = ['update-ref', 'refs/heads/' + branch, commit]
|
||||||
if parent:
|
if parent:
|
||||||
|
@ -191,6 +197,13 @@ def parse_args(argv):
|
||||||
parser.add_argument('--exclude', action='append', default=[],
|
parser.add_argument('--exclude', action='append', default=[],
|
||||||
help="Glob to exclude files from the commit. Relative "
|
help="Glob to exclude files from the commit. Relative "
|
||||||
"to DATA_DIR. May be specified multiple times")
|
"to DATA_DIR. May be specified multiple times")
|
||||||
|
parser.add_argument('--notes', nargs=2, action='append', default=[],
|
||||||
|
metavar=('GIT_REF', 'FILE'),
|
||||||
|
help="Add a file as a note under refs/notes/GIT_REF. "
|
||||||
|
"{branch_name} in GIT_REF will be expanded to the "
|
||||||
|
"actual target branch name (specified by "
|
||||||
|
"--branch-name). This option may be specified "
|
||||||
|
"multiple times.")
|
||||||
parser.add_argument('data_dir', metavar='DATA_DIR',
|
parser.add_argument('data_dir', metavar='DATA_DIR',
|
||||||
help="Data to commit")
|
help="Data to commit")
|
||||||
return parser.parse_args(argv)
|
return parser.parse_args(argv)
|
||||||
|
@ -229,7 +242,7 @@ def main(argv=None):
|
||||||
|
|
||||||
# Commit data
|
# Commit data
|
||||||
commit = git_commit_data(data_repo, args.data_dir, branch_name,
|
commit = git_commit_data(data_repo, args.data_dir, branch_name,
|
||||||
commit_msg, args.exclude)
|
commit_msg, args.exclude, args.notes)
|
||||||
|
|
||||||
# Create tag
|
# Create tag
|
||||||
if tag_name:
|
if tag_name:
|
||||||
|
@ -242,7 +255,9 @@ def main(argv=None):
|
||||||
# If no remote is given we push with the default settings from
|
# If no remote is given we push with the default settings from
|
||||||
# gitconfig
|
# gitconfig
|
||||||
if args.push is not True:
|
if args.push is not True:
|
||||||
cmd.extend([args.push, branch_name])
|
notes_refs = ['refs/notes/' + ref.format(branch_name=branch_name)
|
||||||
|
for ref, _ in args.notes]
|
||||||
|
cmd.extend([args.push, branch_name] + notes_refs)
|
||||||
log.info("Pushing data to remote")
|
log.info("Pushing data to remote")
|
||||||
data_repo.run_cmd(cmd)
|
data_repo.run_cmd(cmd)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue