commit-womb
[Top][All Lists]
Advanced

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

[Commit-womb] gnumaint gnumaint


From: Jose E. Marchesi
Subject: [Commit-womb] gnumaint gnumaint
Date: Wed, 30 Aug 2006 20:57:15 +0000

CVSROOT:        /cvsroot/womb
Module name:    gnumaint
Changes by:     Jose E. Marchesi <jemarch>      06/08/30 20:57:15

Modified files:
        .              : gnumaint 

Log message:
        Added recemail operation

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnumaint/gnumaint?cvsroot=womb&r1=1.3&r2=1.4

Patches:
Index: gnumaint
===================================================================
RCS file: /cvsroot/womb/gnumaint/gnumaint,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- gnumaint    30 Aug 2006 19:20:31 -0000      1.3
+++ gnumaint    30 Aug 2006 20:57:15 -0000      1.4
@@ -282,6 +282,17 @@
     puts {}
 }
 
+proc do_help_recemail {} {
+
+    variable mail_activity
+
+    puts "gnumaint recemail - receive an email from a maintainer"
+    puts "Usage:"
+    puts {}
+    puts "  gnumaint recemail"
+    puts {}
+}
+
 proc do_help_operation {topic} {
 
     switch $topic {
@@ -309,6 +320,73 @@
 
 }
 
+proc do_recemail_operation {opargs} {
+
+    variable maintainersdb
+    variable formail
+
+    ;# Read the email from the standard input
+    set email_contents [read -nonewline stdin]
+
+    ;# Get data fields from the received email
+    set from [exec $formail -c -xFrom << $email_contents]
+    set subject [exec $formail -c -xSubject << $email_contents]
+    set reply_to [exec $formail -c -xReply-To << $email_contents]
+    set body [exec $formail -I \"\" << $email_contents]
+
+    ;# Infer the nature of the email from the subject content
+    set subject [string trim $subject]
+    switch $subject {
+
+       ACT {
+           ;#
+           ;# Activity response email
+           ;#
+
+           ;# Search for the package name
+           set pkg_name {}
+           set package_name_regexp ".*\\\$pkgname:(\[^$\]*)\\\$.*"
+           regexp $package_name_regexp $body match pkg_name
+           if {$pkg_name == ""} then {
+               ;# No package mark => discard this email
+           } else {
+
+               ;# Get the right package
+               foreach pkg $maintainersdb {
+
+                   if {$pkg_name == [lindex $pkg 0]} then {
+
+                       ;# Make sure the email sender is a maintainer
+                       ;# for this package
+                       foreach mnt [lindex $pkg 1] {
+
+                           set maintainer_name [lindex $mnt 0]
+                           set maintainer_email [lindex $mnt 1]
+
+                           if {[string match "*$maintainer_email*" $from]} 
then {
+                               
+                               ;# Log the operation
+                               add_to_log \
+                                   "received activity control email reply from 
$maintainer_email for package $pkg_name" 
+
+                               ;# Annotate this reply into the activity file
+                               
+                           }
+
+                           break
+                       }
+
+                       break
+                   }
+               }
+           }
+       }
+       default {
+           ;# Unkown email type. Ignore it.
+       }
+    }
+}
+
 proc do_sendemail_operation {opargs} {
 
     if {[llength $opargs] == 1} then {
@@ -344,12 +422,12 @@
 
 proc do_sendemail_operation_activity {} {
     
-    global maintainersdb
-    global formail
-    global sendmail
-    global mail_activity
-    global email_originator
-    global email_reply
+    variable maintainersdb
+    variable formail
+    variable sendmail
+    variable mail_activity
+    variable email_originator
+    variable email_reply
 
     ;# Read the email template
     set email_contents_file [open $mail_activity r]
@@ -372,6 +450,12 @@
                                      [list %MAINTAINER_NAME $maintainer_name] \
                                      [list %MAINTAINER_EMAIL 
$maintainer_email]]
            set email_contents [fill-template $translation_list $email_template]
+
+           ;# Append the control line
+           set control_line \
+               "\n\n-- Please make sure to include the following line in the 
body of your reply --\n    \$package:$pkg_name\$\n"
+           append email_contents $control_line
+
            set subject_contents [fill-template $translation_list 
$subject_template]
            
            ;# Build the email with formail
@@ -455,7 +539,7 @@
 
 proc do_list_maintainers {which} {
 
-    global maintainersdb
+    variable maintainersdb
 
     set listed_maintainer {}
 
@@ -485,7 +569,7 @@
 
 proc do_list_maintainers_package {package_name} {
 
-    global maintainersdb
+    variable maintainersdb
 
     foreach pkg $maintainersdb {
        
@@ -512,7 +596,7 @@
 
 proc do_list_packages {which} {
 
-    global maintainersdb
+    variable maintainersdb
 
     foreach pkg $maintainersdb {
 
@@ -534,8 +618,8 @@
 
 proc parse_command_line_arguments {} {
 
-    global argc
-    global argv
+    variable argc
+    variable argv
 
     if {$argc == 0} then {
        
@@ -564,6 +648,11 @@
            do_sendemail_operation $argv
 
        }
+       recemail {
+
+           do_recemail_operation $argv
+
+       }
        default {
 
            do_help_usage
@@ -574,7 +663,7 @@
 
 proc main {} {
 
-    global maintainersdb
+    variable maintainersdb
     
     # Override configuration variables from
     # the environment




reply via email to

[Prev in Thread] Current Thread [Next in Thread]