tags 352957 + patch
thanks

Hello!

On Wed, 15 Feb 2006 14:24:49 +0100, Junichi Uekawa wrote:
> C-cC-e
> debian-changelog-unfinalise-last-version
[...]
> What I want is 
[...]
> pbuilder (0.139) unstable; urgency=low
>
>   [Somebody else]
>   * Bug fix: "pbuilder: pdebuild dies if /etc/shadow doesn't exist",
>     thanks to Brian Nelson (Closes: #338976).
>
>   [Junichi Uekawa]
>
>  -- 
[...]
> Is this already implemented somewhere?

In the attached patch, here a list of changes:

  * rename (debian-changelog-maintainer) to
    (debian-changelog-last-maintainer), this is what the function
    really work on (and obviously changing all the calls to it)
  * change how (debian-changelog-last-maintainer) works, returning a
    list of (NAME EMAIL) and not only EMAIL (and obviously adjust all
    the call to it)
  * add (debian-changelog-comaintainer-insert), which actually inserts
    the co-maintainer name in the form "[ NAME ]" [1] [2]
  * add (debian-changelog-comaintainer), which checks if we're in a
    co-maintenance, calling (debian-changelog-comaintainer-insert) [3]
  * add the support for co-maintenance to
    (debian-changelog-unfinalise-last-version)

Comments?

Thx, bye,
Gismo / Luca

Footnotes: 
[1] I really prefer this to "[NAME]" and from the changelog.Debian.gz
    I've installed only about 10 of them use "[NAME]", check with

    $ find /usr/share/doc/ -name changelog.Debian.gz -type f | \ 
       xargs -0 -e zgrep -nH -e "  \["

[2] we can add a variable to have it with or without spaces, but I
    don't think it's worth

[3] we can have three situations: no co-maintenance (need to add),
    co-maintenance but the new maintainer isn't already present in the
    last changelog entry (need to add) or co-maintenance with the new
    maintainer already present (no need to add); I tested the three
    and it works

--- debian-changelog-mode.el	2006-09-06 03:09:01.000000000 +0200
+++ debian-changelog-mode.el_gismo	2006-10-11 22:27:27.000000000 +0200
@@ -303,6 +303,17 @@
 ;;    suggested by Romain Francoise <[EMAIL PROTECTED]> (Closes: #322994)
 ;; V1.82 05Sep2006 Peter Samuelson <[EMAIL PROTECTED]>
 ;;  - Add tilde support for upstream version numbers (Closes: #382514)
+;; V1.83 11Oct2006 Luca Capello <[EMAIL PROTECTED]>
+;;  - Rename `debian-changelog-maintainer' to `debian-changelog-last-maintainer',
+;;    this is what the function really work on
+;;  - `debian-changelog-last-maintainer' now returns a list of "(NAME EMAIL)"
+;;    and not only EMAIL
+;;  - Add `debian-changelog-comaintainer-insert', which actually inserts the
+;;    co-maintainer name in the form "[ NAME ]"
+;;  - Add `debian-changelog-comaintainer', which checks if we're in a
+;;    co-maintenance, calling `debian-changelog-comaintainer-insert'
+;;  - Add co-maintenance support to `debian-changelog-unfinalise-last-version'
+
 
 ;;; Acknowledgements:  (These people have contributed)
 ;;   Roland Rosenfeld <[EMAIL PROTECTED]>
@@ -1144,15 +1155,18 @@
             " <" debian-changelog-mailing-address ">  "
 	    (debian-changelog-date-string))))
 
-(defun debian-changelog-maintainer ()
-  "Return maintainer of last changelog entry."
+(defun debian-changelog-last-maintainer ()
+  "Return maintainer name and e-mail of the last changelog entry as
+a list in the form (NAME EMAIL)."
   (save-excursion
     (goto-char (point-min))
-    (if (re-search-forward "^ -- .*<\\(.*\\)>" nil t)
-        (if (fboundp 'match-string-no-properties)
-            (match-string-no-properties 1)
-          (match-string 1))
-      (error "Maintainer name not found."))))
+    (let ((string
+	   (if (re-search-forward "^ -- \\(.*\\)>" nil t)
+	       (if (fboundp 'match-string-no-properties)
+		   (match-string-no-properties 1)
+		 (match-string 1))
+	     (error "Maintainer name and email not found."))))
+      (split-string string " <"))))
 
 (defun debian-changelog-web-developer-page ()
   "Browse the BTS for the last upload maintainer's developer summary page."
@@ -1162,9 +1176,47 @@
         (load "browse-url" nil t)
         (if (not (featurep 'browse-url))
             (error "This function requires the browse-url elisp package"))))
-  (let ((name (debian-changelog-maintainer)))
-    (browse-url (concat "http://qa.debian.org/developer.php?login="; name))
-    (message "Looking up developer summary page for %s via browse-url" name)))
+  (let ((email (cadr (debian-changelog-last-maintainer))))
+    (browse-url (concat "http://qa.debian.org/developer.php?login="; email))
+    (message "Looking up developer summary page for %s via browse-url" email)))
+
+;; co-maintenance as per bug #352957 by Luca Capello 2006
+(defun debian-changelog-comaintainer-insert (name separator)
+  "In the line before SEPARATOR, insert the co-maintainer name as for
+the form [ NAME ]."
+  (goto-char (point-min))
+  (re-search-forward (concat "\n " separator))
+  (previous-line 1)
+  (insert "\n  [ " name " ]")
+  (when (string= "--" separator)
+    (insert "\n")))
+  
+(defun debian-changelog-comaintainer ()
+  "If the last maintainer is different from the current one, create a
+co-maintained changelog entry."
+  (let ((name (car (debian-changelog-last-maintainer))))
+    (unless (string= name debian-changelog-full-name)
+      (let ((maintainers-found)
+	    (debian-changelog-last-entry-end
+	     (progn (goto-char (point-min))
+		    (re-search-forward "\n --"))))
+	(mapc (lambda (x)
+		(goto-char (point-min))
+		(when (search-forward x debian-changelog-last-entry-end t)
+		  (add-to-list 'maintainers-found x)))
+	      (list name debian-changelog-full-name))
+	;; set the co-maintenanche if any
+	(if maintainers-found
+	    ;; co-maintenance, debian-changelog-full-name is not present
+	    (if (and (member name maintainers-found)
+		     (not (member debian-changelog-full-name
+				  maintainers-found)))
+		(debian-changelog-comaintainer-insert
+		 debian-changelog-full-name "--"))
+	  ;; no co-maintenance
+	  (mapc (lambda (x)
+		  (debian-changelog-comaintainer-insert (car x) (cadr x)))
+		`((,name " *") (,debian-changelog-full-name "--"))))))))
 
 ;;
 ;; interactive function to unfinalise changelog (so modifications can be made)
@@ -1178,6 +1230,7 @@
   (if (debian-changelog-finalised-p) nil
     (error "Most recent version is not finalised"))
   (save-excursion
+    (debian-changelog-comaintainer)
     (goto-char (point-min))
     (re-search-forward "\n --")
     (let ((dels (point)))

Attachment: pgpGHpbY0q35J.pgp
Description: PGP signature

Reply via email to