Skip to content

Commit

Permalink
contents/ja/blog: add _2024.html (WIP)
Browse files Browse the repository at this point in the history
  • Loading branch information
hajimehoshi committed Dec 6, 2024
1 parent 166f5e4 commit 6fa9856
Show file tree
Hide file tree
Showing 10 changed files with 739 additions and 0 deletions.
Binary file added _site/images/blog/2024/dest.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _site/images/blog/2024/ehh2023.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _site/images/blog/2024/hexslide.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _site/images/blog/2024/rumpyramid.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _site/images/blog/2024/storyhittsukimushi.webp
Binary file not shown.
Binary file added _site/images/blog/2024/tpotbtmsf.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _site/images/blog/2024/turgatory.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
99 changes: 99 additions & 0 deletions cmd/contributorslister/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
// Copyright 2024 Hajime Hoshi
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package main

import (
"cmp"
"encoding/json"
"flag"
"fmt"
"os"
"os/exec"
"slices"
"strings"
"time"
)

func main() {
if err := xmain(); err != nil {
fmt.Fprintf(os.Stderr, "%v\n", err)
os.Exit(1)
}
}

type commit struct {
Author author `json:"author"`
}

type author struct {
Login string `json:"login"`
}

func xmain() error {
flag.Parse()
repo := "hajimehoshi/ebiten"
if flag.NArg() > 0 {
repo = flag.Arg(0)
}

year := time.Now().Year()

cmd := exec.Command("gh", "api",
"-H", "Accept: application/vnd.github+json",
"-H", "X-GitHub-Api-Version: 2022-11-28",
"--paginate", "--slurp",
fmt.Sprintf("/repos/%s/commits?since=%d-12-01T00:00:00Z&until=%d-12-01T00:00:00Z", repo, year-1, year))
out, err := cmd.Output()
if err != nil {
if e, ok := err.(*exec.ExitError); ok {
return fmt.Errorf("error: %s\n%s", e, e.Stderr)
}
return err
}

var commitArrays [][]commit
if err := json.Unmarshal(out, &commitArrays); err != nil {
return err
}

committerCounts := map[string]int{}
for _, commits := range commitArrays {
for _, c := range commits {
committerCounts[c.Author.Login]++
}
}

type committer struct {
login string
count int
}
var committers []committer
for login, count := range committerCounts {
committers = append(committers, committer{login, count})
}

slices.SortFunc(committers, func(a, b committer) int {
if a.count != b.count {
return -(a.count - b.count)
}
return cmp.Compare(strings.ToLower(a.login), strings.ToLower(b.login))
})

for _, c := range committers {
fmt.Printf("%s: %d\n", c.login, c.count)
}

return nil
}
Loading

0 comments on commit 6fa9856

Please sign in to comment.