[gnome-builder/wip/gtk4-port] plugins/git: implement scope for IdeVcsConfig



commit 123814eaaff0ae6b8ac26370444104eadd1cc597
Author: Christian Hergert <chergert redhat com>
Date:   Sat May 14 15:05:05 2022 -0700

    plugins/git: implement scope for IdeVcsConfig
    
    This allows modifying the proper config object (global or for the
    repository directly) so now the global preferences and project preferences
    show the appropriate values.

 src/plugins/git/gbp-git-vcs-config.c | 42 ++++++++++++++++++++++++++++++------
 1 file changed, 35 insertions(+), 7 deletions(-)
---
diff --git a/src/plugins/git/gbp-git-vcs-config.c b/src/plugins/git/gbp-git-vcs-config.c
index f110696d5..859d325a2 100644
--- a/src/plugins/git/gbp-git-vcs-config.c
+++ b/src/plugins/git/gbp-git-vcs-config.c
@@ -29,6 +29,7 @@
 #include "daemon/ipc-git-config.h"
 
 #include "gbp-git-client.h"
+#include "gbp-git-vcs.h"
 #include "gbp-git-vcs-config.h"
 
 struct _GbpGitVcsConfig
@@ -73,18 +74,46 @@ get_config (GbpGitVcsConfig  *self,
   context = ide_object_get_context (IDE_OBJECT (self));
   client = gbp_git_client_from_context (context);
 
-  if (!self->is_global)
-    {
-      /* TODO: get config from repository */
-    }
+  g_assert (IDE_IS_CONTEXT (context));
+  g_assert (GBP_IS_GIT_CLIENT (client));
 
   if (!(service = gbp_git_client_get_service (client, cancellable, error)))
     return NULL;
 
-  if (!ipc_git_service_call_load_config_sync (service, &obj_path, cancellable, error))
-    return NULL;
+  if (!self->is_global)
+    {
+      IdeVcs *vcs;
+      IpcGitRepository *repository;
+
+      vcs = ide_vcs_from_context (context);
+      g_assert (GBP_IS_GIT_VCS (vcs));
+
+      repository = gbp_git_vcs_get_repository (GBP_GIT_VCS (vcs));
+      g_assert (!repository || IPC_IS_GIT_REPOSITORY (repository));
+
+      if (repository == NULL)
+        {
+          g_set_error (error,
+                       G_IO_ERROR,
+                       G_IO_ERROR_NOT_SUPPORTED,
+                       "Failed to load git repository");
+          return NULL;
+        }
+
+      if (!ipc_git_repository_call_load_config_sync (repository, &obj_path, cancellable, error))
+        return NULL;
+    }
+  else
+    {
+      if (!ipc_git_service_call_load_config_sync (service, &obj_path, cancellable, error))
+        return NULL;
+    }
+
+  g_assert (obj_path != NULL);
+  g_assert (g_variant_is_object_path (obj_path));
 
   connection = g_dbus_proxy_get_connection (G_DBUS_PROXY (service));
+  g_assert (G_IS_DBUS_CONNECTION (connection));
 
   return ipc_git_config_proxy_new_sync (connection,
                                         G_DBUS_PROXY_FLAGS_NONE,
@@ -92,7 +121,6 @@ get_config (GbpGitVcsConfig  *self,
                                         obj_path,
                                         cancellable,
                                         error);
-
 }
 
 static void


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