[gnome-builder] git: provide config options when cloning



commit 7dd63340475e2d221ed8c95e9ff1c8febc02f539
Author: Christian Hergert <chergert redhat com>
Date:   Wed Apr 10 00:25:46 2019 -0700

    git: provide config options when cloning

 src/plugins/git/daemon/ipc-git-service-impl.c         | 19 +++++++++++++++++++
 .../git/daemon/org.gnome.Builder.Git.Service.xml      |  1 +
 src/plugins/git/daemon/test-git.c                     |  6 ++++++
 3 files changed, 26 insertions(+)
---
diff --git a/src/plugins/git/daemon/ipc-git-service-impl.c b/src/plugins/git/daemon/ipc-git-service-impl.c
index 23c263ebb..013c1af37 100644
--- a/src/plugins/git/daemon/ipc-git-service-impl.c
+++ b/src/plugins/git/daemon/ipc-git-service-impl.c
@@ -148,6 +148,7 @@ ipc_git_service_impl_handle_clone (IpcGitService         *service,
                                    const gchar           *url,
                                    const gchar           *location,
                                    const gchar           *branch,
+                                   GVariant              *config_options,
                                    const gchar           *progress_path)
 {
   g_autoptr(GgitRepository) repository = NULL;
@@ -158,6 +159,7 @@ ipc_git_service_impl_handle_clone (IpcGitService         *service,
   g_autoptr(GError) error = NULL;
   g_autoptr(GFile) file = NULL;
   g_autoptr(GFile) clone_location = NULL;
+  GVariantIter iter;
 
   g_assert (IPC_IS_GIT_SERVICE_IMPL (service));
   g_assert (G_IS_DBUS_METHOD_INVOCATION (invocation));
@@ -191,6 +193,23 @@ ipc_git_service_impl_handle_clone (IpcGitService         *service,
   if (!(repository = ggit_repository_clone (url, file, options, &error)))
     goto gerror;
 
+  if (g_variant_iter_init (&iter, config_options))
+    {
+      g_autoptr(GgitConfig) config = NULL;
+      GVariant *value;
+      gchar *key;
+
+      if ((config = ggit_repository_get_config (repository, NULL)))
+        {
+          while (g_variant_iter_loop (&iter, "{sv}", &key, &value))
+            {
+              g_printerr ("%s\n", g_variant_get_type_string (value));
+              if (g_variant_is_of_type (value, G_VARIANT_TYPE_STRING))
+                ggit_config_set_string (config, key, g_variant_get_string (value, NULL), NULL);
+            }
+        }
+    }
+
   clone_location = ggit_repository_get_location (repository);
   ipc_git_service_complete_clone (service,
                                   invocation,
diff --git a/src/plugins/git/daemon/org.gnome.Builder.Git.Service.xml 
b/src/plugins/git/daemon/org.gnome.Builder.Git.Service.xml
index 8382aeef8..e14f2b594 100644
--- a/src/plugins/git/daemon/org.gnome.Builder.Git.Service.xml
+++ b/src/plugins/git/daemon/org.gnome.Builder.Git.Service.xml
@@ -59,6 +59,7 @@
       <arg name="branch" direction="in" type="s">
         <doc:doc><doc:summary>The branch to clone.</doc:summary></doc:doc>
       </arg>
+      <arg name="config_options" direction="in" type="a{sv}"/>
       <arg name="progress" direction="in" type="o">
         <doc:doc><doc:summary>The path to an org.gnome.Builder.Git.Progress object on the callers 
connection.</doc:summary></doc:doc>
       </arg>
diff --git a/src/plugins/git/daemon/test-git.c b/src/plugins/git/daemon/test-git.c
index b79fc86d5..840ed26ff 100644
--- a/src/plugins/git/daemon/test-git.c
+++ b/src/plugins/git/daemon/test-git.c
@@ -173,12 +173,17 @@ test_clone (IpcGitService *service)
   g_auto(GStrv) branches = NULL;
   g_autoptr(GVariant) changes = NULL;
   g_autofree gchar *monitor_path = NULL;
+  GVariantDict opts;
   GDBusConnection *conn;
   GVariantIter iter;
   gboolean ret;
 
   g_assert (IPC_IS_GIT_SERVICE (service));
 
+  g_variant_dict_init (&opts, NULL);
+  g_variant_dict_insert (&opts, "user.name", "s", "Test User");
+  g_variant_dict_insert (&opts, "user.email", "s", "Test Email");
+
   g_message ("Creating local progress object");
   conn = g_dbus_proxy_get_connection (G_DBUS_PROXY (service));
   progress = ipc_git_progress_skeleton_new ();
@@ -195,6 +200,7 @@ test_clone (IpcGitService *service)
                                          "https://gitlab.gnome.org/chergert/hello";,
                                          tmpdir,
                                          "master",
+                                         g_variant_dict_end (&opts),
                                          PROGRESS_PATH,
                                          &location,
                                          NULL,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]