[gitg] Extract author date from environment



commit ef6575f8285f77f5963640642e73ccbae0f78ac4
Author: Jesse van den Kieboom <jessevdk gmail com>
Date:   Sat Jul 6 13:18:08 2013 +0200

    Extract author date from environment

 gitg/commit/gitg-commit.vala |   21 +++++++++++++++++++--
 1 files changed, 19 insertions(+), 2 deletions(-)
---
diff --git a/gitg/commit/gitg-commit.vala b/gitg/commit/gitg-commit.vala
index 36a4006..a4e97bd 100644
--- a/gitg/commit/gitg-commit.vala
+++ b/gitg/commit/gitg-commit.vala
@@ -532,11 +532,13 @@ namespace GitgCommit
                {
                        string? user = null;
                        string? email = null;
+                       DateTime? date = null;
 
                        var env = application.environment;
 
                        var nameenv = @"GIT_$(envname)_NAME";
                        var emailenv = @"GIT_$(envname)_EMAIL";
+                       var dateenv = @"GIT_$(envname)_DATE";
 
                        if (env.has_key(nameenv))
                        {
@@ -548,6 +550,20 @@ namespace GitgCommit
                                email = env[emailenv];
                        }
 
+                       if (env.has_key(dateenv))
+                       {
+                               try
+                               {
+                                       date = Gitg.Date.parse(env[dateenv]);
+                               }
+                               catch {}
+                       }
+
+                       if (date == null)
+                       {
+                               date = new DateTime.now_local();
+                       }
+
                        var conf = application.repository.get_config();
 
                        if (user == null)
@@ -566,8 +582,9 @@ namespace GitgCommit
                                } catch {}
                        }
 
-                       return new Ggit.Signature.now(user != null ? user : "",
-                                                     email != null ? email : "");
+                       return new Ggit.Signature(user != null ? user : "",
+                                                 email != null ? email : "",
+                                                 date);
                }
 
                private void on_commit_clicked()



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]