From b00b8b1601142d21564a2dff871b8750db2af71d Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Tue, 21 Mar 2017 13:16:29 +0100 Subject: [PATCH] builder: Add --default-branch=BRANCH --- builder/builder-main.c | 12 +++++++----- builder/builder-manifest.c | 12 +++++++++--- builder/builder-manifest.h | 3 ++- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/builder/builder-main.c b/builder/builder-main.c index e7f6b90e1..dac444340 100644 --- a/builder/builder-main.c +++ b/builder/builder-main.c @@ -56,6 +56,7 @@ static char *opt_from_git_branch; static char *opt_stop_at; static char *opt_build_shell; static char *opt_arch; +static char *opt_default_branch; static char *opt_repo; static char *opt_subject; static char *opt_body; @@ -67,6 +68,7 @@ static GOptionEntry entries[] = { { "verbose", 'v', 0, G_OPTION_ARG_NONE, &opt_verbose, "Print debug information during command processing", NULL }, { "version", 0, 0, G_OPTION_ARG_NONE, &opt_version, "Print version information and exit", NULL }, { "arch", 0, 0, G_OPTION_ARG_STRING, &opt_arch, "Architecture to build for (must be host compatible)", "ARCH" }, + { "default-branch", 0, 0, G_OPTION_ARG_STRING, &opt_default_branch, "Change the default branch", "BRANCH" }, { "run", 0, 0, G_OPTION_ARG_NONE, &opt_run, "Run a command in the build directory (see --run --help)", NULL }, { "ccache", 0, 0, G_OPTION_ARG_NONE, &opt_ccache, "Use ccache", NULL }, { "disable-cache", 0, 0, G_OPTION_ARG_NONE, &opt_disable_cache, "Disable cache lookups", NULL }, @@ -592,7 +594,7 @@ main (int argc, "--exclude=/lib/debug/*", "--include=/lib/debug/app", builder_context_get_separate_locales (build_context) ? "--exclude=/share/runtime/locale/*/*" : skip_arg, - opt_repo, app_dir_path, builder_manifest_get_branch (manifest), NULL)) + opt_repo, app_dir_path, builder_manifest_get_branch (manifest, opt_default_branch), NULL)) { g_printerr ("Export failed: %s\n", error->message); return 1; @@ -622,7 +624,7 @@ main (int argc, if (!do_export (build_context, &error, TRUE, metadata_arg, files_arg, - opt_repo, app_dir_path, builder_manifest_get_branch (manifest), NULL)) + opt_repo, app_dir_path, builder_manifest_get_branch (manifest, opt_default_branch), NULL)) { g_printerr ("Export failed: %s\n", error->message); return 1; @@ -639,7 +641,7 @@ main (int argc, if (!do_export (build_context, &error, TRUE, "--metadata=metadata.debuginfo", builder_context_get_build_runtime (build_context) ? "--files=usr/lib/debug" : "--files=files/lib/debug", - opt_repo, app_dir_path, builder_manifest_get_branch (manifest), NULL)) + opt_repo, app_dir_path, builder_manifest_get_branch (manifest, opt_default_branch), NULL)) { g_printerr ("Export failed: %s\n", error->message); return 1; @@ -657,7 +659,7 @@ main (int argc, "--metadata=metadata.platform", "--files=platform", builder_context_get_separate_locales (build_context) ? "--exclude=/share/runtime/locale/*/*" : skip_arg, - opt_repo, app_dir_path, builder_manifest_get_branch (manifest), NULL)) + opt_repo, app_dir_path, builder_manifest_get_branch (manifest, opt_default_branch), NULL)) { g_printerr ("Export failed: %s\n", error->message); return 1; @@ -687,7 +689,7 @@ main (int argc, if (!do_export (build_context, &error, TRUE, metadata_arg, files_arg, - opt_repo, app_dir_path, builder_manifest_get_branch (manifest), NULL)) + opt_repo, app_dir_path, builder_manifest_get_branch (manifest, opt_default_branch), NULL)) { g_printerr ("Export failed: %s\n", error->message); return 1; diff --git a/builder/builder-manifest.c b/builder/builder-manifest.c index 9792d73a8..65650e9a7 100644 --- a/builder/builder-manifest.c +++ b/builder/builder-manifest.c @@ -1083,15 +1083,21 @@ builder_manifest_get_runtime_version (BuilderManifest *self) } const char * -builder_manifest_get_branch (BuilderManifest *self) +builder_manifest_get_branch (BuilderManifest *self, const char *default_branch) { - return self->branch ? self->branch : "master"; + if (self->branch) + return self->branch; + + if (default_branch) + return default_branch; + + return "master"; } static const char * builder_manifest_get_base_version (BuilderManifest *self) { - return self->base_version ? self->base_version : builder_manifest_get_branch (self); + return self->base_version ? self->base_version : builder_manifest_get_branch (self, NULL); } static char * diff --git a/builder/builder-manifest.h b/builder/builder-manifest.h index 44b73cef1..c61e5530e 100644 --- a/builder/builder-manifest.h +++ b/builder/builder-manifest.h @@ -53,7 +53,8 @@ const char * builder_manifest_get_id_platform (BuilderManifest *self); char * builder_manifest_get_locale_id_platform (BuilderManifest *self); BuilderOptions *builder_manifest_get_build_options (BuilderManifest *self); GList * builder_manifest_get_modules (BuilderManifest *self); -const char * builder_manifest_get_branch (BuilderManifest *self); +const char * builder_manifest_get_branch (BuilderManifest *self, + const char *default_branch); gboolean builder_manifest_start (BuilderManifest *self, gboolean allow_missing_runtimes,