[gnome-builder] vcs: add API to list tags
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] vcs: add API to list tags
- Date: Mon, 28 Jan 2019 04:00:07 +0000 (UTC)
commit 1f47141c54c70e52b61e44785723202f40635667
Author: Christian Hergert <chergert redhat com>
Date: Sun Jan 27 19:58:26 2019 -0800
vcs: add API to list tags
src/libide/vcs/ide-vcs-tag.c | 54 +++++++++++++++++++++++++++++++++++++++
src/libide/vcs/ide-vcs-tag.h | 42 ++++++++++++++++++++++++++++++
src/libide/vcs/ide-vcs.c | 61 ++++++++++++++++++++++++++++++++++++++++++++
src/libide/vcs/ide-vcs.h | 16 ++++++++++++
src/libide/vcs/libide-vcs.h | 1 +
src/libide/vcs/meson.build | 2 ++
6 files changed, 176 insertions(+)
---
diff --git a/src/libide/vcs/ide-vcs-tag.c b/src/libide/vcs/ide-vcs-tag.c
new file mode 100644
index 000000000..6acd80d9c
--- /dev/null
+++ b/src/libide/vcs/ide-vcs-tag.c
@@ -0,0 +1,54 @@
+/* ide-vcs-tag.c
+ *
+ * Copyright 2019 Christian Hergert <chergert redhat com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#define G_LOG_DOMAIN "ide-vcs-tag"
+
+#include "config.h"
+
+#include "ide-vcs-tag.h"
+
+G_DEFINE_INTERFACE (IdeVcsTag, ide_vcs_tag, G_TYPE_OBJECT)
+
+static void
+ide_vcs_tag_default_init (IdeVcsTagInterface *iface)
+{
+}
+
+/**
+ * ide_vcs_tag_get_name:
+ * @self: an #IdeVcsTag
+ *
+ * Gets the name of the tag, which is used in various UI elements
+ * to display to the user.
+ *
+ * Returns: (transfer full): a string containing the tag name
+ *
+ * Since: 3.32
+ */
+gchar *
+ide_vcs_tag_get_name (IdeVcsTag *self)
+{
+ g_return_val_if_fail (IDE_IS_VCS_TAG (self), NULL);
+
+ if (IDE_VCS_TAG_GET_IFACE (self)->get_name)
+ return IDE_VCS_TAG_GET_IFACE (self)->get_name (self);
+
+ return NULL;
+}
diff --git a/src/libide/vcs/ide-vcs-tag.h b/src/libide/vcs/ide-vcs-tag.h
new file mode 100644
index 000000000..8992d9cd4
--- /dev/null
+++ b/src/libide/vcs/ide-vcs-tag.h
@@ -0,0 +1,42 @@
+/* ide-vcs-tag.h
+ *
+ * Copyright 2019 Christian Hergert <chergert redhat com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#pragma once
+
+#include <libide-core.h>
+
+G_BEGIN_DECLS
+
+#define IDE_TYPE_VCS_TAG (ide_vcs_tag_get_type ())
+
+IDE_AVAILABLE_IN_3_32
+G_DECLARE_INTERFACE (IdeVcsTag, ide_vcs_tag, IDE, VCS_TAG, GObject)
+
+struct _IdeVcsTagInterface
+{
+ GTypeInterface parent;
+
+ gchar *(*get_name) (IdeVcsTag *self);
+};
+
+IDE_AVAILABLE_IN_3_32
+gchar *ide_vcs_tag_get_name (IdeVcsTag *self);
+
+G_END_DECLS
diff --git a/src/libide/vcs/ide-vcs.c b/src/libide/vcs/ide-vcs.c
index b9adc1b1f..52835564c 100644
--- a/src/libide/vcs/ide-vcs.c
+++ b/src/libide/vcs/ide-vcs.c
@@ -89,6 +89,30 @@ ide_vcs_real_list_branches_finish (IdeVcs *self,
return g_task_propagate_pointer (G_TASK (result), error);
}
+static void
+ide_vcs_real_list_tags_async (IdeVcs *self,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ g_task_report_new_error (self,
+ callback,
+ user_data,
+ ide_vcs_real_list_tags_async,
+ G_IO_ERROR,
+ G_IO_ERROR_NOT_SUPPORTED,
+ "Not supported by %s",
+ G_OBJECT_TYPE_NAME (self));
+}
+
+static GPtrArray *
+ide_vcs_real_list_tags_finish (IdeVcs *self,
+ GAsyncResult *result,
+ GError **error)
+{
+ return g_task_propagate_pointer (G_TASK (result), error);
+}
+
static void
ide_vcs_real_switch_branch_async (IdeVcs *self,
IdeVcsBranch *branch,
@@ -121,6 +145,8 @@ ide_vcs_default_init (IdeVcsInterface *iface)
iface->list_status_finish = ide_vcs_real_list_status_finish;
iface->list_branches_async = ide_vcs_real_list_branches_async;
iface->list_branches_finish = ide_vcs_real_list_branches_finish;
+ iface->list_tags_async = ide_vcs_real_list_tags_async;
+ 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;
@@ -529,6 +555,41 @@ ide_vcs_list_branches_finish (IdeVcs *self,
return IDE_VCS_GET_IFACE (self)->list_branches_finish (self, result, error);
}
+void
+ide_vcs_list_tags_async (IdeVcs *self,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ g_return_if_fail (IDE_IS_VCS (self));
+ g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable));
+
+ IDE_VCS_GET_IFACE (self)->list_tags_async (self, cancellable, callback, user_data);
+}
+
+/**
+ * ide_vcs_list_tags_finish:
+ * @self: an #IdeVcs
+ * @result: a #GAsyncResult
+ * @error: location for a #GError
+ *
+ * Returns: (transfer full) (element-type IdeVcsBranch): an array of
+ * #IdeVcsBranch.
+ *
+ * Since: 3.32
+ */
+GPtrArray *
+ide_vcs_list_tags_finish (IdeVcs *self,
+ GAsyncResult *result,
+ GError **error)
+{
+ g_return_val_if_fail (IDE_IS_MAIN_THREAD (), NULL);
+ g_return_val_if_fail (IDE_IS_VCS (self), NULL);
+ g_return_val_if_fail (G_IS_ASYNC_RESULT (result), NULL);
+
+ return IDE_VCS_GET_IFACE (self)->list_tags_finish (self, result, error);
+}
+
void
ide_vcs_switch_branch_async (IdeVcs *self,
IdeVcsBranch *branch,
diff --git a/src/libide/vcs/ide-vcs.h b/src/libide/vcs/ide-vcs.h
index a654bb2e3..afb04318b 100644
--- a/src/libide/vcs/ide-vcs.h
+++ b/src/libide/vcs/ide-vcs.h
@@ -65,6 +65,13 @@ struct _IdeVcsInterface
GPtrArray *(*list_branches_finish) (IdeVcs *self,
GAsyncResult *result,
GError **error);
+ void (*list_tags_async) (IdeVcs *self,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+ GPtrArray *(*list_tags_finish) (IdeVcs *self,
+ GAsyncResult *result,
+ GError **error);
void (*switch_branch_async) (IdeVcs *self,
IdeVcsBranch *branch,
GCancellable *cancellable,
@@ -119,6 +126,15 @@ GPtrArray *ide_vcs_list_branches_finish (IdeVcs *self,
GAsyncResult *result,
GError **error);
IDE_AVAILABLE_IN_3_32
+void ide_vcs_list_tags_async (IdeVcs *self,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+IDE_AVAILABLE_IN_3_32
+GPtrArray *ide_vcs_list_tags_finish (IdeVcs *self,
+ GAsyncResult *result,
+ GError **error);
+IDE_AVAILABLE_IN_3_32
void ide_vcs_switch_branch_async (IdeVcs *self,
IdeVcsBranch *branch,
GCancellable *cancellable,
diff --git a/src/libide/vcs/libide-vcs.h b/src/libide/vcs/libide-vcs.h
index de43ce6ad..aafb4ed38 100644
--- a/src/libide/vcs/libide-vcs.h
+++ b/src/libide/vcs/libide-vcs.h
@@ -35,5 +35,6 @@
#include "ide-vcs-file-info.h"
#include "ide-vcs.h"
#include "ide-vcs-monitor.h"
+#include "ide-vcs-tag.h"
#undef IDE_VCS_INSIDE
diff --git a/src/libide/vcs/meson.build b/src/libide/vcs/meson.build
index 9cd80139d..6b0e157c4 100644
--- a/src/libide/vcs/meson.build
+++ b/src/libide/vcs/meson.build
@@ -16,6 +16,7 @@ libide_vcs_public_headers = [
'ide-vcs-monitor.h',
'ide-vcs-uri.h',
'ide-vcs.h',
+ 'ide-vcs-tag.h',
'libide-vcs.h',
]
@@ -38,6 +39,7 @@ libide_vcs_public_sources = [
'ide-vcs-file-info.c',
'ide-vcs-initializer.c',
'ide-vcs-monitor.c',
+ 'ide-vcs-tag.c',
'ide-vcs-uri.c',
'ide-vcs.c',
]
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]