spill 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGELOG.md +5 -0
- data/LICENSE.txt +21 -0
- data/README.md +50 -0
- data/exe/spill +5 -0
- data/lib/spill/cli.rb +45 -0
- data/lib/spill/collectors/github.rb +129 -0
- data/lib/spill/collectors/local_git.rb +94 -0
- data/lib/spill/event.rb +7 -0
- data/lib/spill/renderer.rb +90 -0
- data/lib/spill/repo_finder.rb +9 -0
- data/lib/spill/report.rb +45 -0
- data/lib/spill/version.rb +3 -0
- data/lib/spill/window.rb +27 -0
- data/lib/spill.rb +13 -0
- metadata +60 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: e3fbd52dab7cb94bc936122dce281e3f08a854df2814ae8dd136cd7ceb05cc55
|
|
4
|
+
data.tar.gz: d6b2c9fe0a68bae6a2295f84a82c60b16075f142632f3f4362e7a2ad1a8a0bec
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 7c7d6bfe3c753170d59d469f79ac94bfd8655a72fa41141d3808a73cae96ab5ed048c7af2ef7092a06910ae8520630d2d8df6c5065490d064bf254ed05064b16
|
|
7
|
+
data.tar.gz: a9327e2dc50834fc63c7e9afbab1b05954347c98dfa2e96e4908c3c9e91d7d8e07d9509ca24fec7f84edc4e8ce6bb3458d424718d0a5ec8cb8ed3dd58eb21870
|
data/CHANGELOG.md
ADDED
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Tugcem Yalcin
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# spill 🍵
|
|
2
|
+
|
|
3
|
+
Your standup, spilled. `spill` scans a folder of git repos and prints what you
|
|
4
|
+
**did** and what you're **doing** — synthesized from local git and (optionally)
|
|
5
|
+
your GitHub activity via the `gh` CLI. Not a commit dump: merged PRs, reviews
|
|
6
|
+
you gave, branches in flight, uncommitted work.
|
|
7
|
+
|
|
8
|
+
$ cd ~/code && spill
|
|
9
|
+
|
|
10
|
+
spill · Fri Jul 4 · today + yesterday
|
|
11
|
+
|
|
12
|
+
DONE
|
|
13
|
+
icebreaker-bingo · main · 7 commits
|
|
14
|
+
Scaffold Rails 8.1 app on Ruby 4.0.4
|
|
15
|
+
Add QR code page
|
|
16
|
+
GitHub
|
|
17
|
+
merged PR #12 (acme/website) — Fix nav
|
|
18
|
+
reviewed PR #87 (acme/dashboard) — Payout calc
|
|
19
|
+
|
|
20
|
+
DOING
|
|
21
|
+
icebreaker-bingo · feed-page: 3 unpushed commits
|
|
22
|
+
website: uncommitted changes (4 files)
|
|
23
|
+
PR #14 open (acme/website) — Live feed
|
|
24
|
+
|
|
25
|
+
3 quiet repos skipped
|
|
26
|
+
|
|
27
|
+
## Install
|
|
28
|
+
|
|
29
|
+
gem install spill
|
|
30
|
+
|
|
31
|
+
Requires Ruby ≥ 3.2 and `git`. The GitHub section lights up automatically if
|
|
32
|
+
the [gh CLI](https://cli.github.com) is installed and authenticated — no
|
|
33
|
+
tokens, no config. No `gh`? Local git still works; the section is skipped.
|
|
34
|
+
|
|
35
|
+
## Usage
|
|
36
|
+
|
|
37
|
+
spill # scan the current directory (repos up to 2 levels down)
|
|
38
|
+
spill ~/code # scan somewhere else
|
|
39
|
+
spill --since "3 days ago" # wider window ("yesterday", "2 weeks ago", "2026-07-01")
|
|
40
|
+
spill --author me@work.com # override the git author
|
|
41
|
+
spill --no-github # local git only
|
|
42
|
+
|
|
43
|
+
## Roadmap
|
|
44
|
+
|
|
45
|
+
Deployment detection, a NEXT section from issue trackers, and an LLM narrator —
|
|
46
|
+
see [docs/specs](docs/specs/) for the layered design.
|
|
47
|
+
|
|
48
|
+
## License
|
|
49
|
+
|
|
50
|
+
MIT
|
data/exe/spill
ADDED
data/lib/spill/cli.rb
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
require "optparse"
|
|
2
|
+
|
|
3
|
+
module Spill
|
|
4
|
+
class CLI
|
|
5
|
+
def self.run(argv, stdout: $stdout)
|
|
6
|
+
options = { github: true }
|
|
7
|
+
early_exit = false
|
|
8
|
+
parser = OptionParser.new do |opts|
|
|
9
|
+
opts.banner = "Usage: spill [ROOT] [options]"
|
|
10
|
+
opts.on("--since EXPR", 'Window start: "yesterday", "3 days ago", "2026-07-01"') { |v| options[:since] = v }
|
|
11
|
+
opts.on("--author EMAIL", "Override the commit author for all repos") { |v| options[:author] = v }
|
|
12
|
+
opts.on("--no-github", "Skip the GitHub layer") { options[:github] = false }
|
|
13
|
+
opts.on("--version", "Print version") do
|
|
14
|
+
stdout.puts Spill::VERSION
|
|
15
|
+
early_exit = true
|
|
16
|
+
end
|
|
17
|
+
opts.on("-h", "--help", "Show this help") do
|
|
18
|
+
stdout.puts opts
|
|
19
|
+
early_exit = true
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
args = parser.parse(argv)
|
|
24
|
+
return 0 if early_exit
|
|
25
|
+
|
|
26
|
+
report = build_report(args, options)
|
|
27
|
+
color = stdout.respond_to?(:tty?) && stdout.tty? && ENV["NO_COLOR"].nil?
|
|
28
|
+
stdout.puts Renderer.render(report, color: color)
|
|
29
|
+
0
|
|
30
|
+
rescue OptionParser::ParseError, ArgumentError => e
|
|
31
|
+
stdout.puts "spill: #{e.message}"
|
|
32
|
+
0
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def self.build_report(args, options)
|
|
36
|
+
window = options[:since] ? Window.parse(options[:since]) : Window.default
|
|
37
|
+
repo_paths = RepoFinder.find(args.first || Dir.pwd)
|
|
38
|
+
local = Collectors::LocalGit.new(repo_paths: repo_paths, author: options[:author])
|
|
39
|
+
.collect(window: window)
|
|
40
|
+
github = options[:github] ? Collectors::Github.new.collect(window: window) : []
|
|
41
|
+
Report.build(local: local, github: github,
|
|
42
|
+
repos: repo_paths.map { |path| File.basename(path) }, window: window)
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
require "json"
|
|
2
|
+
require "open3"
|
|
3
|
+
require "time"
|
|
4
|
+
|
|
5
|
+
module Spill
|
|
6
|
+
module Collectors
|
|
7
|
+
class Github
|
|
8
|
+
MAX_PAGES = 3
|
|
9
|
+
PAGE_SIZE = 100
|
|
10
|
+
|
|
11
|
+
DEFAULT_RUNNER = lambda do |args|
|
|
12
|
+
out, _err, status = Open3.capture3("gh", *args)
|
|
13
|
+
[ out, status.success? ]
|
|
14
|
+
rescue Errno::ENOENT
|
|
15
|
+
[ "", false ]
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def initialize(runner: DEFAULT_RUNNER)
|
|
19
|
+
@runner = runner
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def collect(window:)
|
|
23
|
+
login = fetch_login
|
|
24
|
+
return nil if login.nil?
|
|
25
|
+
|
|
26
|
+
raw = fetch_raw_events(login)
|
|
27
|
+
return nil if raw.nil?
|
|
28
|
+
|
|
29
|
+
events = raw.filter_map { |item| map_event(item) }
|
|
30
|
+
.select { |event| event.timestamp >= window.since }
|
|
31
|
+
open_prs = open_pr_events(login)
|
|
32
|
+
return nil if open_prs.nil?
|
|
33
|
+
|
|
34
|
+
events.concat(open_prs)
|
|
35
|
+
events << truncation_event(raw) if truncated?(raw, window)
|
|
36
|
+
events
|
|
37
|
+
rescue StandardError
|
|
38
|
+
nil
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
private
|
|
42
|
+
|
|
43
|
+
def fetch_login
|
|
44
|
+
out, ok = @runner.call([ "api", "user" ])
|
|
45
|
+
return nil unless ok
|
|
46
|
+
|
|
47
|
+
JSON.parse(out)["login"]
|
|
48
|
+
rescue JSON::ParserError
|
|
49
|
+
nil
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def fetch_raw_events(login)
|
|
53
|
+
raw = []
|
|
54
|
+
(1..MAX_PAGES).each do |page|
|
|
55
|
+
out, ok = @runner.call([ "api", "users/#{login}/events?per_page=#{PAGE_SIZE}&page=#{page}" ])
|
|
56
|
+
return nil unless ok
|
|
57
|
+
|
|
58
|
+
batch = JSON.parse(out)
|
|
59
|
+
raw.concat(batch)
|
|
60
|
+
break if batch.size < PAGE_SIZE
|
|
61
|
+
end
|
|
62
|
+
raw
|
|
63
|
+
rescue JSON::ParserError
|
|
64
|
+
nil
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def map_event(item)
|
|
68
|
+
repo = item.dig("repo", "name")
|
|
69
|
+
created = item["created_at"]
|
|
70
|
+
return nil if created.nil?
|
|
71
|
+
|
|
72
|
+
time = Time.parse(created).localtime
|
|
73
|
+
case item["type"]
|
|
74
|
+
when "PullRequestEvent" then map_pull_request(item, repo, time)
|
|
75
|
+
when "PullRequestReviewEvent" then build(:review, item.dig("payload", "pull_request"), repo, time)
|
|
76
|
+
when "IssuesEvent"
|
|
77
|
+
build(:issue_closed, item.dig("payload", "issue"), repo, time) if item.dig("payload", "action") == "closed"
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def map_pull_request(item, repo, time)
|
|
82
|
+
pull = item.dig("payload", "pull_request")
|
|
83
|
+
return nil if pull.nil?
|
|
84
|
+
|
|
85
|
+
case item.dig("payload", "action")
|
|
86
|
+
when "opened" then build(:pr_opened, pull, repo, time)
|
|
87
|
+
when "closed" then build(:pr_merged, pull, repo, time) if pull["merged"]
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def build(kind, subject, repo, time)
|
|
92
|
+
return nil if subject.nil?
|
|
93
|
+
|
|
94
|
+
Event.new(source: :github, kind: kind, repo: repo, title: subject["title"],
|
|
95
|
+
ref: "##{subject["number"]}", timestamp: time)
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def open_pr_events(login)
|
|
99
|
+
query = "search/issues?q=is:pr+is:open+author:#{login}&per_page=50&advanced_search=true"
|
|
100
|
+
out, ok = @runner.call([ "api", query ])
|
|
101
|
+
return nil unless ok
|
|
102
|
+
|
|
103
|
+
JSON.parse(out).fetch("items", []).map do |item|
|
|
104
|
+
Event.new(source: :github, kind: :pr_open,
|
|
105
|
+
repo: item["repository_url"].to_s.split("/repos/").last,
|
|
106
|
+
title: item["title"], ref: "##{item["number"]}",
|
|
107
|
+
timestamp: Time.parse(item["updated_at"]).localtime)
|
|
108
|
+
end
|
|
109
|
+
rescue JSON::ParserError
|
|
110
|
+
nil
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
def truncated?(raw, window)
|
|
114
|
+
return false if raw.size < MAX_PAGES * PAGE_SIZE
|
|
115
|
+
|
|
116
|
+
oldest_time(raw) > window.since
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
def truncation_event(raw)
|
|
120
|
+
Event.new(source: :github, kind: :github_truncated, repo: nil,
|
|
121
|
+
extra: { oldest: oldest_time(raw) })
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
def oldest_time(raw)
|
|
125
|
+
raw.map { |item| Time.parse(item["created_at"]) }.min.localtime
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
end
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
require "open3"
|
|
2
|
+
require "time"
|
|
3
|
+
|
|
4
|
+
module Spill
|
|
5
|
+
module Collectors
|
|
6
|
+
class LocalGit
|
|
7
|
+
SEP = "\x1f"
|
|
8
|
+
|
|
9
|
+
def initialize(repo_paths:, author: nil)
|
|
10
|
+
@repo_paths = repo_paths
|
|
11
|
+
@author = author
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def collect(window:)
|
|
15
|
+
@repo_paths.flat_map { |path| repo_events(path, window) }
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
private
|
|
19
|
+
|
|
20
|
+
def repo_events(path, window)
|
|
21
|
+
name = File.basename(path)
|
|
22
|
+
events = []
|
|
23
|
+
email = @author || git(path, "config", "user.email")&.strip
|
|
24
|
+
events.concat(commit_events(path, name, email, window)) unless email.nil? || email.empty?
|
|
25
|
+
events.concat(state_events(path, name))
|
|
26
|
+
events
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def commit_events(path, name, email, window)
|
|
30
|
+
seen = {}
|
|
31
|
+
ordered_branches(path).flat_map do |branch|
|
|
32
|
+
log = git(path, "log", branch, "--no-merges", "--author=#{email}",
|
|
33
|
+
"--since=#{window.since.iso8601}", "--date=iso-strict",
|
|
34
|
+
"--pretty=format:%H#{SEP}%ad#{SEP}%s")
|
|
35
|
+
next [] if log.nil?
|
|
36
|
+
|
|
37
|
+
log.each_line(chomp: true).filter_map do |line|
|
|
38
|
+
sha, date, subject = line.split(SEP, 3)
|
|
39
|
+
next if sha.nil? || seen[sha]
|
|
40
|
+
|
|
41
|
+
seen[sha] = true
|
|
42
|
+
Event.new(source: :local_git, kind: :commit, repo: name, title: subject,
|
|
43
|
+
ref: branch, timestamp: Time.parse(date), extra: { sha: sha })
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def state_events(path, name)
|
|
49
|
+
events = []
|
|
50
|
+
dirty = (git(path, "status", "--porcelain") || "").lines.count
|
|
51
|
+
if dirty.positive?
|
|
52
|
+
events << Event.new(source: :local_git, kind: :dirty_tree, repo: name,
|
|
53
|
+
extra: { files: dirty })
|
|
54
|
+
end
|
|
55
|
+
events.concat(unpushed_events(path, name))
|
|
56
|
+
events
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def unpushed_events(path, name)
|
|
60
|
+
return [] if (git(path, "remote") || "").strip.empty?
|
|
61
|
+
|
|
62
|
+
refs = git(path, "for-each-ref", "refs/heads",
|
|
63
|
+
"--format=%(refname:short)#{SEP}%(upstream:short)#{SEP}%(upstream:track)")
|
|
64
|
+
(refs || "").each_line(chomp: true).filter_map do |line|
|
|
65
|
+
branch, upstream, track = line.split(SEP, 3)
|
|
66
|
+
if upstream.nil? || upstream.empty?
|
|
67
|
+
count = git(path, "rev-list", "--count", branch, "--not", "--remotes").to_i
|
|
68
|
+
next unless count.positive?
|
|
69
|
+
|
|
70
|
+
Event.new(source: :local_git, kind: :branch_wip, repo: name, ref: branch,
|
|
71
|
+
extra: { unpushed: count, no_upstream: true })
|
|
72
|
+
elsif track =~ /ahead (\d+)/
|
|
73
|
+
Event.new(source: :local_git, kind: :branch_wip, repo: name, ref: branch,
|
|
74
|
+
extra: { ahead: Regexp.last_match(1).to_i })
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def ordered_branches(path)
|
|
80
|
+
head = git(path, "symbolic-ref", "--short", "HEAD")&.strip
|
|
81
|
+
all = (git(path, "for-each-ref", "refs/heads", "--format=%(refname:short)") || "")
|
|
82
|
+
.each_line(chomp: true).to_a
|
|
83
|
+
([ head ] + (all - [ head ]).sort).compact.uniq
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
def git(path, *args)
|
|
87
|
+
out, _err, status = Open3.capture3("git", "-C", path, *args)
|
|
88
|
+
status.success? ? out : nil
|
|
89
|
+
rescue Errno::ENOENT
|
|
90
|
+
nil
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
end
|
data/lib/spill/event.rb
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
module Spill
|
|
2
|
+
module Renderer
|
|
3
|
+
module_function
|
|
4
|
+
|
|
5
|
+
def render(report, color: false, now: Time.now)
|
|
6
|
+
lines = [ "#{style("spill", :bold, color)} · #{now.strftime("%a %b %-d")} · #{report.window.label}" ]
|
|
7
|
+
if empty?(report)
|
|
8
|
+
lines << "" << "Nothing to spill. 🍵"
|
|
9
|
+
else
|
|
10
|
+
lines.concat(done_lines(report, color))
|
|
11
|
+
lines.concat(doing_lines(report, color))
|
|
12
|
+
lines.concat(quiet_lines(report, color))
|
|
13
|
+
end
|
|
14
|
+
report.notes.each { |note| lines << "" << style(note, :dim, color) }
|
|
15
|
+
lines.join("\n") << "\n"
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def empty?(report)
|
|
19
|
+
report.done.empty? && report.github_done.empty? && report.doing.empty?
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def done_lines(report, color)
|
|
23
|
+
return [] if report.done.empty? && report.github_done.empty?
|
|
24
|
+
|
|
25
|
+
lines = [ "", style("DONE", :bold, color) ]
|
|
26
|
+
report.done.each do |entry|
|
|
27
|
+
entry[:branches].each do |branch|
|
|
28
|
+
count = branch[:commits].size
|
|
29
|
+
lines << " #{entry[:repo]} · #{branch[:name]} · #{pluralize(count, "commit")}"
|
|
30
|
+
branch[:commits].each { |commit| lines << " #{commit.title}" }
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
if report.github_done.any?
|
|
34
|
+
lines << " GitHub"
|
|
35
|
+
report.github_done.each { |event| lines << " #{github_line(event)}" }
|
|
36
|
+
end
|
|
37
|
+
lines
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def doing_lines(report, color)
|
|
41
|
+
return [] if report.doing.empty?
|
|
42
|
+
|
|
43
|
+
[ "", style("DOING", :bold, color) ] +
|
|
44
|
+
report.doing.map { |event| " #{doing_line(event)}" }
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def quiet_lines(report, color)
|
|
48
|
+
return [] if report.quiet.empty?
|
|
49
|
+
|
|
50
|
+
count = report.quiet.size
|
|
51
|
+
[ "", style("#{count} quiet #{count == 1 ? "repo" : "repos"} skipped", :dim, color) ]
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def github_line(event)
|
|
55
|
+
verb = { pr_merged: "merged PR", pr_opened: "opened PR",
|
|
56
|
+
review: "reviewed PR", issue_closed: "closed issue" }.fetch(event.kind)
|
|
57
|
+
"#{verb} #{event.ref} (#{event.repo})#{title_suffix(event.title)}"
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def title_suffix(title)
|
|
61
|
+
title.to_s.empty? ? "" : " — #{title}"
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def doing_line(event)
|
|
65
|
+
case event.kind
|
|
66
|
+
when :dirty_tree
|
|
67
|
+
"#{event.repo}: uncommitted changes (#{pluralize(event.extra[:files], "file")})"
|
|
68
|
+
when :branch_wip
|
|
69
|
+
if event.extra[:no_upstream]
|
|
70
|
+
"#{event.repo} · #{event.ref}: not pushed yet (#{pluralize(event.extra[:unpushed], "commit")})"
|
|
71
|
+
else
|
|
72
|
+
"#{event.repo} · #{event.ref}: #{event.extra[:ahead]} unpushed #{event.extra[:ahead] == 1 ? "commit" : "commits"}"
|
|
73
|
+
end
|
|
74
|
+
when :pr_open
|
|
75
|
+
"PR #{event.ref.delete_prefix("#").prepend("#")} open (#{event.repo})#{title_suffix(event.title)}"
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def pluralize(count, noun)
|
|
80
|
+
"#{count} #{count == 1 ? noun : "#{noun}s"}"
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def style(text, kind, color)
|
|
84
|
+
return text unless color
|
|
85
|
+
|
|
86
|
+
code = kind == :bold ? 1 : 2
|
|
87
|
+
"\e[#{code}m#{text}\e[0m"
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
end
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
module Spill
|
|
2
|
+
module RepoFinder
|
|
3
|
+
def self.find(root)
|
|
4
|
+
root = File.expand_path(root)
|
|
5
|
+
candidates = [ root ] + Dir.glob(File.join(root, "*")) + Dir.glob(File.join(root, "*", "*"))
|
|
6
|
+
candidates.select { |dir| File.directory?(File.join(dir, ".git")) }.sort
|
|
7
|
+
end
|
|
8
|
+
end
|
|
9
|
+
end
|
data/lib/spill/report.rb
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
module Spill
|
|
2
|
+
Report = Data.define(:window, :done, :github_done, :doing, :quiet, :notes) do
|
|
3
|
+
GITHUB_DONE_KINDS = %i[ pr_opened pr_merged review issue_closed ].freeze
|
|
4
|
+
LOCAL_STATE_KINDS = %i[ branch_wip dirty_tree ].freeze
|
|
5
|
+
|
|
6
|
+
def self.build(local:, github:, repos:, window:)
|
|
7
|
+
local ||= []
|
|
8
|
+
github_events = github || []
|
|
9
|
+
commits = local.select { |event| event.kind == :commit }
|
|
10
|
+
state = local.select { |event| LOCAL_STATE_KINDS.include?(event.kind) }
|
|
11
|
+
|
|
12
|
+
new(
|
|
13
|
+
window: window,
|
|
14
|
+
done: build_done(commits),
|
|
15
|
+
github_done: github_events.select { |e| GITHUB_DONE_KINDS.include?(e.kind) }.sort_by(&:timestamp),
|
|
16
|
+
doing: build_doing(state, github_events),
|
|
17
|
+
quiet: repos - (commits.map(&:repo) + state.map(&:repo)).uniq,
|
|
18
|
+
notes: build_notes(github, github_events)
|
|
19
|
+
)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def self.build_done(commits)
|
|
23
|
+
commits.group_by(&:repo).map do |repo, events|
|
|
24
|
+
branches = events.group_by(&:ref).map do |branch, list|
|
|
25
|
+
{ name: branch, commits: list.sort_by(&:timestamp) }
|
|
26
|
+
end
|
|
27
|
+
{ repo: repo, branches: branches, last: events.map(&:timestamp).max }
|
|
28
|
+
end.sort_by { |entry| entry[:last] }.reverse
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def self.build_doing(state, github_events)
|
|
32
|
+
open_prs = github_events.select { |e| e.kind == :pr_open }
|
|
33
|
+
.sort_by(&:timestamp).reverse
|
|
34
|
+
state.sort_by { |e| [ e.repo, e.kind.to_s ] } + open_prs
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def self.build_notes(github, github_events)
|
|
38
|
+
notes = []
|
|
39
|
+
notes << "GitHub: skipped (gh not available)" if github.nil?
|
|
40
|
+
truncated = github_events.find { |e| e.kind == :github_truncated }
|
|
41
|
+
notes << "GitHub: may be incomplete before #{truncated.extra[:oldest].strftime("%b %-d")}" if truncated
|
|
42
|
+
notes
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
data/lib/spill/window.rb
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
require "time"
|
|
2
|
+
|
|
3
|
+
module Spill
|
|
4
|
+
Window = Data.define(:since, :label) do
|
|
5
|
+
def self.default(now: Time.now)
|
|
6
|
+
new(since: midnight(now) - 86_400, label: "today + yesterday")
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def self.parse(expr, now: Time.now)
|
|
10
|
+
text = expr.strip
|
|
11
|
+
since =
|
|
12
|
+
case text
|
|
13
|
+
when "today" then midnight(now)
|
|
14
|
+
when "yesterday" then midnight(now) - 86_400
|
|
15
|
+
when /\A(\d+)\s+hours?\s+ago\z/ then now - ($1.to_i * 3_600)
|
|
16
|
+
when /\A(\d+)\s+days?\s+ago\z/ then now - ($1.to_i * 86_400)
|
|
17
|
+
when /\A(\d+)\s+weeks?\s+ago\z/ then now - ($1.to_i * 7 * 86_400)
|
|
18
|
+
else Time.parse(text)
|
|
19
|
+
end
|
|
20
|
+
new(since: since, label: text)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def self.midnight(time)
|
|
24
|
+
Time.new(time.year, time.month, time.day)
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
data/lib/spill.rb
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
require_relative "spill/version"
|
|
2
|
+
require_relative "spill/event"
|
|
3
|
+
require_relative "spill/window"
|
|
4
|
+
require_relative "spill/repo_finder"
|
|
5
|
+
require_relative "spill/collectors/local_git"
|
|
6
|
+
require_relative "spill/collectors/github"
|
|
7
|
+
require_relative "spill/report"
|
|
8
|
+
require_relative "spill/renderer"
|
|
9
|
+
require_relative "spill/cli"
|
|
10
|
+
|
|
11
|
+
module Spill
|
|
12
|
+
class Error < StandardError; end
|
|
13
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: spill
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Tugcem Yalcin
|
|
8
|
+
bindir: exe
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies: []
|
|
12
|
+
description: spill scans a folder of git repos and prints a standup report — commits,
|
|
13
|
+
PRs merged, reviews given, and work still in flight — synthesized from local git
|
|
14
|
+
and (optionally) the GitHub CLI.
|
|
15
|
+
email:
|
|
16
|
+
- tugcemyalcin@gmail.com
|
|
17
|
+
executables:
|
|
18
|
+
- spill
|
|
19
|
+
extensions: []
|
|
20
|
+
extra_rdoc_files: []
|
|
21
|
+
files:
|
|
22
|
+
- CHANGELOG.md
|
|
23
|
+
- LICENSE.txt
|
|
24
|
+
- README.md
|
|
25
|
+
- exe/spill
|
|
26
|
+
- lib/spill.rb
|
|
27
|
+
- lib/spill/cli.rb
|
|
28
|
+
- lib/spill/collectors/github.rb
|
|
29
|
+
- lib/spill/collectors/local_git.rb
|
|
30
|
+
- lib/spill/event.rb
|
|
31
|
+
- lib/spill/renderer.rb
|
|
32
|
+
- lib/spill/repo_finder.rb
|
|
33
|
+
- lib/spill/report.rb
|
|
34
|
+
- lib/spill/version.rb
|
|
35
|
+
- lib/spill/window.rb
|
|
36
|
+
homepage: https://github.com/tugcem/spill
|
|
37
|
+
licenses:
|
|
38
|
+
- MIT
|
|
39
|
+
metadata:
|
|
40
|
+
source_code_uri: https://github.com/tugcem/spill
|
|
41
|
+
changelog_uri: https://github.com/tugcem/spill/blob/main/CHANGELOG.md
|
|
42
|
+
rubygems_mfa_required: 'true'
|
|
43
|
+
rdoc_options: []
|
|
44
|
+
require_paths:
|
|
45
|
+
- lib
|
|
46
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
47
|
+
requirements:
|
|
48
|
+
- - ">="
|
|
49
|
+
- !ruby/object:Gem::Version
|
|
50
|
+
version: '3.2'
|
|
51
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
52
|
+
requirements:
|
|
53
|
+
- - ">="
|
|
54
|
+
- !ruby/object:Gem::Version
|
|
55
|
+
version: '0'
|
|
56
|
+
requirements: []
|
|
57
|
+
rubygems_version: 4.0.10
|
|
58
|
+
specification_version: 4
|
|
59
|
+
summary: 'Your standup, spilled: a Done/Doing report from local git and GitHub.'
|
|
60
|
+
test_files: []
|