Improve ostree commit messages
Allow the user to configure the commit message when performing an ostree commit. Testing PASSED Run apt-ostree compose create --repo /home/repo \ --base config/debian/bookworm test-repo PASSED Run ostree log --repo /home/repo test-repo and look at the output of log file. PASSED Run apt-ostree compose create --edit --repo /home/repo \ --base config/debian/bookworm test-2 PASSED Run ostree log --repo /home/repo test-repo and look at the output of log file. Story: 2010867 Task: 48556 Change-Id: Iee14930c75aa6468783398e3c5f63000cf52a520 Signed-off-by: Charles Short <charles.short@windriver.com>
This commit is contained in:
parent
2d3ff906a3
commit
d267ba3cf9
@ -22,7 +22,7 @@ from apt_ostree.utils import run_command
|
|||||||
@click.command(short_help="Create treefile")
|
@click.command(short_help="Create treefile")
|
||||||
@pass_state_context
|
@pass_state_context
|
||||||
@compose_options
|
@compose_options
|
||||||
def create(state, repo, base, branch):
|
def create(state, repo, base, branch, edit):
|
||||||
if state.repo is None:
|
if state.repo is None:
|
||||||
click.secho("You did not supply an ostree repository", fg="red")
|
click.secho("You did not supply an ostree repository", fg="red")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
@ -77,4 +77,7 @@ def create(state, repo, base, branch):
|
|||||||
"--output", str(workdir)], cwd=state.base)
|
"--output", str(workdir)], cwd=state.base)
|
||||||
|
|
||||||
create_ostree(rootfs)
|
create_ostree(rootfs)
|
||||||
ostree_commit(state.repo, state.branch, rootfs)
|
ostree_commit(state,
|
||||||
|
rootfs,
|
||||||
|
subject="Commit by apt-ostree",
|
||||||
|
msg="Initialized by apt-ostree")
|
||||||
|
@ -40,6 +40,19 @@ def workspace_option(f):
|
|||||||
)(f)
|
)(f)
|
||||||
|
|
||||||
|
|
||||||
|
def edit_option(f):
|
||||||
|
def callback(ctxt, param, value):
|
||||||
|
state = ctxt.ensure_object(State)
|
||||||
|
state.edit = value
|
||||||
|
return value
|
||||||
|
return click.option(
|
||||||
|
"--edit",
|
||||||
|
is_flag=True,
|
||||||
|
help="Increase verbosity",
|
||||||
|
callback=callback
|
||||||
|
)(f)
|
||||||
|
|
||||||
|
|
||||||
def repo_option(f):
|
def repo_option(f):
|
||||||
"""ostree repo path option"""
|
"""ostree repo path option"""
|
||||||
def callback(ctxt, param, value):
|
def callback(ctxt, param, value):
|
||||||
@ -87,4 +100,5 @@ def compose_options(f):
|
|||||||
f = repo_option(f)
|
f = repo_option(f)
|
||||||
f = base_option(f)
|
f = base_option(f)
|
||||||
f = branch_option(f)
|
f = branch_option(f)
|
||||||
|
f = edit_option(f)
|
||||||
return f
|
return f
|
||||||
|
@ -12,15 +12,27 @@ from apt_ostree.log import log_step
|
|||||||
from apt_ostree.utils import run_command
|
from apt_ostree.utils import run_command
|
||||||
|
|
||||||
|
|
||||||
def ostree_commit(repo, branch, rootfs):
|
def ostree_commit(state,
|
||||||
"""Commit directory to ostree repository"""
|
rootfs,
|
||||||
with complete_step(f"Committing {branch} to {repo}"):
|
subject=None,
|
||||||
r = run_command(
|
msg=None):
|
||||||
["ostree", "commit", f"--repo={repo}",
|
"""Commit rootfs to ostree repository."""
|
||||||
f"--branch={branch}", str(rootfs)],
|
cmd = ["ostree", "commit", f"--repo={state.repo}"]
|
||||||
)
|
if state.edit:
|
||||||
|
cmd += ["-e"]
|
||||||
|
else:
|
||||||
|
if subject:
|
||||||
|
cmd += [f"--subject={subject}"]
|
||||||
|
if msg:
|
||||||
|
cmd += [f"--body={msg}"]
|
||||||
|
|
||||||
|
cmd += [f"--branch={state.branch}", str(rootfs)]
|
||||||
|
with complete_step(f"Committing {state.branch} to {state.repo}"):
|
||||||
|
r = run_command(cmd)
|
||||||
if r.returncode != 0:
|
if r.returncode != 0:
|
||||||
click.secho(f"Failed to commit to ostree.", fg="red")
|
click.secho(
|
||||||
|
f"Failed to commit {state.branch} to {state.repo}.",
|
||||||
|
fg="red")
|
||||||
raise
|
raise
|
||||||
|
|
||||||
log_step(f"Succesfully commited {branch} to {repo}.")
|
log_step(f"Succesfully commited {state.branch} to {state.repo}.")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user