[gnome-builder] autotools: check .git/index for more accurate datetime info
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] autotools: check .git/index for more accurate datetime info
- Date: Mon, 6 Apr 2015 21:36:59 +0000 (UTC)
commit 713232748ec476421e088fe29b8ea405c5e323da
Author: Christian Hergert <christian hergert me>
Date: Thu Apr 2 21:08:46 2015 -0700
autotools: check .git/index for more accurate datetime info
This is very much a leaking of abstractions, but I don't have a clear idea
of what he abstraction would look like to merge the various systems. So
this trick will do for now.
libide/autotools/ide-autotools-project-miner.c | 19 ++++++++++++++++++-
1 files changed, 18 insertions(+), 1 deletions(-)
---
diff --git a/libide/autotools/ide-autotools-project-miner.c b/libide/autotools/ide-autotools-project-miner.c
index 9760ec3..ee7fe8c 100644
--- a/libide/autotools/ide-autotools-project-miner.c
+++ b/libide/autotools/ide-autotools-project-miner.c
@@ -43,12 +43,15 @@ static GParamSpec *gParamSpecs [LAST_PROP];
static void
ide_autotools_project_miner_discovered (IdeAutotoolsProjectMiner *self,
+ GCancellable *cancellable,
GFile *directory,
GFileInfo *file_info)
{
g_autofree gchar *uri = NULL;
g_autofree gchar *name = NULL;
g_autoptr(GFile) file = NULL;
+ g_autoptr(GFile) index_file = NULL;
+ g_autoptr(GFileInfo) index_info = NULL;
g_autoptr(IdeProjectInfo) project_info = NULL;
g_autoptr(GDateTime) last_modified_at = NULL;
const gchar *filename;
@@ -64,6 +67,20 @@ ide_autotools_project_miner_discovered (IdeAutotoolsProjectMiner *self,
g_debug ("Discovered autotools project at %s", uri);
mtime = g_file_info_get_attribute_uint64 (file_info, G_FILE_ATTRIBUTE_TIME_MODIFIED);
+
+ /*
+ * If there is a git repo, trust the .git/index file for time info,
+ * it is more reliable than our directory mtime.
+ */
+ index_file = g_file_get_child (directory, ".git/index");
+ index_info = g_file_query_info (index_file,
+ G_FILE_ATTRIBUTE_TIME_MODIFIED,
+ G_FILE_QUERY_INFO_NONE,
+ cancellable,
+ NULL);
+ if (index_info != NULL)
+ mtime = g_file_info_get_attribute_uint64 (index_info, G_FILE_ATTRIBUTE_TIME_MODIFIED);
+
last_modified_at = g_date_time_new_from_unix_local (mtime);
filename = g_file_info_get_attribute_byte_string (file_info, G_FILE_ATTRIBUTE_STANDARD_NAME);
@@ -142,7 +159,7 @@ ide_autotools_project_miner_mine_directory (IdeAutotoolsProjectMiner *self,
if ((0 == g_strcmp0 (filename, "configure.ac")) ||
(0 == g_strcmp0 (filename, "configure.in")))
{
- ide_autotools_project_miner_discovered (self, directory, file_info);
+ ide_autotools_project_miner_discovered (self, cancellable, directory, file_info);
g_clear_object (&file_info);
return;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]