unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Alex Kost <alezost@gmail.com>
To: "Ludovic Courtès" <ludo@gnu.org>
Cc: guix-devel@gnu.org
Subject: [PATCH] build: Generate 'AUTHORS'.
Date: Sat, 04 Jul 2015 12:43:23 +0300	[thread overview]
Message-ID: <873814i7gk.fsf_-_@gmail.com> (raw)
In-Reply-To: <87egkt4aij.fsf@gnu.org> ("Ludovic \=\?utf-8\?Q\?Court\=C3\=A8s\=22'\?\= \=\?utf-8\?Q\?s\?\= message of "Tue, 30 Jun 2015 14:59:48 +0200")

[-- Attachment #1: Type: text/plain, Size: 470 bytes --]

I hope the number of commits by each contributor in the generated
AUTHORS file addresses (at least partially) John's concerns about
«the measure of contribution».

The new "build-aux/generate-authors.scm" file may be tested like so:

  guile ~/src/guix/build-aux/generate-authors.scm ~/src/guix /tmp/guix-authors


Not related: I wonder is there a reason to ignore (in .gitignore) the
whole "build-aux" directory?  IIUC this led to commit 8bc35f8, right?


[-- Attachment #2: 0001-build-Generate-AUTHORS.patch --]
[-- Type: text/x-patch, Size: 6480 bytes --]

From 3f8c6b024b3df310f2076ff897af8169d45005da Mon Sep 17 00:00:00 2001
From: Alex Kost <alezost@gmail.com>
Date: Sat, 4 Jul 2015 12:27:26 +0300
Subject: [PATCH] build: Generate 'AUTHORS'.

* build-aux/generate-authors.scm: New file.
* Makefile.am (gen-AUTHORS): New target.
  (dist-hook, .PHONY): Add it.
---
 Makefile.am                    |  12 ++++-
 build-aux/generate-authors.scm | 120 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 130 insertions(+), 2 deletions(-)
 create mode 100644 build-aux/generate-authors.scm

diff --git a/Makefile.am b/Makefile.am
index cc0b135..44d3b09 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,6 +1,7 @@
 # GNU Guix --- Functional package management for GNU
 # Copyright © 2012, 2013, 2014, 2015 Ludovic Courtès <ludo@gnu.org>
 # Copyright © 2013 Andreas Enge <andreas@enge.fr>
+# Copyright © 2015 Alex Kost <alezost@gmail.com>
 #
 # This file is part of GNU Guix.
 #
@@ -363,7 +364,9 @@ guix-binary.%.tar.xz:
 	  "$(top_srcdir)/build-aux/make-binary-tarball.scm" "$*" "$@"
 
 
-dist-hook: sync-descriptions gen-ChangeLog assert-no-store-file-names
+dist-hook: sync-descriptions gen-ChangeLog gen-AUTHORS
+dist-hook: assert-no-store-file-names
+
 distcheck-hook: assert-binaries-available assert-final-inputs-self-contained
 
 sync-descriptions:
@@ -378,6 +381,11 @@ gen-ChangeLog:
 	  mv $(distdir)/cl-t $(distdir)/ChangeLog;	\
 	fi
 
+gen-AUTHORS:
+	$(top_builddir)/pre-inst-env "$(GUILE)"			\
+	  "$(top_srcdir)/build-aux/generate-authors.scm"	\
+	  "$(top_srcdir)" "$(distdir)/AUTHORS"
+
 # Make sure we're not shipping a file that embeds a local /gnu/store file name.
 assert-no-store-file-names:
 	if grep -r --exclude=*.texi --exclude=*.info				\
@@ -397,6 +405,6 @@ assert-final-inputs-self-contained:
 	$(top_builddir)/pre-inst-env "$(GUILE)"				\
 	  "$(top_srcdir)/build-aux/check-final-inputs-self-contained.scm"
 
-.PHONY: sync-descriptions gen-ChangeLog clean-go
+.PHONY: sync-descriptions gen-ChangeLog gen-AUTHORS clean-go
 .PHONY: assert-no-store-file-names assert-binaries-available
 .PHONY: assert-final-inputs-self-contained
diff --git a/build-aux/generate-authors.scm b/build-aux/generate-authors.scm
new file mode 100644
index 0000000..1dc882f
--- /dev/null
+++ b/build-aux/generate-authors.scm
@@ -0,0 +1,120 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2015 Alex Kost <alezost@gmail.com>
+;;;
+;;; 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 <http://www.gnu.org/licenses/>.
+
+;;;
+;;; Generate AUTHORS file for directory with the Guix git repository.
+;;;
+
+(use-modules
+ (ice-9 popen)
+ (ice-9 rdelim)
+ (ice-9 match)
+ (srfi srfi-1)
+ (guix config)
+ (guix utils)
+ (guix build utils))
+
+(define %guix-dir
+  (make-parameter #f))
+
+(define-syntax-rule (append-maybe init-lst (test add-lst) ...)
+  (let* ((lst init-lst)
+         (lst (if test
+                  (append lst add-lst)
+                  lst))
+         ...)
+    lst))
+
+(define (command-output cmd . args)
+  "Execute CMD with ARGS and return its output without trailing newspace."
+  (let* ((port (apply open-pipe* OPEN_READ cmd args))
+         (output (read-string port)))
+    (close-port port)
+    (string-trim-right output #\newline)))
+
+(define (git-output . args)
+  "Execute git command with ARGS and return its output without trailing
+newspace."
+  (with-directory-excursion (%guix-dir)
+    (apply command-output "git" args)))
+
+(define* (contributors-string #:optional (range "HEAD"))
+  "Return a string with names of people contributed to commit RANGE."
+  (git-output "shortlog" "--numbered" "--summary" "--email" range))
+
+(define* (tags #:key pattern sort)
+  "Return a list of the git repository tags.
+PATTERN is passed to '--list' and SORT is passed to '--sort' options of
+'git tag' command."
+  (let* ((args (append-maybe
+                '("tag")
+                (pattern (list "--list" pattern))
+                (sort    (list "--sort" sort))))
+         (output (apply git-output args)))
+    (string-split output #\newline)))
+
+(define (version-tags)
+  "Return only version tags (v0.8, etc.) sorted from the biggest version
+to the smallest one."
+  (tags #:pattern "v*"
+        #:sort "-version:refname"))
+
+(define (generate-authors-file file)
+  "Generate authors FILE."
+  (define previous-release-tag
+    (find (lambda (tag)
+            (version>? %guix-version
+                       (substring tag 1))) ; remove leading 'v'
+          (version-tags)))
+
+  (define release-range
+    (string-append previous-release-tag "..HEAD"))
+
+  (with-output-to-file file
+    (lambda ()
+      (display "\
+GNU Guix consists of Scheme code that implements the deployment model
+of the Nix package management tool.  In fact, it currently talks to a
+build daemon whose code comes from Nix (see the manual for details.)
+
+Nix was initially written by Eelco Dolstra; other people have been
+contributing to it.  See `nix/AUTHORS' for details.\n\n")
+      (format #t "Contributors to GNU Guix ~a:\n\n"
+              %guix-version)
+      (display (contributors-string release-range))
+      (newline) (newline)
+      (display "Overall contributors:\n\n")
+      (display (contributors-string))
+      (newline))))
+
+(define (show-help)
+  (match (command-line)
+    ((me _ ...)
+     (format #t "Usage: guile ~a DIRECTORY AUTHORS
+Generate AUTHORS file for DIRECTORY with the Guix git repository.\n"
+             me))))
+
+(match (command-line)
+  ((_ guix-dir authors-file)
+   (parameterize ((%guix-dir guix-dir))
+     (generate-authors-file authors-file)))
+  (_
+   (show-help)
+   (exit 1)))
+
+;;; generate-authors.scm ends here
-- 
2.4.3


  parent reply	other threads:[~2015-07-04  9:43 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-27 17:53 [PATCH] Clean up 'THANKS' and 'AUTHORS' Alex Kost
2015-06-27 18:00 ` Andreas Enge
2015-06-27 23:42   ` Mark H Weaver
2015-06-27 18:35 ` Paul van der Walt
2015-06-27 23:48   ` Mark H Weaver
2015-06-28  0:14     ` Paul van der Walt
2015-06-28  7:54   ` Alex Kost
2015-06-28  9:25     ` Paul van der Walt
2015-06-28 17:34       ` Alex Kost
2015-06-28 18:28 ` Alex Kost
2015-06-28 20:43   ` Ludovic Courtès
2015-06-29 19:26     ` Generate 'AUTHORS' Alex Kost
2015-06-29 19:51       ` Cyril Roelandt
2015-06-30 12:59       ` Ludovic Courtès
2015-06-30 19:26         ` Alex Kost
2015-06-30 20:56           ` Mark H Weaver
2015-06-30 22:28           ` Ben Woodcroft
2015-07-01  9:25           ` Ludovic Courtès
2015-07-02  5:46           ` [PATCH] Add '.mailmap' Alex Kost
2015-07-02 12:56             ` Ludovic Courtès
2015-07-04  9:43         ` Alex Kost [this message]
2015-07-04 10:33           ` "/build-aux" in ".gitignore" (was [PATCH] build: Generate 'AUTHORS'.) Mathieu Lirzin
2015-07-05 21:43             ` Ludovic Courtès
2015-07-06  9:46               ` [PATCH] Prevent Git from silently ignoring new files Mathieu Lirzin
2015-07-06 16:27                 ` Ludovic Courtès
2015-07-05 21:45           ` [PATCH] build: Generate 'AUTHORS' Ludovic Courtès
2015-06-29 19:35     ` [PATCH] Clean up 'THANKS' and 'AUTHORS' John Darrington
2015-06-29 20:02       ` Cyril Roelandt
2015-06-30 13:03       ` Ludovic Courtès
2015-07-02  5:46   ` Alex Kost

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=873814i7gk.fsf_-_@gmail.com \
    --to=alezost@gmail.com \
    --cc=guix-devel@gnu.org \
    --cc=ludo@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).