Skip to content

Commit 8cc1d6e

Browse files
committed
Merge branch 'master' of ssh://github.com/elifesciences/maintainers-txt
2 parents 72474f9 + 937a33f commit 8cc1d6e

File tree

7 files changed

+111
-19
lines changed

7 files changed

+111
-19
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ maintainers-txt
66
linux-amd64
77
linux-amd64.sha256
88
alias-map.json
9+
output.svg

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ and `alias-map.json` might look like:
3535
{"jdoe": "[email protected]"}
3636
```
3737

38+
### Graph
39+
40+
To generate a simple pie chart from the output of the `maintainers-txt`:
41+
42+
GITHUB_TOKEN=your-github-token ./maintainers-txt > report.json
43+
go run . graph
44+
3845
## Licence
3946

4047
Copyright © 2024 eLife Sciences

go.mod

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,19 @@ go 1.20
44

55
require (
66
github.com/google/go-github/v55 v55.0.0
7+
github.com/wcharczuk/go-chart/v2 v2.1.1
78
golang.org/x/oauth2 v0.18.0
89
)
910

1011
require (
1112
github.com/ProtonMail/go-crypto v1.0.0 // indirect
13+
github.com/blend/go-sdk v1.20220411.3 // indirect
1214
github.com/cloudflare/circl v1.3.7 // indirect
15+
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect
1316
github.com/golang/protobuf v1.5.4 // indirect
1417
github.com/google/go-querystring v1.1.0 // indirect
1518
golang.org/x/crypto v0.21.0 // indirect
19+
golang.org/x/image v0.11.0 // indirect
1620
golang.org/x/sys v0.18.0 // indirect
1721
google.golang.org/appengine v1.6.8 // indirect
1822
google.golang.org/protobuf v1.33.0 // indirect

go.sum

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
github.com/ProtonMail/go-crypto v1.0.0 h1:LRuvITjQWX+WIfr930YHG2HNfjR1uOfyf5vE0kC2U78=
22
github.com/ProtonMail/go-crypto v1.0.0/go.mod h1:EjAoLdwvbIOoOQr3ihjnSoLZRtE8azugULFRteWMNc0=
3+
github.com/blend/go-sdk v1.20220411.3 h1:GFV4/FQX5UzXLPwWV03gP811pj7B8J2sbuq+GJQofXc=
4+
github.com/blend/go-sdk v1.20220411.3/go.mod h1:7lnH8fTi6U4i1fArEXRyOIY2E1X4MALg09qsQqY1+ak=
35
github.com/bwesterb/go-ristretto v1.2.3/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0=
46
github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA=
57
github.com/cloudflare/circl v1.3.7 h1:qlCDlTPz2n9fu58M0Nh1J/JzcFpfgkFHHX3O35r5vcU=
68
github.com/cloudflare/circl v1.3.7/go.mod h1:sRTcRWXGLrKw6yIGJ+l7amYJFfAXbZG0kBSc8r4zxgA=
9+
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g=
10+
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k=
711
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
812
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
913
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
@@ -15,13 +19,17 @@ github.com/google/go-github/v55 v55.0.0 h1:4pp/1tNMB9X/LuAhs5i0KQAE40NmiR/y6prLN
1519
github.com/google/go-github/v55 v55.0.0/go.mod h1:JLahOTA1DnXzhxEymmFF5PP2tSS9JVNj68mSZNDwskA=
1620
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
1721
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
22+
github.com/wcharczuk/go-chart/v2 v2.1.1 h1:2u7na789qiD5WzccZsFz4MJWOJP72G+2kUuJoSNqWnE=
23+
github.com/wcharczuk/go-chart/v2 v2.1.1/go.mod h1:CyCAUt2oqvfhCl6Q5ZvAZwItgpQKZOkCJGb+VGv6l14=
1824
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
1925
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
2026
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
2127
golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4=
2228
golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU=
2329
golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA=
2430
golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs=
31+
golang.org/x/image v0.11.0 h1:ds2RoQvBvYTiJkwpSFDwCcDFNX7DqjL2WsUgTNk0Ooo=
32+
golang.org/x/image v0.11.0/go.mod h1:bglhjqbqVuEb9e9+eNR45Jfu7D+T4Qan+NhQk8Ck2P8=
2533
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
2634
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
2735
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
@@ -58,6 +66,7 @@ golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
5866
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
5967
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
6068
golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
69+
golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
6170
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
6271
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
6372
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=

graph.go

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package main
2+
3+
import (
4+
"encoding/json"
5+
"fmt"
6+
"os"
7+
8+
"github.com/wcharczuk/go-chart/v2"
9+
)
10+
11+
func graph() {
12+
report_file := "report.json"
13+
report_bytes, err := os.ReadFile(report_file)
14+
panicOnErr(err, "reading report.json")
15+
16+
dest := map[string][]string{}
17+
json.Unmarshal(report_bytes, &dest)
18+
19+
// each slice of the chart is a person,
20+
// the value of each slice is the sum of each percentage
21+
// of each repository they are responsible for.
22+
23+
person_value_idx := map[string]float64{}
24+
for _, person_list := range dest {
25+
num_people := float64(len(person_list))
26+
for _, person := range person_list {
27+
person_value, present := person_value_idx[person]
28+
if !present {
29+
person_value = 0
30+
}
31+
person_value += 1.0 / num_people
32+
person_value_idx[person] = person_value
33+
}
34+
}
35+
36+
vals := []chart.Value{}
37+
for person, value := range person_value_idx {
38+
vals = append(vals, chart.Value{Value: value, Label: person})
39+
}
40+
41+
pie := chart.PieChart{
42+
Width: 512,
43+
Height: 512,
44+
Values: vals,
45+
}
46+
47+
f, _ := os.Create("output.svg")
48+
defer f.Close()
49+
pie.Render(chart.SVG, f)
50+
fmt.Println("wrote output.svg")
51+
}

main.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ func fetch_repos(org_name, token string) []*github.Repository {
210210
return repo_list
211211
}
212212

213-
func main() {
213+
func report() {
214214
args := os.Args[1:]
215215

216216
token := github_token()
@@ -243,7 +243,7 @@ func main() {
243243
if file_exists(path) {
244244
raw_maintainers[repo.GetName()] = slurp(path)
245245
} else {
246-
// https://raw.githubusercontent.com/elifesciences/github-repo-security-alerts/master/maintainers.txt
246+
// https://raw.githubusercontent.com/elifesciences/example-repo/master/maintainers.txt
247247
urltem := "https://raw.githubusercontent.com/%s/%s/%s/maintainers.txt"
248248
url := fmt.Sprintf(urltem, org_name, repo.GetName(), repo.GetDefaultBranch())
249249

@@ -295,3 +295,14 @@ func main() {
295295
os.Exit(1)
296296
}
297297
}
298+
299+
// ---
300+
301+
func main() {
302+
args := os.Args[1:]
303+
if len(args) == 0 || args[0] != "graph" {
304+
report()
305+
} else {
306+
graph()
307+
}
308+
}

manage.sh

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ if test ! "$cmd"; then
99
echo "available commands:"
1010
echo " build build project"
1111
echo " clean removes generated files"
12-
echo " release build project for distribution"
1312
echo " deps.update update project dependencies"
13+
echo " release build project for distribution"
1414
exit 1
1515
fi
1616

@@ -24,6 +24,20 @@ if test "$cmd" = "build"; then
2424
-v
2525
exit 0
2626

27+
elif test "$cmd" = "clean"; then
28+
# *--maintainers.txt - downloaded from repositories
29+
# linux-amd64* linux-arm64* - generated by the 'release' command.
30+
shopt -s nullglob # continue when glob below is empty
31+
rm -fv *--maintainers.txt linux-amd64* linux-arm64*
32+
exit 0
33+
34+
elif test "$cmd" = "deps.update"; then
35+
# -u 'update modules [...] to use newer minor or patch releases when available'
36+
go get -u
37+
go mod tidy
38+
./manage.sh build
39+
exit 0
40+
2741
elif test "$cmd" = "release"; then
2842
# GOOS is 'Go OS' and is being explicit in which OS to build for.
2943
# CGO_ENABLED=0 skips CGO and linking against glibc to build static binaries.
@@ -38,33 +52,28 @@ elif test "$cmd" = "release"; then
3852
-v \
3953
-o linux-amd64
4054
sha256sum linux-amd64 > linux-amd64.sha256
55+
56+
GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build \
57+
-ldflags="-s -w" \
58+
-trimpath \
59+
-v \
60+
-o linux-arm64
61+
sha256sum linux-arm64 > linux-arm64.sha256
62+
4163
echo ---
4264
echo "wrote linux-amd64"
4365
echo "wrote linux-amd64.sha256"
66+
echo "wrote linux-arm64"
67+
echo "wrote linux-arm64.sha256"
4468
exit 0
4569

46-
elif test "$cmd" = "deps.update"; then
70+
elif test "$cmd" = "update-deps"; then
4771
# -u 'update modules [...] to use newer minor or patch releases when available'
4872
go get -u
4973
go mod tidy
5074
./manage.sh build
5175
exit 0
5276

53-
elif test "$cmd" = "clean"; then
54-
shopt -s nullglob # continue when glob below is empty
55-
for file in *--maintainers.txt; do # created during normal operation
56-
rm "$file"
57-
echo "deleted: $file"
58-
done
59-
tbd=( linux-amd64 linux-amd64.sha256 )
60-
for file in "${tbd[@]}"; do # created with ./manage.sh release
61-
if [ -e "$file" ]; then
62-
rm "$file"
63-
echo "deleted $file"
64-
fi
65-
done
66-
exit 0
67-
6877
# ...
6978

7079
fi

0 commit comments

Comments
 (0)