[gnome-builder/wip/chergert/buildcleanup: 5/10] git: allow .you-dont-git-me files to disable git plugin
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/chergert/buildcleanup: 5/10] git: allow .you-dont-git-me files to disable git plugin
- Date: Mon, 12 Dec 2016 03:32:22 +0000 (UTC)
commit cfe2717f1c26c8ea43b8f8bef82c989ef3b0700a
Author: Christian Hergert <chergert redhat com>
Date: Sun Dec 11 19:15:34 2016 -0800
git: allow .you-dont-git-me files to disable git plugin
We need a simple way to disable the git plugin for unit tests. This is a
little hack to work around the parent project being git.
Longer term, we should make ide_context_new_async() include an options
parameter so that we can tweak context initialization.
plugins/git/ide-git-vcs.c | 22 ++++++++++++++++++++++
1 files changed, 22 insertions(+), 0 deletions(-)
---
diff --git a/plugins/git/ide-git-vcs.c b/plugins/git/ide-git-vcs.c
index 2e78992..a68af3c 100644
--- a/plugins/git/ide-git-vcs.c
+++ b/plugins/git/ide-git-vcs.c
@@ -166,6 +166,24 @@ ide_git_vcs_discover (IdeGitVcs *self,
if (g_strcmp0 (name, ".git") == 0)
return g_object_ref (file);
+ /*
+ * Work around for in-tree tests which we do not
+ * want to use the git backend.
+ *
+ * TODO: Allow options during context creation.
+ */
+ child = g_file_get_child (file, ".you-dont-git-me");
+
+ if (g_file_query_exists (child, NULL))
+ {
+ g_set_error (error,
+ G_IO_ERROR,
+ G_IO_ERROR_NOT_SUPPORTED,
+ "The project has blocked use of the git plugin");
+ return NULL;
+ }
+
+ g_clear_object (&child);
child = g_file_get_child (file, ".git");
if (g_file_query_exists (child, NULL))
@@ -198,12 +216,16 @@ ide_git_vcs_load (IdeGitVcs *self,
GFile *project_file;
g_assert (IDE_IS_GIT_VCS (self));
+ g_assert (error != NULL);
context = ide_object_get_context (IDE_OBJECT (self));
project_file = ide_context_get_project_file (context);
if (!(location = ide_git_vcs_discover (self, project_file, error)))
{
+ if (g_error_matches (*error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED))
+ return NULL;
+
g_clear_error (error);
/* Fallback to libgit2(-glib) discovery */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]