From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id eG8mOCT4dmKHeAAAbAwnHQ (envelope-from ) for ; Sun, 08 May 2022 00:52:20 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id 8EQVOCT4dmKGOwAAauVa8A (envelope-from ) for ; Sun, 08 May 2022 00:52:20 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 9531E2B841 for ; Sun, 8 May 2022 00:52:20 +0200 (CEST) Received: from localhost ([::1]:52548 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nnTHf-00079G-OI for larch@yhetil.org; Sat, 07 May 2022 18:52:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44384) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nnTHQ-00078s-UF for guix-devel@gnu.org; Sat, 07 May 2022 18:52:05 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:44760) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nnTHO-0006ec-JJ; Sat, 07 May 2022 18:52:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:In-Reply-To:Date:References:Subject:To: From; bh=qjw+Qt28F4Byy1eWhucv9M0iR6mbnWVskGwBenKBxVw=; b=pfkIdr8l8Cy1e5sc5ock RLBuovF3EMqYPnedyQzLxujdF6DmqstVVtRosZoPFfA5Viq9MicU63g/yn+f9V0cdCb/rrFW/isaQ XZRHbhcBg9xEGVz2nq94GcB3EpthpR6qicbkuX2yl9XT0yF2LsaKWf04+j98BtSovlFa7tPnMV22M /8TrbHGb8ur6xlpWQpexLK2eSYUn8EZxTNP2Sn9at7WF454ugDs2nibQWX4cns+JeObfpDEIBmv8N b7l+lep5UWbhILgsWT1Z8AUC2rtSqhQ9/S3ZqG3xp3y5A/UbZ0PanR0idl5VTpTDhmow2bndp+I4i tjyLvd+N986OEA==; Received: from 91-160-117-201.subs.proxad.net ([91.160.117.201]:60487 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nnTHO-0003a4-5W; Sat, 07 May 2022 18:52:02 -0400 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: Arun Isaac Cc: zimoun , Guix Devel , Kyle Meyer , Ricardo Wurmus Subject: Re: Mumi, public-inbox and tools References: <87bkwf956h.fsf@gmail.com> <87v8umcxpq.fsf@systemreboot.net> X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 19 =?utf-8?Q?Flor=C3=A9al?= an 230 de la =?utf-8?Q?R?= =?utf-8?Q?=C3=A9volution?= X-PGP-Key-ID: 0x090B11993D9AEBB5 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5 X-OS: x86_64-pc-linux-gnu Date: Sun, 08 May 2022 00:52:00 +0200 In-Reply-To: <87v8umcxpq.fsf@systemreboot.net> (Arun Isaac's message of "Tue, 03 May 2022 23:20:09 +0530") Message-ID: <87a6btymzz.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-BeenThere: guix-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+larch=yhetil.org@gnu.org Sender: "Guix-devel" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1651963940; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=F8zfZHN+K1y9gMXNWi+Jt/S0MeF+qwKzSJcYBGhd13U=; b=LudFGr6thREe3eGMx9cEM9/sCmSZCnSIt1wseBKhfHYhPgG3NpsyrJmK/x+bW7uF8VNNVz 5B4r11dQmNGEgUpZuAjydA+OEqsGABSdqnFR+EygB68ZQ0SeObRpSrHIfyE4BoXBl+CPiV sLtdrgBNlHwhTDLg/AfJYaIdqFUD6Fb2HZ1X8rVPb7/hGqn9Af+HFP0Fp6ASIbxaGID6ql jvVc9Xx+Nnp1g1KiRp/LiI2uBd5i0innT+gvA3YSnRggcHocOd073HN4/MGLqiBCmDkjaO +Cw9FnycXIOlvlglmwsBr6ZjzGDfmyvygbaRSnvCh2PsMqyfdQdYT9QYfxLNBw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1651963940; a=rsa-sha256; cv=none; b=b28U9Sp0kRNIktRgDVJr7dkOGHqsf7UUakBceBNnLqXTdWhtdyzL1SLtsv+ASPWlH4GWtQ ftbImD0lBp9vEMk8SsrCwBWTeZgwiV9YK6moTLSP9XwcGnO+M0sqiH6h4qpM4QXfc31BvR dtZllDBIiRahyVmfdBm9UeKDWcT1jyLFkpG9NK9wjyrtGBEIvxg/QaqipJO4GVn/CiUFfd +zSZWaSges8P0mQIxyBNSaWvL1GxZiwoMSIK1VOCgcK3wh2sgvSbsrUWs/Aew39GZUnwz1 UYAIlTQROgLEUbW5TFa7fCawF0zBF1DDnn8fGvfwdM4IJhJtuNZFWLINH1P32w== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=gnu.org header.s=fencepost-gnu-org header.b=pfkIdr8l; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "guix-devel-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-devel-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -2.00 Authentication-Results: aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=gnu.org header.s=fencepost-gnu-org header.b=pfkIdr8l; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "guix-devel-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-devel-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 9531E2B841 X-Spam-Score: -2.00 X-Migadu-Scanner: scn1.migadu.com X-TUID: wVqG+MstO2UY --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hello! The attached super-early-draft =E2=80=98guix review=E2=80=99 script fetches= mboxes from mumi=E2=80=94that part is OK. What=E2=80=99s more difficult is the rest: determining what=E2=80=99s a pat= ch and what=E2=80=99s not (I gather this is something that b4 and Patchwork handle nicely), getting the latest patch series, things like that. Then there=E2=80=99s the big about applying patches in a branch, and option= ally finding out the package differences so the tool can provide feedback and possibly start building things (I think the Guix Data Service has code to help with that.) I think we could have, as a first step, a command that allows us to run: ./pre-inst-env guix review 54874 and that fetches patches, applies them, and ideally reports on the difference and what needs to be built. It=E2=80=99s a relatively low-hanging fruit after all. Thoughts? Ludo=E2=80=99. --=-=-= Content-Type: text/plain; charset=utf-8 Content-Disposition: inline; filename=review.scm Content-Transfer-Encoding: quoted-printable Content-Description: the code ;;; GNU Guix --- Functional package management for GNU ;;; Copyright =C2=A9 2022 Ludovic Court=C3=A8s ;;; ;;; This file is part of GNU Guix. ;;; ;;; GNU Guix is free software; you can redistribute it and/or modify it ;;; under the terms of the GNU General Public License as published by ;;; the Free Software Foundation; either version 3 of the License, or (at ;;; your option) any later version. ;;; ;;; GNU Guix is distributed in the hope that it will be useful, but ;;; WITHOUT ANY WARRANTY; without even the implied warranty of ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;; GNU General Public License for more details. ;;; ;;; You should have received a copy of the GNU General Public License ;;; along with GNU Guix. If not, see . (define-module (guix scripts review) #:use-module (guix scripts) #:use-module (guix ui) #:use-module (guix i18n) #:use-module (guix colors) #:use-module (guix http-client) #:use-module (guix utils) #:use-module ((guix build utils) #:select (find-files invoke)) #:autoload (guix inferior) (open-inferior close-inferior inferior-available-packages) #:autoload (gnu packages) (fold-available-packages) #:autoload (email email) (parse-email email-headers email-body) #:use-module (ice-9 binary-ports) #:use-module (srfi srfi-1) #:use-module (web uri) #:use-module (web http) #:use-module (ice-9 match) #:use-module (ice-9 rdelim) #:use-module (ice-9 format) #:export (guix-review)) (define (patch-set-url number) (string-append "https://issues.guix.gnu.org/issue/" (number->string number) "/patch-set")) (define (monkey-patch!) ;; XXX: Currently mumi returns "Content-Type: text;...", which is conside= red ;; invalid. Work around it. (declare-header! "Content-Type" (lambda (str) (let ((parts (string-split str #\;))) (cons 'text/plain ;<- this is the "fix" (map (lambda (x) (let ((eq (string-index x #\=3D))) (cons (string->symbol (string-trim x char-set:whitespace = 0 eq)) (string-trim-right x char-set:whites= pace (1+ eq))))) (cdr parts))))) (header-validator 'content-type) (header-writer 'content-type)) (set! monkey-patch! (const #t))) (define (download-patch-set directory number) "Download to DIRECTORY the patches of issue NUMBER." (define (patch-file n) (format #f "~a/~3,'0d.patch" directory n)) (define (from-line? str) (string-prefix? "From " str)) (monkey-patch!) (let ((port (http-fetch (string->uri (patch-set-url number))))) (let loop ((n 0) (output (%make-void-port "w0"))) (match (read-line port 'concat) ((? eof-object?) (close-port output) n) ((? from-line? line) (close-port output) (let* ((n (+ n 1)) (new (open-output-file (patch-file n)))) (display line new) (loop n new))) (line (display line output) (loop n output)))))) (define colorize-patch-line (color-rules ("^(---.*)$" BOLD) ("^(\\+\\+\\+.*)$" BOLD) ("^(-.*)$" RED) ("^(\\+.*)$" GREEN) ("^(@@ .* @@)" CYAN))) (define (display-patch file) "Read the patch in FILE and display it to standard output." (define email (parse-email (call-with-input-file file (lambda (port) (read-line port) ;discard the "From " line (get-bytevector-all port))))) (with-paginated-output-port port (match (assoc-ref (email-headers email) 'from) ((from) (format port "From: ~a <~a>~%" (or (assoc-ref from 'name) "") (assoc-ref from 'address)) (format port "Subject: ~a~%" (assoc-ref (email-headers email) 'subject)) (newline port))) (call-with-input-string (email-body email) (lambda (input) (let loop () (match (read-line input 'concat) ((? eof-object?) #t) (line (display (colorize-patch-line line) port) (loop)) (_ (loop)))))))) (define (apply-patch patch) (invoke "git" "am" "-s" patch)) ;;; ;;; Package differences. ;;; (define (available-packages) (fold-available-packages (lambda* (name version result #:key supported? deprecated? #:allow-other-keys) (if (and supported? (not deprecated?)) (alist-cons name version result) result)) '())) (define (new-available-packages) (define %top-builddir (dirname (search-path %load-compiled-path "guix.go"))) (let* ((inferior (open-inferior %top-builddir #:command "scripts/guix")) (packages (inferior-available-packages inferior))) (close-inferior inferior) packages)) ;; (define display-new/upgraded-packages ;; (@@ (guix scripts pull) display-new/upgraded-packages)) ;;; ;;; Command-line options. ;;; (define %default-options '((action . apply))) (define %options '()) ;;; ;;; Entry point. ;;; (define-command (guix-review . args) (category packaging) (synopsis "review patches") (with-error-handling (let* ((options (parse-command-line args %options (list %default-options))) (issue (match (assoc-ref options 'argument) ((=3D string->number number) number) (_ (leave (G_ "missing issue number~%")))))) (call-with-temporary-directory (lambda (directory) (let ((patches (download-patch-set directory issue))) (info (N_ "downloaded ~a patch for issue #~a~%" "downloaded ~a patches for issue #~a~%" patches) patches issue) (if (=3D 1 patches) (match (find-files directory) ((patch) (display-patch patch) (info (G_ "hit enter to apply~%")))) (info (G_ "screen the patches under ~a and hit enter to appl= y~%") directory)) (read-char) (let ((old (available-packages))) (for-each apply-patch (find-files directory)) (invoke "make") (let ((new (new-available-packages))) (pk 'diff (lset-difference equal? new old)) (display-new/upgraded-packages old new #:concise? #f))))))))) ;; Local Variables: ;; eval: (put 'with-binding 'scheme-indent-function 2) ;; End: --=-=-=--