[gnome-builder] vcs: allow registering known ignored files
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] vcs: allow registering known ignored files
- Date: Wed, 15 Feb 2017 01:12:32 +0000 (UTC)
commit 158028e1ff265a5d2c562d4bf68d3ed3f226b16e
Author: Christian Hergert <chergert redhat com>
Date: Tue Feb 14 17:11:45 2017 -0800
vcs: allow registering known ignored files
This is convenience so that plugins such as flatpak can have files ignored
that shouldn't eventually land in the repositories, nor should be displayed
in the project tree.
libide/vcs/ide-vcs.c | 25 +++++++++++++++++++++++++
libide/vcs/ide-vcs.h | 1 +
2 files changed, 26 insertions(+), 0 deletions(-)
---
diff --git a/libide/vcs/ide-vcs.c b/libide/vcs/ide-vcs.c
index 1e0cb7d..f63b71d 100644
--- a/libide/vcs/ide-vcs.c
+++ b/libide/vcs/ide-vcs.c
@@ -32,6 +32,16 @@ enum {
};
static guint signals [N_SIGNALS];
+static GPtrArray *ignored;
+
+void
+ide_vcs_register_ignored (const gchar *pattern)
+{
+ if (ignored == NULL)
+ ignored = g_ptr_array_new ();
+
+ g_ptr_array_add (ignored, g_pattern_spec_new (pattern));
+}
static void
ide_vcs_default_init (IdeVcsInterface *iface)
@@ -79,6 +89,21 @@ ide_vcs_is_ignored (IdeVcs *self,
{
g_return_val_if_fail (IDE_IS_VCS (self), FALSE);
+ if G_LIKELY (ignored != NULL)
+ {
+ g_autofree gchar *name = g_file_get_basename (file);
+ guint len = strlen (name);
+ g_autofree gchar *reversed = g_utf8_strreverse (name, len);
+
+ for (guint i = 0; i < ignored->len; i++)
+ {
+ GPatternSpec *pattern_spec = g_ptr_array_index (ignored, i);
+
+ if (g_pattern_match (pattern_spec, len, name, reversed))
+ return TRUE;
+ }
+ }
+
if (IDE_VCS_GET_IFACE (self)->is_ignored)
return IDE_VCS_GET_IFACE (self)->is_ignored (self, file, error);
diff --git a/libide/vcs/ide-vcs.h b/libide/vcs/ide-vcs.h
index dd3654b..c9d6f8d 100644
--- a/libide/vcs/ide-vcs.h
+++ b/libide/vcs/ide-vcs.h
@@ -46,6 +46,7 @@ struct _IdeVcsInterface
gchar *(*get_branch_name) (IdeVcs *self);
};
+void ide_vcs_register_ignored (const gchar *pattern);
IdeBufferChangeMonitor *ide_vcs_get_buffer_change_monitor (IdeVcs *self,
IdeBuffer *buffer);
GFile *ide_vcs_get_working_directory (IdeVcs *self);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]