浏览代码

authors: Enable auto updates (#5074)

Removes the manual handling of the AUTHORS file, giving every committer automatic credit for their contribution.

Manual tweaks to the file are still accepted and retained by the scripts.
Jakob Borg 7 年之前
父节点
当前提交
d8366e4a88
共有 6 个文件被更改,包括 172 次插入172 次删除
  1. 5 10
      .github/PULL_REQUEST_TEMPLATE.md
  2. 51 6
      AUTHORS
  3. 2 2
      build.sh
  4. 0 1
      gui/default/syncthing/core/aboutModalView.html
  5. 0 150
      meta/authors_test.go
  6. 114 3
      script/authors.go

+ 5 - 10
.github/PULL_REQUEST_TEMPLATE.md

@@ -20,13 +20,8 @@ If this is a user visible change (including API and protocol changes), add a lin
 to the corresponding pull request on https://github.com/syncthing/docs or describe
 the documentation changes necessary.
 
-### Authorship
-
-Every author of a code contribution (Go, Javascript, HTML, CSS etc, with the
-possible exception of minor typo corrections and similar) is recorded in the
-AUTHORS and NICKS files and the in-GUI credits. If this is your first
-contribution, a maintainer will add you properly before accepting the
-contribution. You need not do so yourself or worry about the fact that the
-"authors" automated test fails. However, if your name (such as you want it
-presented in the credits) is not visible on your Github profile or in your
-commit messages, please assist by providing it here.
+## Authorship
+
+Your name and email will be added automatically to the AUTHORS file
+based on the commit metadata.
+

+ 51 - 6
AUTHORS

@@ -1,10 +1,16 @@
 # This is the official list of Syncthing authors for copyright purposes.
-# The format is:
+#
+# THIS FILE IS MOSTLY AUTO GENERATED. IF YOU'VE MADE A COMMIT TO THE
+# REPOSITORY YOU WILL BE ADDED HERE AUTOMATICALLY WITHOUT THE NEED FOR
+# ANY MANUAL ACTION.
+#
+# That said, you are welcome to correct your name or add a nickname / GitHub
+# user name as appropriate. The format is:
 #
 #    Name Name Name (nickname) <[email protected]> <[email protected]>
 #
-# After changing this list, run "go run script/authors.go" to sort and update
-# the GUI HTML.
+# The in-GUI authors list is periodically automatically updated from the
+# contents of this file.
 #
 
 Aaron Bieber (qbit) <[email protected]>
@@ -14,11 +20,14 @@ Alessandro G. (alessandro.g89) <[email protected]>
 Alexander Graf (alex2108) <[email protected]>
 Alexandre Viau (aviau) <[email protected]> <[email protected]>
 Anderson Mesquita (andersonvom) <[email protected]>
+andresvia <[email protected]>
 Andrew Dunham (andrew-d) <[email protected]>
-Andrew Rabert (nvllsvm) <[email protected]>
-Andrey D (scienmind) <[email protected]>
+Andrew Rabert (nvllsvm) <[email protected]> <[email protected]>
+Andrey D (scienmind) <[email protected]> <[email protected]>
+andyleap <[email protected]>
 Antoine Lamielle (0x010C) <[email protected]> <[email protected]>
 Antony Male (canton7) <[email protected]>
+Aranjedeath <[email protected]>
 Arthur Axel fREW Schmidt (frioux) <[email protected]> <[email protected]>
 Audrius Butkevicius (AudriusButkevicius) <[email protected]>
 Bart De Vries (mogwa1) <[email protected]>
@@ -27,17 +36,21 @@ Ben Schulz (uok) <[email protected]> <[email protected]>
 Ben Shepherd (benshep) <[email protected]>
 Ben Sidhom (bsidhom) <[email protected]>
 Benedikt Heine (bebehei) <[email protected]>
+Benedikt Morbach <[email protected]>
 Benny Ng (tpng) <[email protected]>
 Brandon Philips (philips) <[email protected]>
 Brendan Long (brendanlong) <[email protected]>
 Brian R. Becker (brbecker) <[email protected]>
 Caleb Callaway (cqcallaw) <[email protected]>
 Carsten Hagemann (Moter8) <[email protected]>
-Cathryne Linenweaver (Cathryne) <[email protected]> <[email protected]>
+Cathryne Linenweaver (Cathryne) <[email protected]> <[email protected]> <[email protected]>
 Cedric Staniewski (xduugu) <[email protected]>
 Chris Howie (cdhowie) <[email protected]>
 Chris Joel (cdata) <[email protected]>
+Chris Tonkinson <[email protected]>
+chucic <[email protected]>
 Colin Kennedy (moshen) <[email protected]>
+Dale Visser <[email protected]>
 Daniel Bergmann (brgmnn) <[email protected]> <[email protected]>
 Daniel Harte (norgeous) <[email protected]> <[email protected]> <[email protected]>
 Daniel Martí (mvdan) <[email protected]>
@@ -45,9 +58,11 @@ Darshil Chanpura (dtchanpura) <[email protected]> <[email protected]>
 David Rimmer (dinosore) <[email protected]>
 Denis A. (dva) <[email protected]>
 Dennis Wilson (snnd) <[email protected]>
+derekriemer <[email protected]>
 Dmitry Saveliev (dsaveliev) <[email protected]>
 Dominik Heidler (asdil12) <[email protected]>
 Elias Jarlebring (jarlebring) <[email protected]>
+Elliot Huffman <[email protected]>
 Emil Hessman (ceh) <[email protected]>
 Erik Meitner (WSGCSysadmin) <[email protected]>
 Federico Castagnini (facastagnini) <[email protected]>
@@ -57,29 +72,38 @@ Francois-Xavier Gsell (zukoo) <[email protected]>
 Frank Isemann (fti7) <[email protected]>
 Gilli Sigurdsson (gillisig) <[email protected]>
 Graham Miln (grahammiln) <[email protected]> <[email protected]>
+Han Boetes <[email protected]>
 Harrison Jones (harrisonhjones) <[email protected]>
 Heiko Zuerker (Smiley73) <[email protected]>
+Iain Barnett <[email protected]>
 Ian Johnson (anonymouse64) <[email protected]> <[email protected]>
 Jaakko Hannikainen (jgke) <[email protected]>
 Jacek Szafarkiewicz (hadogenes) <[email protected]>
 Jake Peterson (acogdev) <[email protected]>
 Jakob Borg (calmh) <[email protected]> <[email protected]>
 James Patterson (jpjp) <[email protected]> <[email protected]>
+janost <[email protected]>
 Jaroslav Malec (dzarda) <[email protected]>
+jaseg <[email protected]>
 Jaya Chithra (jayachithra) <[email protected]>
 Jens Diemer (jedie) <[email protected]> <[email protected]>
 Jerry Jacobs (xor-gate) <[email protected]> <[email protected]>
 Jochen Voss (seehuhn) <[email protected]>
+Johan Andersson <[email protected]>
 Johan Vromans (sciurius) <[email protected]>
 John Rinehart (fuzzybear3965) <[email protected]>
+Jonathan Cross <[email protected]>
 Jose Manuel Delicado (jmdaweb) <[email protected]> <[email protected]>
 Karol Różycki (krozycki) <[email protected]>
+Keith Turner <[email protected]>
 Kelong Cong (kc1212) <[email protected]> <[email protected]>
 Ken'ichi Kamada (kamadak) <[email protected]>
 Kevin Allen (ironmig) <[email protected]>
 Kevin White, Jr. (kwhite17) <[email protected]>
+klemens <[email protected]>
 Kurt Fitzner (Kudalufi) <[email protected]> <[email protected]>
 Lars K.W. Gohlke (lkwg82) <[email protected]>
+Laurent Arnoud <[email protected]>
 Laurent Etiemble (letiemble) <[email protected]> <[email protected]>
 Leo Arias (elopio) <[email protected]>
 Liu Siyuan (liusy182) <[email protected]> <[email protected]>
@@ -89,50 +113,71 @@ Majed Abdulaziz (majedev) <[email protected]>
 Marc Laporte (marclaporte) <[email protected]> <[email protected]>
 Marc Pujol (kilburn) <[email protected]>
 Marcin Dziadus (marcindziadus) <[email protected]>
+marco-m <[email protected]>
 Mark Pulford (mpx) <[email protected]>
 Mateusz Naściszewski (mateon1) <[email protected]>
+Matic Potočnik <[email protected]>
 Matt Burke (burkemw3) <[email protected]> <[email protected]>
+Matteo Ruina <[email protected]>
 Max Schulze (kralo) <[email protected]> <[email protected]>
+MaximAL <[email protected]>
+Maxime Thirouin <[email protected]>
 Michael Jephcote (Rewt0r) <[email protected]> <[email protected]>
 Michael Ploujnikov (plouj) <[email protected]>
 Michael Tilli (pyfisch) <[email protected]>
+Mike Boone <[email protected]>
+MikeLund <[email protected]>
 Nate Morrison (nrm21) <[email protected]>
 Nicholas Rishel (PrototypeNM1) <[email protected]> <[email protected]>
+Nicolas Braud-Santoni <[email protected]>
 Niels Peter Roest (Niller303) <[email protected]> <[email protected]>
 Nils Jakobi (thunderstorm99) <[email protected]>
+NoLooseEnds <[email protected]>
 Pascal Jungblut (pascalj) <[email protected]> <[email protected]>
 Pawel Palenica (qepasa) <[email protected]>
+perewa <[email protected]>
+Peter Dave Hello <[email protected]>
 Peter Hoeg (peterhoeg) <[email protected]>
 Peter Marquardt (wwwutz) <[email protected]> <[email protected]>
+Phil Davis <[email protected]>
 Philippe Schommers (filoozoom) <[email protected]>
 Phill Luby (pluby) <[email protected]>
+Pier Paolo Ramon <[email protected]>
 Piotr Bejda (piobpl) <[email protected]>
 Pramodh KP (pramodhkp) <[email protected]> <[email protected]>
+Richard Hartmann <[email protected]>
 Robert Carosi (nov1n) <[email protected]>
 Roman Zaynetdinov (zaynetro) <[email protected]>
 Ross Smith II (rasa) <[email protected]>
+rubenbe <[email protected]>
 Ryan Sullivan (KayoticSully) <[email protected]>
 Sacheendra Talluri (sacheendra) <[email protected]>
 Scott Klupfel (kluppy) <[email protected]>
 Sergey Mishin (ralder) <[email protected]>
 Simon Frei (imsodin) <[email protected]>
+Sly_tom_cat <[email protected]>
 Stefan Kuntz (Stefan-Code) <[email protected]> <[email protected]>
 Stefan Tatschner (rumpelsepp) <[email protected]> <[email protected]>
 Suhas Gundimeda (snugghash) <[email protected]> <[email protected]>
 Taylor Khan (nelsonkhan) <[email protected]>
+Thomas Hipp <[email protected]>
 Tim Abell (timabell) <[email protected]>
 Tim Howes (timhowes) <[email protected]>
 Tobias Nygren (tnn2) <[email protected]>
 Tobias Tom (tobiastom) <[email protected]>
 Tomas Cerveny (kozec) <[email protected]>
+Tommy Thorn <[email protected]>
 Tully Robinson (tojrobinson) <[email protected]>
 Tyler Brazier (tylerbrazier) <[email protected]>
 Unrud (Unrud) <[email protected]> <[email protected]>
 Veeti Paananen (veeti) <[email protected]>
 Victor Buinsky (buinsky) <[email protected]>
 Vil Brekin (Vilbrekin) <[email protected]>
+Vladimir Rusinov <[email protected]>
+wangguoliang <[email protected]>
 William A. Kennington III (wkennington) <[email protected]>
 Wulf Weich (wweich) <[email protected]> <[email protected]> <[email protected]>
 Xavier O. (damajor) <[email protected]>
 xjtdy888 (xjtdy888) <[email protected]>
 Yannic A. (eipiminus1) <[email protected]> <[email protected]>
+佛跳墙 <[email protected]>

+ 2 - 2
build.sh

@@ -59,8 +59,8 @@ case "${1:-default}" in
 		go run script/authors.go
 		build transifex
 		pushd man ; ./refresh.sh ; popd
-		git add -A gui man
-		git commit -m 'gui, man: Update docs & translations'
+		git add -A gui man AUTHORS
+		git commit -m 'gui, man, authors: Update docs, translations, and contributors'
 		;;
 
 	noupgrade)

文件差异内容过多而无法显示
+ 0 - 1
gui/default/syncthing/core/aboutModalView.html


+ 0 - 150
meta/authors_test.go

@@ -1,150 +0,0 @@
-// Copyright (C) 2015 The Syncthing Authors.
-//
-// This Source Code Form is subject to the terms of the Mozilla Public
-// License, v. 2.0. If a copy of the MPL was not distributed with this file,
-// You can obtain one at https://mozilla.org/MPL/2.0/.
-
-// Checks for authors that are not mentioned in AUTHORS
-package meta
-
-import (
-	"bytes"
-	"io/ioutil"
-	"os/exec"
-	"regexp"
-	"strings"
-	"testing"
-)
-
-// list of commits that we don't include in our checks; because they are
-// legacy things that don't check code, are committed with incorrect address,
-// or for other reasons.
-var excludeCommits = stringSetFromStrings([]string{
-	"63bd0136fb40a91efaa279cb4b4159d82e8e6904",
-	"4e2feb6fbc791bb8a2daf0ab8efb10775d66343e",
-	"f2459ef3319b2f060dbcdacd0c35a1788a94b8bd",
-	"b61f418bf2d1f7d5a9d7088a20a2a448e5e66801",
-	"a9339d0627fff439879d157c75077f02c9fac61b",
-	"254c63763a3ad42fd82259f1767db526cff94a14",
-	"4b76ec40c07078beaa2c5e250ed7d9bd6276a718",
-	"32a76901a91ff0f663db6f0830e0aedec946e4d0",
-	"3626003f680bad3e63677982576d3a05421e88e9",
-	"342036408e65bd25bb6afbcc705e2e2c013bb01f",
-	"e37cefdbee1c1cd95ad095b5da6d1252723f103b",
-	"bcc5d7c00f52552303b463d43a636f27b7f7e19b",
-	"bc7639b0ffcea52b2197efb1c0bb68b338d1c915",
-})
-
-func TestCheckAuthors(t *testing.T) {
-	if testing.Short() {
-		t.Skip("skipping slow test")
-	}
-
-	actual, hashes := actualAuthorEmails(t, ".", "../cmd/", "../lib/", "../gui/", "../test/", "../script/")
-	listed := listedAuthorEmails(t)
-	missing := actual.except(listed)
-	for author := range missing {
-		t.Logf("Missing author: %s", author)
-		for _, hash := range hashes[author] {
-			t.Logf("  in hash: %s", hash)
-		}
-	}
-	if len(missing) > 0 {
-		t.Errorf("Missing %d author(s)", len(missing))
-	}
-}
-
-// actualAuthorEmails returns the set of author emails found in the actual git
-// commit log, except those in excluded commits.
-func actualAuthorEmails(t *testing.T, paths ...string) (stringSet, map[string][]string) {
-	args := append([]string{"log", "--format=%H %ae"}, paths...)
-	cmd := exec.Command("git", args...)
-	bs, err := cmd.Output()
-	if err != nil {
-		t.Fatal("authorEmails:", err)
-	}
-
-	hashes := make(map[string][]string)
-	authors := newStringSet()
-	for _, line := range bytes.Split(bs, []byte{'\n'}) {
-		fields := strings.Fields(string(line))
-		if len(fields) != 2 {
-			continue
-		}
-
-		hash, author := fields[0], fields[1]
-		if excludeCommits.has(hash) {
-			continue
-		}
-
-		if strings.Contains(strings.ToLower(body(t, hash)), "skip-check: authors") {
-			continue
-		}
-
-		authors.add(author)
-		hashes[author] = append(hashes[author], hash)
-	}
-
-	return authors, hashes
-}
-
-// listedAuthorEmails returns the set of author emails mentioned in AUTHORS
-func listedAuthorEmails(t *testing.T) stringSet {
-	bs, err := ioutil.ReadFile("../AUTHORS")
-	if err != nil {
-		t.Fatal("listedAuthorEmails:", err)
-	}
-
-	emailRe := regexp.MustCompile(`<([^>]+)>`)
-	matches := emailRe.FindAllStringSubmatch(string(bs), -1)
-
-	authors := newStringSet()
-	for _, match := range matches {
-		authors.add(match[1])
-	}
-	return authors
-}
-
-func body(t *testing.T, hash string) string {
-	cmd := exec.Command("git", "show", "--pretty=format:%b", "-s", hash)
-	bs, err := cmd.Output()
-	if err != nil {
-		t.Fatal("body:", err)
-	}
-	return string(bs)
-}
-
-// A simple string set type
-
-type stringSet map[string]struct{}
-
-func newStringSet() stringSet {
-	return make(stringSet)
-}
-
-func stringSetFromStrings(ss []string) stringSet {
-	s := newStringSet()
-	for _, e := range ss {
-		s.add(e)
-	}
-	return s
-}
-
-func (s stringSet) add(e string) {
-	s[e] = struct{}{}
-}
-
-func (s stringSet) has(e string) bool {
-	_, ok := s[e]
-	return ok
-}
-
-func (s stringSet) except(other stringSet) stringSet {
-	diff := newStringSet()
-	for e := range s {
-		if !other.has(e) {
-			diff.add(e)
-		}
-	}
-	return diff
-}

+ 114 - 3
script/authors.go

@@ -32,12 +32,18 @@ var (
 )
 
 const authorsHeader = `# This is the official list of Syncthing authors for copyright purposes.
-# The format is:
+#
+# THIS FILE IS MOSTLY AUTO GENERATED. IF YOU'VE MADE A COMMIT TO THE
+# REPOSITORY YOU WILL BE ADDED HERE AUTOMATICALLY WITHOUT THE NEED FOR
+# ANY MANUAL ACTION.
+#
+# That said, you are welcome to correct your name or add a nickname / GitHub
+# user name as appropriate. The format is:
 #
 #    Name Name Name (nickname) <[email protected]> <[email protected]>
 #
-# After changing this list, run "go run script/authors.go" to sort and update
-# the GUI HTML.
+# The in-GUI authors list is periodically automatically updated from the
+# contents of this file.
 #
 `
 
@@ -50,8 +56,42 @@ type author struct {
 }
 
 func main() {
+	// Read authors from the AUTHORS file
 	authors := getAuthors()
 
+	// Grab the set of thus known email addresses
+	listed := make(stringSet)
+	names := make(map[string]int)
+	for i, a := range authors {
+		names[a.name] = i
+		for _, e := range a.emails {
+			listed.add(e)
+		}
+	}
+
+	// Grab the set of all known authors based on the git log, and add any
+	// missing ones to the authors list.
+	all := allAuthors()
+	for email, name := range all {
+		if listed.has(email) {
+			continue
+		}
+
+		if _, ok := names[name]; ok && name != "" {
+			// We found a match on name
+			authors[names[name]].emails = append(authors[names[name]].emails, email)
+			listed.add(email)
+			continue
+		}
+
+		authors = append(authors, author{
+			name:   name,
+			emails: []string{email},
+		})
+		names[name] = len(authors) - 1
+		listed.add(email)
+	}
+
 	// Write author names in GUI about modal
 
 	getContributions(authors)
@@ -167,6 +207,46 @@ next:
 	}
 }
 
+// list of commits that we don't include in our author file; because they
+// are legacy things that don't affect code, are committed with incorrect
+// address, or for other reasons.
+var excludeCommits = stringSetFromStrings([]string{
+	"a9339d0627fff439879d157c75077f02c9fac61b",
+	"254c63763a3ad42fd82259f1767db526cff94a14",
+	"32a76901a91ff0f663db6f0830e0aedec946e4d0",
+	"bc7639b0ffcea52b2197efb1c0bb68b338d1c915",
+})
+
+// allAuthors returns the set of authors in the git commit log, except those
+// in excluded commits.
+func allAuthors() map[string]string {
+	args := append([]string{"log", "--format=%H %ae %an"})
+	cmd := exec.Command("git", args...)
+	bs, err := cmd.Output()
+	if err != nil {
+		log.Fatal("git:", err)
+	}
+
+	names := make(map[string]string)
+	for _, line := range bytes.Split(bs, []byte{'\n'}) {
+		fields := strings.SplitN(string(line), " ", 3)
+		if len(fields) != 3 {
+			continue
+		}
+		hash, email, name := fields[0], fields[1], fields[2]
+
+		if excludeCommits.has(hash) {
+			continue
+		}
+
+		if names[email] == "" {
+			names[email] = name
+		}
+	}
+
+	return names
+}
+
 type byContributions []author
 
 func (l byContributions) Len() int { return len(l) }
@@ -194,3 +274,34 @@ func (l byName) Less(a, b int) bool {
 }
 
 func (l byName) Swap(a, b int) { l[a], l[b] = l[b], l[a] }
+
+// A simple string set type
+
+type stringSet map[string]struct{}
+
+func stringSetFromStrings(ss []string) stringSet {
+	s := make(stringSet)
+	for _, e := range ss {
+		s.add(e)
+	}
+	return s
+}
+
+func (s stringSet) add(e string) {
+	s[e] = struct{}{}
+}
+
+func (s stringSet) has(e string) bool {
+	_, ok := s[e]
+	return ok
+}
+
+func (s stringSet) except(other stringSet) stringSet {
+	diff := make(stringSet)
+	for e := range s {
+		if !other.has(e) {
+			diff.add(e)
+		}
+	}
+	return diff
+}

部分文件因为文件数量过多而无法显示