Last active
August 29, 2015 14:01
-
-
Save richlowe/a58678bfb43db2752d09 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun il--break-lines (pattern) | |
"Break the buffer such that each PATTERN is at the beginning of a line" | |
(save-excursion | |
(goto-char (point-min)) | |
(while (search-forward-regexp pattern nil t) | |
(goto-char (match-beginning 0)) | |
(unless (bolp) | |
(insert "\n")) | |
(goto-char (match-end 0))))) | |
(defun il--insert-approver () | |
"Insert the illumos Approver metadata in the correct spot" | |
(let ((approver (format "%s <%s>" user-full-name user-mail-address))) | |
(goto-char (point-max)) | |
(if (search-backward-regexp "^Approved.by:\\(.*\\)$" nil t) | |
(replace-match (format " %s" approver) nil t nil 1) | |
(search-backward-regexp "^Reviewed.by:.*$") | |
(goto-char (match-end 0)) | |
(insert (format "\nApproved by: %s\n" approver))))) | |
(defun illumos-approve-commit () | |
"Fix an illumos commit message that's been destroyed by `git | |
format-patch', and insert the approval" | |
(interactive) | |
(save-excursion | |
(goto-char (point-min)) | |
;; Split bug IDs | |
(il--break-lines "\\s-[0-9]\\{4,\\}\\s-") | |
;; Split reviewers | |
(il--break-lines "\\(Reviewed\\|Approved\\).by:") | |
(il--insert-approver))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment