support for last_committer and last_author when scanning repos
authorChristian Thaeter <ct@pipapo.org>
Mon, 7 Jan 2008 21:12:49 +0000 (22:12 +0100)
committerChristian Thaeter <ct@pipapo.org>
Mon, 7 Jan 2008 21:12:49 +0000 (22:12 +0100)
src/actions.c
src/repo.c
src/webgit.h

index d141e33..cb2a1ba 100644 (file)
@@ -51,6 +51,8 @@ webgit_main_content_action (struct webgit_query* query)
                                html(html_tag ("th"),"Description"),
                                html(html_tag ("th"),"Owner"),
                                html(html_tag ("th"),"Last Change"),
+                               html(html_tag ("th"),"Author"),
+                               html(html_tag ("th"),"Committer"),
                                html(html_tag ("th"),"Action")
                                ),
                           html_nl()
@@ -67,9 +69,15 @@ webgit_main_content_action (struct webgit_query* query)
                                      html(html_tag ("td"), n->owner),
                                      html(html_tag ("td"),
                                           webgit_object_link (query,
-                                                             n->name, strlen(n->name),
-                                                             n->last_commit, 40,
-                                                             webgit_pretty_age (n->age))
+                                                              n->name, strlen(n->name),
+                                                              n->last_commit, 40,
+                                                              webgit_pretty_age (n->age))
+                                          ),
+                                     html(html_tag ("td"),
+                                          webgit_email_link (n->last_author_name, n->last_author_email)
+                                          ),
+                                     html(html_tag ("td"),
+                                          webgit_email_link (n->last_committer_name, n->last_committer_email)
                                           ),
                                      html(html_tag ("td"),
                                           html(
index 02b3d71..7eb13e8 100644 (file)
@@ -182,14 +182,23 @@ find_last (const char *refname, const unsigned char *sha1, int flags, void *ri)
             {
               self->last_tree = cwa_strndup (i+5, 40);
             }
+          else if (!strncmp (i, "committer ", 10))
+            {
+              const char* name_beg = i+10;
+              char* email_beg = strchr (i, '<');
+              char* email_end = strchr (email_beg, '>');
+
+              self->last_committer_name = cwa_strndup (i+10, email_beg - i - 11);
+              self->last_committer_email = cwa_strndup (email_beg + 1, email_end - email_beg - 1);
+            }
           else if (!strncmp (i, "author ", 7))
             {
-              const char* author_beg = i+7;
+              const char* name_beg = i+7;
               char* email_beg = strchr (i, '<');
               char* email_end = strchr (email_beg, '>');
 
-              self->last_author = cwa_strndup (i+7, email_beg - i - 8);
-              self->last_email = cwa_strndup (email_beg + 1, email_end - email_beg - 1);
+              self->last_author_name = cwa_strndup (i+7, email_beg - i - 8);
+              self->last_author_email = cwa_strndup (email_beg + 1, email_end - email_beg - 1);
             }
           (i = strchr (i, '\n')) && ++i;
         }
@@ -282,8 +291,10 @@ webgit_repoinfo_new (struct webgit_query* query, const char* path)
   ri.last_commit = NULL;
   ri.last_tree = NULL;
   ri.last_head = NULL;
-  ri.last_author = NULL;
-  ri.last_email = NULL;
+  ri.last_committer_name = NULL;
+  ri.last_committer_email = NULL;
+  ri.last_author_name = NULL;
+  ri.last_author_email = NULL;
   ri.query = query;
   ri.age = ~0;
   for_each_branch_ref (find_last, &ri);
@@ -291,8 +302,14 @@ webgit_repoinfo_new (struct webgit_query* query, const char* path)
   self->last_commit = ri.last_commit ? ri.last_commit : cwa_strndup("NO_COMMIT", SIZE_MAX);
   self->last_tree = ri.last_tree ? ri.last_tree : cwa_strndup("NO_TREE", SIZE_MAX);
   self->last_head = ri.last_head ? ri.last_head : cwa_strndup("NO_HEAD", SIZE_MAX);
-  self->last_author = ri.last_author ? ri.last_author : cwa_strndup("NO_AUTHOR", SIZE_MAX);
-  self->last_email = ri.last_email ? ri.last_email : cwa_strndup("NO_EMAIL", SIZE_MAX);
+  self->last_committer_name = ri.last_committer_name ?
+    ri.last_committer_name : cwa_strndup("NO_COMMITTER", SIZE_MAX);
+  self->last_committer_email = ri.last_committer_email ?
+    ri.last_committer_email : cwa_strndup("NO_COMMITTER_EMAIL", SIZE_MAX);
+  self->last_author_name = ri.last_author_name ?
+    ri.last_author_name : cwa_strndup("NO_AUTHOR", SIZE_MAX);
+  self->last_author_email = ri.last_author_email ?
+    ri.last_author_email : cwa_strndup("NO_AUTHOR_EMAIL", SIZE_MAX);
   self->age = ri.age;
 
   return self;
@@ -316,8 +333,10 @@ webgit_repoinfo_free (struct webgit_repo_info* self)
       free (self->last_commit);
       free (self->last_tree);
       free (self->last_head);
-      free (self->last_author);
-      free (self->last_email);
+      free (self->last_committer_name);
+      free (self->last_committer_email);
+      free (self->last_author_name);
+      free (self->last_author_email);
 
       free (self);
     }
index 96c91a6..5a76be7 100644 (file)
@@ -65,8 +65,10 @@ struct webgit_repo_info
   char* last_commit;
   char* last_tree;
   char* last_head;
-  char* last_author;
-  char* last_email;
+  char* last_committer_name;
+  char* last_committer_email;
+  char* last_author_name;
+  char* last_author_email;
 
   unsigned long age;
 };