forked from Mirrors/flatpak-builder
builder: Support specifying revision in bzr sources
parent
5b6f3749d5
commit
6a82dd4ee3
|
@ -37,6 +37,7 @@ struct BuilderSourceBzr {
|
|||
BuilderSource parent;
|
||||
|
||||
char *url;
|
||||
char *revision;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
|
@ -48,6 +49,7 @@ G_DEFINE_TYPE (BuilderSourceBzr, builder_source_bzr, BUILDER_TYPE_SOURCE);
|
|||
enum {
|
||||
PROP_0,
|
||||
PROP_URL,
|
||||
PROP_REVISION,
|
||||
LAST_PROP
|
||||
};
|
||||
|
||||
|
@ -57,6 +59,7 @@ builder_source_bzr_finalize (GObject *object)
|
|||
BuilderSourceBzr *self = (BuilderSourceBzr *)object;
|
||||
|
||||
g_free (self->url);
|
||||
g_free (self->revision);
|
||||
|
||||
G_OBJECT_CLASS (builder_source_bzr_parent_class)->finalize (object);
|
||||
}
|
||||
|
@ -75,6 +78,10 @@ builder_source_bzr_get_property (GObject *object,
|
|||
g_value_set_string (value, self->url);
|
||||
break;
|
||||
|
||||
case PROP_REVISION:
|
||||
g_value_set_string (value, self->revision);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
}
|
||||
|
@ -95,6 +102,11 @@ builder_source_bzr_set_property (GObject *object,
|
|||
self->url = g_value_dup_string (value);
|
||||
break;
|
||||
|
||||
case PROP_REVISION:
|
||||
g_free (self->revision);
|
||||
self->revision = g_value_dup_string (value);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
}
|
||||
|
@ -210,6 +222,14 @@ builder_source_bzr_extract (BuilderSource *source,
|
|||
"branch", "--stacked", mirror_dir_path, dest_path, "--use-existing-dir", NULL))
|
||||
return FALSE;
|
||||
|
||||
if (self->revision)
|
||||
{
|
||||
g_autofree char *revarg = g_strdup_printf ("-r%s", self->revision);
|
||||
if (!bzr (dest, NULL, error,
|
||||
"revert", revarg, NULL))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -223,6 +243,7 @@ builder_source_bzr_checksum (BuilderSource *source,
|
|||
g_autoptr(GError) error = NULL;
|
||||
|
||||
builder_cache_checksum_str (cache, self->url);
|
||||
builder_cache_checksum_str (cache, self->revision);
|
||||
|
||||
current_commit = get_current_commit (self, context, &error);
|
||||
if (current_commit)
|
||||
|
@ -252,6 +273,13 @@ builder_source_bzr_class_init (BuilderSourceBzrClass *klass)
|
|||
"",
|
||||
NULL,
|
||||
G_PARAM_READWRITE));
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_REVISION,
|
||||
g_param_spec_string ("revision",
|
||||
"",
|
||||
"",
|
||||
NULL,
|
||||
G_PARAM_READWRITE));
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -328,6 +328,10 @@
|
|||
<term><option>url</option></term>
|
||||
<listitem><para>URL of the bzr repostiory</para></listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><option>revision</option></term>
|
||||
<listitem><para>A specific revision to use in the branch</para></listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><option>dest</option></term>
|
||||
<listitem><para>Directory inside the source dir where the repository will be checked out.</para></listitem>
|
||||
|
|
Loading…
Reference in New Issue