[gnome-builder] todo: check VCS if file is ignored
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] todo: check VCS if file is ignored
- Date: Fri, 13 Oct 2017 23:09:45 +0000 (UTC)
commit 678e3158bc8c59f23b23e214d2ce3f3134a5af59
Author: Christian Hergert <chergert redhat com>
Date: Fri Oct 13 16:05:58 2017 -0700
todo: check VCS if file is ignored
Before adding the TODO item to the list, we want to check if it
is ignored so the user doesn't get spammed with TODO items that
are not related to their core project.
One such example would be libtool and m4 macros in autotools-
based projects.
https://bugzilla.gnome.org/show_bug.cgi?id=774977
src/plugins/todo/gbp-todo-model.c | 85 ++++++++++++++++++++++++++-
src/plugins/todo/gbp-todo-model.h | 4 +-
src/plugins/todo/gbp-todo-workbench-addin.c | 2 +-
3 files changed, 85 insertions(+), 6 deletions(-)
---
diff --git a/src/plugins/todo/gbp-todo-model.c b/src/plugins/todo/gbp-todo-model.c
index 79f829c..0858fe8 100644
--- a/src/plugins/todo/gbp-todo-model.c
+++ b/src/plugins/todo/gbp-todo-model.c
@@ -37,7 +37,8 @@
*/
struct _GbpTodoModel {
- GtkListStore parent_instance;
+ GtkListStore parent_instance;
+ IdeVcs *vcs;
};
typedef struct
@@ -48,6 +49,13 @@ typedef struct
G_DEFINE_TYPE (GbpTodoModel, gbp_todo_model, GTK_TYPE_LIST_STORE)
+enum {
+ PROP_0,
+ PROP_VCS,
+ N_PROPS
+};
+
+static GParamSpec *properties [N_PROPS];
static GRegex *line1;
static GRegex *line2;
@@ -126,11 +134,17 @@ static void
gbp_todo_model_merge (GbpTodoModel *self,
GbpTodoItem *item)
{
+ const gchar *path;
GtkTreeIter iter;
g_assert (GBP_IS_TODO_MODEL (self));
g_assert (GBP_IS_TODO_ITEM (item));
+ path = gbp_todo_item_get_path (item);
+
+ if (ide_vcs_path_is_ignored (self->vcs, path, NULL))
+ return;
+
gtk_list_store_prepend (GTK_LIST_STORE (self), &iter);
gtk_list_store_set (GTK_LIST_STORE (self), &iter, 0, item, -1);
}
@@ -170,10 +184,72 @@ gbp_todo_model_merge_results (gpointer user_data)
}
static void
+gbp_todo_model_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GbpTodoModel *self = GBP_TODO_MODEL (object);
+
+ switch (prop_id)
+ {
+ case PROP_VCS:
+ g_value_set_object (value, self->vcs);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
+}
+
+static void
+gbp_todo_model_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GbpTodoModel *self = GBP_TODO_MODEL (object);
+
+ switch (prop_id)
+ {
+ case PROP_VCS:
+ self->vcs = g_value_dup_object (value);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
+}
+
+static void
+gbp_todo_model_dispose (GObject *object)
+{
+ GbpTodoModel *self = (GbpTodoModel *)object;
+
+ g_clear_object (&self->vcs);
+
+ G_OBJECT_CLASS (gbp_todo_model_parent_class)->dispose (object);
+}
+
+static void
gbp_todo_model_class_init (GbpTodoModelClass *klass)
{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
g_autoptr(GError) error = NULL;
+ object_class->dispose = gbp_todo_model_dispose;
+ object_class->get_property = gbp_todo_model_get_property;
+ object_class->set_property = gbp_todo_model_set_property;
+
+ properties [PROP_VCS] =
+ g_param_spec_object ("vcs",
+ "Vcs",
+ "The VCS for the current context",
+ IDE_TYPE_VCS,
+ (G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_properties (object_class, N_PROPS, properties);
+
line1 = g_regex_new ("(.*):(\\d+):(.*)", 0, 0, &error);
g_assert_no_error (error);
g_assert (line1 != NULL);
@@ -195,6 +271,7 @@ gbp_todo_model_init (GbpTodoModel *self)
/**
* gbp_todo_model_new:
+ * @vcs: The Vcs to check for ignored files
*
* Creates a new #GbpTodoModel.
*
@@ -203,9 +280,11 @@ gbp_todo_model_init (GbpTodoModel *self)
* Since: 3.26
*/
GbpTodoModel *
-gbp_todo_model_new (void)
+gbp_todo_model_new (IdeVcs *vcs)
{
- return g_object_new (GBP_TYPE_TODO_MODEL, NULL);
+ return g_object_new (GBP_TYPE_TODO_MODEL,
+ "vcs", vcs,
+ NULL);
}
static void
diff --git a/src/plugins/todo/gbp-todo-model.h b/src/plugins/todo/gbp-todo-model.h
index a60238d..12d5a0c 100644
--- a/src/plugins/todo/gbp-todo-model.h
+++ b/src/plugins/todo/gbp-todo-model.h
@@ -18,7 +18,7 @@
#pragma once
-#include <gtk/gtk.h>
+#include <ide.h>
G_BEGIN_DECLS
@@ -26,7 +26,7 @@ G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (GbpTodoModel, gbp_todo_model, GBP, TODO_MODEL, GtkListStore)
-GbpTodoModel *gbp_todo_model_new (void);
+GbpTodoModel *gbp_todo_model_new (IdeVcs *vcs);
void gbp_todo_model_mine_async (GbpTodoModel *self,
GFile *file,
GCancellable *cancellable,
diff --git a/src/plugins/todo/gbp-todo-workbench-addin.c b/src/plugins/todo/gbp-todo-workbench-addin.c
index 4a61a79..bb36855 100644
--- a/src/plugins/todo/gbp-todo-workbench-addin.c
+++ b/src/plugins/todo/gbp-todo-workbench-addin.c
@@ -100,7 +100,7 @@ gbp_todo_workbench_addin_load (IdeWorkbenchAddin *addin,
self,
G_CONNECT_SWAPPED);
- self->model = gbp_todo_model_new ();
+ self->model = gbp_todo_model_new (vcs);
self->panel = g_object_new (GBP_TYPE_TODO_PANEL,
"model", self->model,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]