[gnome-builder/wip/gtk4-port] libide/vcs: add IdeVcsCloner vfunc to get directory name
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/gtk4-port] libide/vcs: add IdeVcsCloner vfunc to get directory name
- Date: Wed, 1 Jun 2022 05:01:44 +0000 (UTC)
commit 2816eee40b296982ad52dd89b805c80713af6d37
Author: Christian Hergert <chergert redhat com>
Date: Tue May 31 21:59:24 2022 -0700
libide/vcs: add IdeVcsCloner vfunc to get directory name
This helps massage something like "path/to/thing.git" into "thing".
src/libide/vcs/ide-vcs-cloner.c | 28 ++++++++++++++++++++++++++++
src/libide/vcs/ide-vcs-cloner.h | 5 +++++
2 files changed, 33 insertions(+)
---
diff --git a/src/libide/vcs/ide-vcs-cloner.c b/src/libide/vcs/ide-vcs-cloner.c
index 10e9fe776..5f45b2583 100644
--- a/src/libide/vcs/ide-vcs-cloner.c
+++ b/src/libide/vcs/ide-vcs-cloner.c
@@ -345,3 +345,31 @@ ide_vcs_cloner_list_branches_finish (IdeVcsCloner *self,
IDE_RETURN (ret);
}
+
+/**
+ * ide_vcs_cloner_get_directory_name:
+ * @self: a #IdeVcsCloner
+ * @uri: an #IdeVcsUri
+ *
+ * Gets the directory name that will be used to clone from @uri.
+ *
+ * If the path has "foo.git", this function would be expected to
+ * return "foo".
+ *
+ * Returns: (transfer full): a string containing the directory name
+ */
+char *
+ide_vcs_cloner_get_directory_name (IdeVcsCloner *self,
+ IdeVcsUri *uri)
+{
+ char *ret;
+
+ IDE_ENTRY;
+
+ g_return_val_if_fail (IDE_IS_VCS_CLONER (self), NULL);
+ g_return_val_if_fail (uri != NULL, NULL);
+
+ ret = IDE_VCS_CLONER_GET_IFACE (self)->get_directory_name (self, uri);
+
+ IDE_RETURN (ret);
+}
diff --git a/src/libide/vcs/ide-vcs-cloner.h b/src/libide/vcs/ide-vcs-cloner.h
index c70a790a3..5d91d4e6d 100644
--- a/src/libide/vcs/ide-vcs-cloner.h
+++ b/src/libide/vcs/ide-vcs-cloner.h
@@ -58,6 +58,8 @@ struct _IdeVcsClonerInterface
GListModel *(*list_branches_finish) (IdeVcsCloner *self,
GAsyncResult *result,
GError **error);
+ char *(*get_directory_name) (IdeVcsCloner *self,
+ IdeVcsUri *uri);
};
IDE_AVAILABLE_IN_ALL
@@ -86,6 +88,9 @@ GListModel *ide_vcs_cloner_list_branches_finish (IdeVcsCloner *self,
GAsyncResult *result,
GError **error);
IDE_AVAILABLE_IN_ALL
+char *ide_vcs_cloner_get_directory_name (IdeVcsCloner *self,
+ IdeVcsUri *uri);
+IDE_AVAILABLE_IN_ALL
gboolean ide_vcs_cloner_validate_uri (IdeVcsCloner *self,
const char *uri,
char **errmsg);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]