gitmarshal 1.1.0 → 1.3.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 +4 -4
- data/README.md +67 -15
- data/gitmarshal.gemspec +12 -13
- data/lib/gitmarshal/cli.rb +42 -10
- data/lib/gitmarshal/github_fetcher.rb +10 -0
- data/lib/gitmarshal/version.rb +1 -1
- data/lib/gitmarshal.rb +2 -2
- 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
@@ -1,9 +1,23 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
<h1 align="center">
|
2
|
+
GitMarshal
|
3
|
+
</h1>
|
3
4
|
|
5
|
+
<p align="center">
|
4
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.
|
5
|
-
|
6
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.
|
8
|
+
</p>
|
9
|
+
|
10
|
+
|
11
|
+
<p align="center">
|
12
|
+
<a href="https://badge.fury.io/rb/gitmarshal"><img src="https://badge.fury.io/rb/gitmarshal.svg" alt="Gem Version"></a>
|
13
|
+
<a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License"></a>
|
14
|
+
<a href="https://codeclimate.com/github/nagstler/gitmarshal/maintainability"><img src="https://api.codeclimate.com/v1/badges/a9c81f4f449374df1e0c/maintainability" alt="Maintainability"></a>
|
15
|
+
<a href="https://github.com/nagstler/gitmarshal/actions/workflows/gem-push.yml"><img src="https://github.com/nagstler/gitmarshal/actions/workflows/gem-push.yml/badge.svg?branch=main" alt="CI Build"></a>
|
16
|
+
</p>
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
|
7
21
|
|
8
22
|
## :sparkles: Features
|
9
23
|
|
@@ -28,22 +42,42 @@ Whether you're a developer interested in the activity of a repository or a manag
|
|
28
42
|
- [License](#license)
|
29
43
|
|
30
44
|
## Prerequisites
|
45
|
+
### 1. Verify Ruby Installation
|
31
46
|
|
32
|
-
Before installing GitMarshal,
|
47
|
+
Before installing GitMarshal, ensure Ruby (version 2.5 or later) is installed on your system. Check your Ruby version using:
|
33
48
|
|
34
49
|
```bash
|
35
50
|
ruby -v
|
36
51
|
```
|
37
52
|
|
38
|
-
|
53
|
+
### 2. Install Ruby (If Not Installed)
|
54
|
+
|
55
|
+
If Ruby is not installed or the version is below 2.5, follow the instructions below to install or upgrade Ruby:
|
56
|
+
#### Ubuntu
|
57
|
+
|
58
|
+
```bash
|
59
|
+
sudo apt-get update
|
60
|
+
sudo apt-get install ruby-full
|
61
|
+
```
|
62
|
+
|
63
|
+
#### MacOS
|
64
|
+
|
65
|
+
```bash
|
66
|
+
brew install ruby
|
67
|
+
```
|
68
|
+
|
69
|
+
#### Windows
|
39
70
|
|
40
|
-
|
41
|
-
|
42
|
-
2. Enter a Note (this can be anything, e.g., "For GitMarshal").
|
43
|
-
3. Under "Select scopes", check the "repo" option.
|
44
|
-
4. Click on "Generate token" at the bottom.
|
71
|
+
Follow the instructions on the [Ruby Installer download page](https://rubyinstaller.org/downloads/) .
|
72
|
+
### 3. Generate GitHub Access Token
|
45
73
|
|
46
|
-
|
74
|
+
To use GitMarshal, generate a GitHub access token:
|
75
|
+
1. Visit [GitHub Tokens New](https://github.com/settings/tokens/new)
|
76
|
+
2. Enter a Note (e.g., "For GitMarshal").
|
77
|
+
3. Check the "repo" option under "Select scopes".
|
78
|
+
4. Click "Generate token" and save the generated token for configuration.
|
79
|
+
|
80
|
+
Now, with Ruby installed and a GitHub token generated, you are ready to install and configure GitMarshal.
|
47
81
|
|
48
82
|
## Installation
|
49
83
|
|
@@ -52,6 +86,7 @@ GitMarshal can be installed directly as a Ruby gem. To do so, simply run the fol
|
|
52
86
|
```bash
|
53
87
|
gem install gitmarshal
|
54
88
|
```
|
89
|
+
|
55
90
|
This command will download and install the GitMarshal gem onto your system.
|
56
91
|
|
57
92
|
## Configuration
|
@@ -76,6 +111,8 @@ To fetch and display a summary of all your GitHub repositories, run:
|
|
76
111
|
gitmarshal
|
77
112
|
```
|
78
113
|
|
114
|
+

|
115
|
+
|
79
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.
|
80
117
|
|
81
118
|
### Fetch Metrics for a Specific Repository
|
@@ -86,17 +123,32 @@ To fetch and display overall metrics for a specific repository, use:
|
|
86
123
|
gitmarshal repo-name
|
87
124
|
```
|
88
125
|
|
126
|
+

|
127
|
+
|
89
128
|
Replace `repo-name` with the name of the repository for which you wish to fetch metrics.
|
90
129
|
|
91
|
-
###
|
130
|
+
### Available Options
|
131
|
+
|
132
|
+
#### `-t`
|
133
|
+
|
134
|
+
Fetch Today's Metrics
|
135
|
+
|
136
|
+
```bash
|
137
|
+
gitmarshal repo-name -t
|
138
|
+
```
|
139
|
+
|
140
|
+

|
141
|
+
|
142
|
+
|
143
|
+
#### `-ch`
|
92
144
|
|
93
|
-
|
145
|
+
Fetch Commit History
|
94
146
|
|
95
147
|
```bash
|
96
|
-
gitmarshal repo-name
|
148
|
+
gitmarshal repo-name -ch
|
97
149
|
```
|
98
150
|
|
99
|
-
|
151
|
+

|
100
152
|
|
101
153
|
### Help Command
|
102
154
|
|
data/gitmarshal.gemspec
CHANGED
@@ -3,19 +3,19 @@
|
|
3
3
|
require_relative "lib/gitmarshal/version"
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
|
-
spec.name
|
7
|
-
spec.version
|
8
|
-
spec.authors
|
9
|
-
spec.email
|
6
|
+
spec.name = "gitmarshal"
|
7
|
+
spec.version = Gitmarshal::VERSION
|
8
|
+
spec.authors = ["Nagendra Dhanakeerthi"]
|
9
|
+
spec.email = ["nagendra.dhanakeerthi@gmail.com"]
|
10
10
|
|
11
|
-
spec.summary
|
12
|
-
spec.description
|
11
|
+
spec.summary = "Command-line tool for fetching and displaying GitHub repository metrics"
|
12
|
+
spec.description = <<-DESC
|
13
13
|
GitMarshal is a command-line tool that allows developers to fetch and display various metrics
|
14
14
|
about GitHub repositories. It provides insights into issues, stargazers, forks, commits,
|
15
15
|
pull requests, and more.
|
16
16
|
DESC
|
17
|
-
spec.homepage
|
18
|
-
spec.license
|
17
|
+
spec.homepage = "https://github.com/nagstler/gitmarshal"
|
18
|
+
spec.license = "MIT"
|
19
19
|
spec.required_ruby_version = Gem::Requirement.new(">= 2.6.0")
|
20
20
|
|
21
21
|
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
@@ -31,14 +31,14 @@ Gem::Specification.new do |spec|
|
|
31
31
|
spec.add_dependency "json", "~> 2.5"
|
32
32
|
spec.add_dependency "thor", "~> 1.1"
|
33
33
|
spec.add_dependency "terminal-table", "~> 3.0.0"
|
34
|
-
spec.add_dependency
|
35
|
-
spec.add_dependency
|
36
|
-
spec.add_dependency
|
34
|
+
spec.add_dependency "colorize", "~> 0.8"
|
35
|
+
spec.add_dependency "octokit", "~> 4.0"
|
36
|
+
spec.add_dependency "faraday-retry", "~> 2.0"
|
37
37
|
|
38
38
|
# Development Dependencies
|
39
39
|
spec.add_development_dependency "rspec", "~> 3.10"
|
40
40
|
spec.add_development_dependency "rubocop", "~> 1.22"
|
41
|
-
|
41
|
+
|
42
42
|
spec.post_install_message = <<-MSG
|
43
43
|
|
44
44
|
#################################################################
|
@@ -58,5 +58,4 @@ Enjoy using GitMarshal!
|
|
58
58
|
#################################################################
|
59
59
|
|
60
60
|
MSG
|
61
|
-
|
62
61
|
end
|
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
|
|
@@ -27,7 +29,7 @@ module GitMarshal
|
|
27
29
|
]
|
28
30
|
end
|
29
31
|
|
30
|
-
table = Terminal::Table.new :title => "Repositories".colorize(:
|
32
|
+
table = Terminal::Table.new :title => "Repositories".colorize(:blue).bold,
|
31
33
|
:headings => ["Name", "Issues", "Stargazers", "Forks"].map { |i| i.colorize(:magenta).bold },
|
32
34
|
:rows => rows
|
33
35
|
|
@@ -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
|
46
|
-
|
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."]
|
49
|
+
|
47
50
|
table = Terminal::Table.new :rows => rows
|
48
|
-
table.title = "GitMarshal Commands".colorize(:
|
49
|
-
table.headings = [
|
51
|
+
table.title = "GitMarshal Commands".colorize(:blue).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
data/lib/gitmarshal.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
|