[gnome-builder] vcs: stub API to push a branch



commit 05dad8817696c2f5da84d7d161befe29e52944b6
Author: Christian Hergert <chergert redhat com>
Date:   Sun May 5 21:49:10 2019 -0700

    vcs: stub API to push a branch
    
    We will likely want to make this more generic going forward
    and come up with how we want to describe what/where things
    get pushed. But this lets us at least test the implementation
    for now.

 src/libide/vcs/ide-vcs.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++
 src/libide/vcs/ide-vcs.h | 18 ++++++++++++++++
 2 files changed, 71 insertions(+)
---
diff --git a/src/libide/vcs/ide-vcs.c b/src/libide/vcs/ide-vcs.c
index 52835564c..a457416b2 100644
--- a/src/libide/vcs/ide-vcs.c
+++ b/src/libide/vcs/ide-vcs.c
@@ -138,6 +138,31 @@ ide_vcs_real_switch_branch_finish (IdeVcs        *self,
   return g_task_propagate_boolean (G_TASK (result), error);
 }
 
+static void
+ide_vcs_real_push_branch_async (IdeVcs              *self,
+                                IdeVcsBranch        *branch,
+                                GCancellable        *cancellable,
+                                GAsyncReadyCallback  callback,
+                                gpointer             user_data)
+{
+  g_task_report_new_error (self,
+                           callback,
+                           user_data,
+                           ide_vcs_real_push_branch_async,
+                           G_IO_ERROR,
+                           G_IO_ERROR_NOT_SUPPORTED,
+                           "Not supported by %s",
+                           G_OBJECT_TYPE_NAME (self));
+}
+
+static gboolean
+ide_vcs_real_push_branch_finish (IdeVcs        *self,
+                                 GAsyncResult  *result,
+                                 GError       **error)
+{
+  return g_task_propagate_boolean (G_TASK (result), error);
+}
+
 static void
 ide_vcs_default_init (IdeVcsInterface *iface)
 {
@@ -149,6 +174,8 @@ ide_vcs_default_init (IdeVcsInterface *iface)
   iface->list_tags_finish = ide_vcs_real_list_tags_finish;
   iface->switch_branch_async = ide_vcs_real_switch_branch_async;
   iface->switch_branch_finish = ide_vcs_real_switch_branch_finish;
+  iface->push_branch_async = ide_vcs_real_push_branch_async;
+  iface->push_branch_finish = ide_vcs_real_push_branch_finish;
 
   g_object_interface_install_property (iface,
                                        g_param_spec_string ("branch-name",
@@ -615,3 +642,29 @@ ide_vcs_switch_branch_finish (IdeVcs        *self,
 
   return IDE_VCS_GET_IFACE (self)->switch_branch_finish (self, result, error);
 }
+
+void
+ide_vcs_push_branch_async (IdeVcs              *self,
+                           IdeVcsBranch        *branch,
+                           GCancellable        *cancellable,
+                           GAsyncReadyCallback  callback,
+                           gpointer             user_data)
+{
+  g_return_if_fail (IDE_IS_MAIN_THREAD ());
+  g_return_if_fail (IDE_IS_VCS (self));
+  g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable));
+
+  IDE_VCS_GET_IFACE (self)->push_branch_async (self, branch, cancellable, callback, user_data);
+}
+
+gboolean
+ide_vcs_push_branch_finish (IdeVcs        *self,
+                            GAsyncResult  *result,
+                            GError       **error)
+{
+  g_return_val_if_fail (IDE_IS_MAIN_THREAD (), FALSE);
+  g_return_val_if_fail (IDE_IS_VCS (self), FALSE);
+  g_return_val_if_fail (G_IS_ASYNC_RESULT (result), FALSE);
+
+  return IDE_VCS_GET_IFACE (self)->push_branch_finish (self, result, error);
+}
diff --git a/src/libide/vcs/ide-vcs.h b/src/libide/vcs/ide-vcs.h
index afb04318b..3b5410e72 100644
--- a/src/libide/vcs/ide-vcs.h
+++ b/src/libide/vcs/ide-vcs.h
@@ -80,6 +80,14 @@ struct _IdeVcsInterface
   gboolean                (*switch_branch_finish)      (IdeVcs               *self,
                                                         GAsyncResult         *result,
                                                         GError              **error);
+  void                    (*push_branch_async)         (IdeVcs               *self,
+                                                        IdeVcsBranch         *branch,
+                                                        GCancellable         *cancellable,
+                                                        GAsyncReadyCallback   callback,
+                                                        gpointer              user_data);
+  gboolean                (*push_branch_finish)        (IdeVcs               *self,
+                                                        GAsyncResult         *result,
+                                                        GError              **error);
 };
 
 IDE_AVAILABLE_IN_3_32
@@ -144,5 +152,15 @@ IDE_AVAILABLE_IN_3_32
 gboolean      ide_vcs_switch_branch_finish (IdeVcs               *self,
                                             GAsyncResult         *result,
                                             GError              **error);
+IDE_AVAILABLE_IN_3_34
+void          ide_vcs_push_branch_async    (IdeVcs               *self,
+                                            IdeVcsBranch         *branch,
+                                            GCancellable         *cancellable,
+                                            GAsyncReadyCallback   callback,
+                                            gpointer              user_data);
+IDE_AVAILABLE_IN_3_34
+gboolean      ide_vcs_push_branch_finish   (IdeVcs               *self,
+                                            GAsyncResult         *result,
+                                            GError              **error);
 
 G_END_DECLS


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