gitmarshal 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +21 -9
- data/lib/gitmarshal/cli.rb +39 -7
- data/lib/gitmarshal/github_fetcher.rb +10 -0
- data/lib/gitmarshal/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9bc50deb927f02f10f347bbd1bc95f5d20c072418b802a5092793b2366766e98
|
4
|
+
data.tar.gz: '06686a6845fa97a86fd42097ed14e8770c047a65a36c56be3487fc6eb88b0cc7'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 98df05341cf9c9bdda1bfbf7164ddb08642c2d5d38563c9e9c5edc92e98fce97421d2caae599b396b78c681660313029afeebfac3b96ef003e624871675dd54f
|
7
|
+
data.tar.gz: b57340f5c83b753e6d95af988236a5120d199e5912fa7ee07ae666ea9fbaf4e463815b65584c8d38bcc2dc14c529baedff75d6e621b387d7ad71b20c06446cc1
|
data/README.md
CHANGED
@@ -2,11 +2,6 @@
|
|
2
2
|
GitMarshal
|
3
3
|
</h1>
|
4
4
|
|
5
|
-
<p align="center">
|
6
|
-
<img src="https://github.com/nagstler/gitmarshal/assets/1298480/b488174b-7a33-4932-ada8-1b34f641b2a5.gif" alt="animated" />
|
7
|
-
</p>
|
8
|
-
|
9
|
-
|
10
5
|
<p align="center">
|
11
6
|
GitMarshal is a command-line interface (CLI) to extract and display various statistics about GitHub repositories. The metrics it retrieves include the number of commits, pull requests, issues, stars, and contributors.
|
12
7
|
Whether you're a developer interested in the activity of a repository or a manager tracking the progress of your project, GitMarshal provides an easy way to fetch this data directly from your command line.
|
@@ -116,6 +111,8 @@ To fetch and display a summary of all your GitHub repositories, run:
|
|
116
111
|
gitmarshal
|
117
112
|
```
|
118
113
|
|
114
|
+
![list-all](https://github.com/nagstler/gitmarshal/assets/1298480/e9f25862-dca6-42e2-9089-25859fe3fab0)
|
115
|
+
|
119
116
|
This will provide you with a comprehensive list of your repositories and will show the number of issues, stars, and forks for each repository.
|
120
117
|
|
121
118
|
### Fetch Metrics for a Specific Repository
|
@@ -126,17 +123,32 @@ To fetch and display overall metrics for a specific repository, use:
|
|
126
123
|
gitmarshal repo-name
|
127
124
|
```
|
128
125
|
|
126
|
+
![repo-metrics](https://github.com/nagstler/gitmarshal/assets/1298480/d30e9a1c-9c63-4d28-824e-4c73a95997a7)
|
127
|
+
|
129
128
|
Replace `repo-name` with the name of the repository for which you wish to fetch metrics.
|
130
129
|
|
131
|
-
###
|
130
|
+
### Available Options
|
131
|
+
|
132
|
+
#### `-t`
|
133
|
+
|
134
|
+
Fetch Today's Metrics
|
135
|
+
|
136
|
+
```bash
|
137
|
+
gitmarshal repo-name -t
|
138
|
+
```
|
139
|
+
|
140
|
+
![today](https://github.com/nagstler/gitmarshal/assets/1298480/45b62c48-4c01-46e7-9180-5f6b63046df9)
|
141
|
+
|
142
|
+
|
143
|
+
#### `-ch`
|
132
144
|
|
133
|
-
|
145
|
+
Fetch Commit History
|
134
146
|
|
135
147
|
```bash
|
136
|
-
gitmarshal repo-name
|
148
|
+
gitmarshal repo-name -ch
|
137
149
|
```
|
138
150
|
|
139
|
-
|
151
|
+
![ch](https://github.com/nagstler/gitmarshal/assets/1298480/ae690aab-9625-410a-812f-73a736e13949)
|
140
152
|
|
141
153
|
### Help Command
|
142
154
|
|
data/lib/gitmarshal/cli.rb
CHANGED
@@ -1,12 +1,14 @@
|
|
1
1
|
require "thor"
|
2
2
|
require "terminal-table"
|
3
3
|
require "colorize"
|
4
|
+
require "unicode_plot"
|
4
5
|
require_relative "github_fetcher"
|
5
6
|
|
6
7
|
module GitMarshal
|
7
8
|
class CLI < Thor
|
8
9
|
class_option :help, type: :boolean, aliases: "-h", desc: "Display usage information"
|
9
10
|
class_option :today, type: :boolean, aliases: "-t", desc: 'Display today\'s repository metrics instead of overall metrics'
|
11
|
+
class_option :commit_history, type: :boolean, aliases: "-ch", desc: "Display the commit history of the repository"
|
10
12
|
|
11
13
|
desc "repos", "Prints a summary of the authenticated user's GitHub repositories"
|
12
14
|
|
@@ -40,20 +42,21 @@ module GitMarshal
|
|
40
42
|
|
41
43
|
def help(*)
|
42
44
|
rows = []
|
43
|
-
rows << ["gitmarshal", "
|
44
|
-
rows << ["gitmarshal repo-name", "
|
45
|
-
rows << ["gitmarshal repo-name
|
45
|
+
rows << ["gitmarshal", " ", "Display all repositories associated with the authenticated user."]
|
46
|
+
rows << ["gitmarshal repo-name", " ", "Display the overall metrics for the specified repository."]
|
47
|
+
rows << ["gitmarshal repo-name", "-t", "Display the current day's metrics for the specified repository."]
|
48
|
+
rows << ["gitmarshal repo-name", "-ch", "Display the commit history grouped by days for the given repository."]
|
46
49
|
|
47
50
|
table = Terminal::Table.new :rows => rows
|
48
51
|
table.title = "GitMarshal Commands".colorize(:blue).bold
|
49
|
-
table.headings = ["Command", "Description"].map { |i| i.colorize(:magenta).bold }
|
52
|
+
table.headings = ["Command", "Options", "Description"].map { |i| i.colorize(:magenta).bold }
|
50
53
|
table.style = { :border_x => "=", :border_i => "x", :alignment => :left }
|
51
54
|
puts table
|
52
55
|
end
|
53
56
|
|
54
57
|
private
|
55
58
|
|
56
|
-
def metrics(repo_name, today_option = false)
|
59
|
+
def metrics(repo_name, today_option = false, commit_history_option = false)
|
57
60
|
fetcher = GithubFetcher.new
|
58
61
|
user = fetcher.fetch_user
|
59
62
|
|
@@ -69,6 +72,19 @@ module GitMarshal
|
|
69
72
|
end
|
70
73
|
# Display today's metrics in a table
|
71
74
|
display_table("Today's Repository Metrics", rows)
|
75
|
+
elsif commit_history_option
|
76
|
+
commit_history = fetcher.fetch_commit_history(user, repo_name)
|
77
|
+
|
78
|
+
# Prepare table rows for commit history
|
79
|
+
rows = commit_history.map do |date, commit_count|
|
80
|
+
[date, commit_count]
|
81
|
+
end
|
82
|
+
|
83
|
+
# Sort rows by date in descending order
|
84
|
+
rows.sort_by! { |row| -Date.parse(row.first).to_time.to_i }
|
85
|
+
|
86
|
+
# Display commit history in a table
|
87
|
+
display_commit_history_table(rows)
|
72
88
|
else
|
73
89
|
rows = prepare_table_rows(repo)
|
74
90
|
# Display latest commit
|
@@ -88,6 +104,21 @@ module GitMarshal
|
|
88
104
|
text.gsub(/(.{1,#{max_width}})(\s+|\Z)/, "\\1\n")
|
89
105
|
end
|
90
106
|
|
107
|
+
def display_commit_history_table(rows)
|
108
|
+
# Limit to last 30 days
|
109
|
+
rows = rows.last(30)
|
110
|
+
|
111
|
+
if rows.size == 0
|
112
|
+
puts "No data found for commits in the last 30 days."
|
113
|
+
else
|
114
|
+
dates = rows.map { |row| row[0] }
|
115
|
+
commit_counts = rows.map { |row| row[1] }
|
116
|
+
|
117
|
+
plot = UnicodePlot.barplot(dates, commit_counts, title: "Commit History")
|
118
|
+
puts plot.render
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
91
122
|
def prepare_table_rows_for_today(repo)
|
92
123
|
[
|
93
124
|
["Repository Name", repo["name"]],
|
@@ -133,8 +164,9 @@ module GitMarshal
|
|
133
164
|
|
134
165
|
def method_missing(method, *args, &_block)
|
135
166
|
if method =~ /[-a-zA-Z0-9_.]+/
|
136
|
-
today_option = args.include?("--today")
|
137
|
-
|
167
|
+
today_option = args.include?("-t") ? args.include?("-t") : args.include?("--today")
|
168
|
+
commit_history_option = args.include?("-ch") ? args.include?("-ch") : args.include?("--commit-history")
|
169
|
+
metrics(method.to_s, today_option, commit_history_option)
|
138
170
|
else
|
139
171
|
super
|
140
172
|
end
|
@@ -23,6 +23,16 @@ class GithubFetcher
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
+
def fetch_commit_history(user, repo_name)
|
27
|
+
commit_history = {}
|
28
|
+
since_date = (Date.today - 30).to_s
|
29
|
+
Octokit.commits_since("#{user}/#{repo_name}", since_date).each do |commit|
|
30
|
+
date = commit.commit.committer.date.to_date.to_s
|
31
|
+
commit_history[date] = commit_history.fetch(date, 0) + 1
|
32
|
+
end
|
33
|
+
commit_history
|
34
|
+
end
|
35
|
+
|
26
36
|
def fetch_today_repo_metrics(user, repo_name)
|
27
37
|
{
|
28
38
|
"name" => repo_name,
|
data/lib/gitmarshal/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gitmarshal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nagendra Dhanakeerthi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-08-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|