core: Add from-file argument to compose
We don't want to have to pass a million arguments.
This commit is contained in:
parent
dbba4538e1
commit
0044ff133a
|
|
@ -30,12 +30,14 @@
|
||||||
static char *subject;
|
static char *subject;
|
||||||
static char *body;
|
static char *body;
|
||||||
static char *branch;
|
static char *branch;
|
||||||
|
static char *from_file_path;
|
||||||
static gboolean recompose;
|
static gboolean recompose;
|
||||||
|
|
||||||
static GOptionEntry options[] = {
|
static GOptionEntry options[] = {
|
||||||
{ "subject", 's', 0, G_OPTION_ARG_STRING, &subject, "One line subject", "subject" },
|
{ "subject", 's', 0, G_OPTION_ARG_STRING, &subject, "One line subject", "subject" },
|
||||||
{ "body", 'm', 0, G_OPTION_ARG_STRING, &body, "Full description", "body" },
|
{ "body", 'm', 0, G_OPTION_ARG_STRING, &body, "Full description", "body" },
|
||||||
{ "branch", 'b', 0, G_OPTION_ARG_STRING, &branch, "Branch", "branch" },
|
{ "branch", 'b', 0, G_OPTION_ARG_STRING, &branch, "Branch", "branch" },
|
||||||
|
{ "from-file", 'F', 0, G_OPTION_ARG_STRING, &from_file_path, "Take list of branches to compose from FILE", "FILE" },
|
||||||
{ "recompose", 0, 0, G_OPTION_ARG_NONE, &recompose, "Regenerate compose from existing branches", NULL },
|
{ "recompose", 0, 0, G_OPTION_ARG_NONE, &recompose, "Regenerate compose from existing branches", NULL },
|
||||||
{ NULL }
|
{ NULL }
|
||||||
};
|
};
|
||||||
|
|
@ -92,6 +94,9 @@ ostree_builtin_compose (int argc, char **argv, GFile *repo_path, GError **error)
|
||||||
char *commit_checksum = NULL;
|
char *commit_checksum = NULL;
|
||||||
GCancellable *cancellable = NULL;
|
GCancellable *cancellable = NULL;
|
||||||
GFile *metadata_f = NULL;
|
GFile *metadata_f = NULL;
|
||||||
|
GFile *from_file = NULL;
|
||||||
|
char *from_file_contents = NULL;
|
||||||
|
char **from_file_args = NULL;
|
||||||
OstreeMutableTree *mtree = NULL;
|
OstreeMutableTree *mtree = NULL;
|
||||||
gboolean skip_commit = FALSE;
|
gboolean skip_commit = FALSE;
|
||||||
gboolean in_transaction = FALSE;
|
gboolean in_transaction = FALSE;
|
||||||
|
|
@ -178,6 +183,31 @@ ostree_builtin_compose (int argc, char **argv, GFile *repo_path, GError **error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (from_file_path)
|
||||||
|
{
|
||||||
|
char **iter;
|
||||||
|
|
||||||
|
from_file = ot_gfile_new_for_path (from_file_path);
|
||||||
|
if (!ot_gfile_load_contents_utf8 (from_file,
|
||||||
|
&from_file_contents, NULL, NULL, error))
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
from_file_args = g_strsplit_set (from_file_contents, "\n", -1);
|
||||||
|
|
||||||
|
for (iter = from_file_args; *iter && **iter; iter++)
|
||||||
|
{
|
||||||
|
const char *src_branch = *iter;
|
||||||
|
|
||||||
|
if (seen_branches && g_hash_table_lookup (seen_branches, src_branch))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (!add_branch (repo, mtree, src_branch,
|
||||||
|
&compose_metadata_builder,
|
||||||
|
error))
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 1; i < argc; i++)
|
for (i = 1; i < argc; i++)
|
||||||
{
|
{
|
||||||
const char *src_branch = argv[i];
|
const char *src_branch = argv[i];
|
||||||
|
|
@ -272,5 +302,8 @@ ostree_builtin_compose (int argc, char **argv, GFile *repo_path, GError **error)
|
||||||
g_clear_object (&destf);
|
g_clear_object (&destf);
|
||||||
g_clear_object (&metadata_f);
|
g_clear_object (&metadata_f);
|
||||||
g_clear_object (&mtree);
|
g_clear_object (&mtree);
|
||||||
|
g_clear_object (&from_file);
|
||||||
|
g_free (from_file_contents);
|
||||||
|
g_strfreev (from_file_args);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
echo "1..7"
|
echo "1..8"
|
||||||
|
|
||||||
. libtest.sh
|
. libtest.sh
|
||||||
|
|
||||||
|
|
@ -99,3 +99,14 @@ $OSTREE checkout some-compose some-compose-checkout
|
||||||
cd some-compose-checkout
|
cd some-compose-checkout
|
||||||
assert_file_has_content ./usr/bin/bar 'updated bar ELF file'
|
assert_file_has_content ./usr/bin/bar 'updated bar ELF file'
|
||||||
echo 'ok recompose with args'
|
echo 'ok recompose with args'
|
||||||
|
|
||||||
|
cd "${test_tmpdir}"
|
||||||
|
echo artifact-libfoo-runtime > compose-contents.txt
|
||||||
|
echo artifact-libfoo-devel >> compose-contents.txt
|
||||||
|
echo artifact-barapp >> compose-contents.txt
|
||||||
|
$OSTREE compose -b some-compose-from-file -s 'from file' -F compose-contents.txt
|
||||||
|
rm -rf some-compose-checkout
|
||||||
|
$OSTREE checkout some-compose-from-file some-compose-checkout
|
||||||
|
cd some-compose-checkout
|
||||||
|
assert_file_has_content ./usr/bin/bar 'updated bar ELF file'
|
||||||
|
echo 'ok recompose from file'
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue