scripts/oe-git-archive: implement --exclude
May be used for excluding certain files from the commit. [YOCTO #10582] (From OE-Core rev: fd125cf694bebefbe9a98fd1bb199d6ca472dad5) 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
60f32a00dc
commit
e10d1ea082
|
@ -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):
|
def git_commit_data(repo, data_dir, branch, message, exclude):
|
||||||
"""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')
|
||||||
|
@ -92,6 +92,11 @@ def git_commit_data(repo, data_dir, branch, message):
|
||||||
env_update = {'GIT_INDEX_FILE': tmp_index,
|
env_update = {'GIT_INDEX_FILE': tmp_index,
|
||||||
'GIT_WORK_TREE': os.path.abspath(data_dir)}
|
'GIT_WORK_TREE': os.path.abspath(data_dir)}
|
||||||
repo.run_cmd('add .', env_update)
|
repo.run_cmd('add .', env_update)
|
||||||
|
|
||||||
|
# Remove files that are excluded
|
||||||
|
if exclude:
|
||||||
|
repo.run_cmd(['rm', '--cached'] + [f for f in exclude], env_update)
|
||||||
|
|
||||||
tree = repo.run_cmd('write-tree', env_update)
|
tree = repo.run_cmd('write-tree', env_update)
|
||||||
|
|
||||||
# Create new commit object from the tree
|
# Create new commit object from the tree
|
||||||
|
@ -183,6 +188,9 @@ def parse_args(argv):
|
||||||
parser.add_argument('--tag-msg-body',
|
parser.add_argument('--tag-msg-body',
|
||||||
default='',
|
default='',
|
||||||
help="Tag message body (pattern)")
|
help="Tag message body (pattern)")
|
||||||
|
parser.add_argument('--exclude', action='append', default=[],
|
||||||
|
help="Glob to exclude files from the commit. Relative "
|
||||||
|
"to DATA_DIR. 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)
|
||||||
|
@ -221,7 +229,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)
|
commit_msg, args.exclude)
|
||||||
|
|
||||||
# Create tag
|
# Create tag
|
||||||
if tag_name:
|
if tag_name:
|
||||||
|
|
Loading…
Reference in New Issue