branch_base 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/.github/dependabot.yml +11 -0
- data/.github/workflows/ci.yaml +76 -0
- data/.gitignore +19 -0
- data/.prettierignore +4 -0
- data/.rspec +5 -0
- data/.rubocop.yml +259 -0
- data/Dockerfile +5 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +124 -0
- data/LICENSE.txt +21 -0
- data/README.md +152 -0
- data/Rakefile +13 -0
- data/branch_base.gemspec +43 -0
- data/internal/git-wrapped.png +0 -0
- data/internal/screenshot.jpg +0 -0
- data/internal/screenshot.png +0 -0
- data/internal/template.html.erb +84 -0
- data/lib/branch_base/cli.rb +79 -0
- data/lib/branch_base/database.rb +98 -0
- data/lib/branch_base/repository.rb +43 -0
- data/lib/branch_base/sync.rb +211 -0
- data/lib/branch_base/version.rb +5 -0
- data/lib/branch_base.rb +97 -0
- data/package.json +13 -0
- data/scripts/branch_base +6 -0
- data/scripts/release_branch_base.sh +22 -0
- data/yarn.lock +20 -0
- metadata +297 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: eac2efb3208cef6e492fac8859c5bf235748568e3e3be1200e7cc617483468c6
|
4
|
+
data.tar.gz: 5fb3a70cab32f0985c776ed703b0b5c099f7ae79402a13359ad284d69362f11d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 399d80d0011a219e2059df531219e99dfe0625f23db6b17f3a6c8b20e54c44ad6c1bd20cce3911a2113f175295dac46a20cdf0f1023f7197cf71c05237a7a3f2
|
7
|
+
data.tar.gz: 2e28d8259736b9c702c692318cd7b81b8eade7ef3cb800f8397524998d06bc096573efe66a9a9f95426a91f121d5c939cdcb6ca5a52000805b9e38d28e52d650
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# To get started with Dependabot version updates, you'll need to specify which
|
2
|
+
# package ecosystems to update and where the package manifests are located.
|
3
|
+
# Please see the documentation for all configuration options:
|
4
|
+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
|
5
|
+
|
6
|
+
version: 2
|
7
|
+
updates:
|
8
|
+
- package-ecosystem: "bundler" # See documentation for possible values
|
9
|
+
directory: "/" # Location of package manifests
|
10
|
+
schedule:
|
11
|
+
interval: "weekly"
|
@@ -0,0 +1,76 @@
|
|
1
|
+
name: CI
|
2
|
+
on:
|
3
|
+
push:
|
4
|
+
branches:
|
5
|
+
- main
|
6
|
+
tags:
|
7
|
+
- "v**"
|
8
|
+
|
9
|
+
pull_request:
|
10
|
+
|
11
|
+
concurrency:
|
12
|
+
group: branch-ci-${{ github.ref }}
|
13
|
+
cancel-in-progress: true
|
14
|
+
|
15
|
+
jobs:
|
16
|
+
rspec:
|
17
|
+
runs-on: ubuntu-latest
|
18
|
+
timeout-minutes: 30
|
19
|
+
name: Ruby ${{ matrix.ruby }}
|
20
|
+
strategy:
|
21
|
+
matrix:
|
22
|
+
ruby: ["2.7.7", "3.0.5", "3.1.4", "3.2.1"]
|
23
|
+
steps:
|
24
|
+
- uses: actions/checkout@v1
|
25
|
+
|
26
|
+
- name: Set up Ruby
|
27
|
+
uses: ruby/setup-ruby@v1
|
28
|
+
with:
|
29
|
+
ruby-version: ${{ matrix.ruby }}
|
30
|
+
bundler-cache: true
|
31
|
+
|
32
|
+
- name: Configure Git
|
33
|
+
run: |
|
34
|
+
git config --global user.email "shayonj@gmail.com"
|
35
|
+
git config --global user.name "Shayon Mukherjee"
|
36
|
+
git config --global init.defaultBranch main
|
37
|
+
|
38
|
+
- name: Bundle install
|
39
|
+
env:
|
40
|
+
RAILS_ENV: test
|
41
|
+
run: |
|
42
|
+
gem install bundler
|
43
|
+
bundle install --jobs 4 --retry 3 --path vendor/bundle
|
44
|
+
|
45
|
+
- name: Run Lint
|
46
|
+
run: bundle exec rubocop
|
47
|
+
|
48
|
+
- name: Run RSpec
|
49
|
+
run: bundle exec rspec
|
50
|
+
|
51
|
+
build-push-image:
|
52
|
+
if: startsWith(github.ref, 'refs/tags/v')
|
53
|
+
runs-on: ubuntu-latest
|
54
|
+
timeout-minutes: 30
|
55
|
+
needs: [rspec]
|
56
|
+
steps:
|
57
|
+
- name: Set up QEMU
|
58
|
+
uses: docker/setup-qemu-action@v2
|
59
|
+
- name: Set up Docker Buildx
|
60
|
+
uses: docker/setup-buildx-action@v2
|
61
|
+
- name: Login to Docker Hub
|
62
|
+
uses: docker/login-action@v2
|
63
|
+
with:
|
64
|
+
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
65
|
+
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
66
|
+
- name: Branch name
|
67
|
+
id: version_name
|
68
|
+
run: |
|
69
|
+
echo ::set-output name=no_v_tag::${GITHUB_REF_NAME:1}
|
70
|
+
- name: Build and push
|
71
|
+
uses: docker/build-push-action@v4
|
72
|
+
with:
|
73
|
+
platforms: linux/amd64,linux/arm64
|
74
|
+
push: true
|
75
|
+
build-args: VERSION=${{ steps.version_name.outputs.no_v_tag }}
|
76
|
+
tags: shayonj/branch_base:latest, shayonj/branch_base:${{ steps.version_name.outputs.no_v_tag }}
|
data/.gitignore
ADDED
data/.prettierignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,259 @@
|
|
1
|
+
require:
|
2
|
+
- rubocop-rspec
|
3
|
+
- rubocop-rake
|
4
|
+
- rubocop-performance
|
5
|
+
|
6
|
+
inherit_mode:
|
7
|
+
merge:
|
8
|
+
- Include
|
9
|
+
- Exclude
|
10
|
+
- AllowedMethods
|
11
|
+
|
12
|
+
AllCops:
|
13
|
+
NewCops: enable
|
14
|
+
Exclude:
|
15
|
+
- "**/.git/**/*"
|
16
|
+
- "**/node_modules/**/*"
|
17
|
+
- "**/Brewfile"
|
18
|
+
TargetRubyVersion: 2.7
|
19
|
+
|
20
|
+
Bundler/OrderedGems:
|
21
|
+
Include:
|
22
|
+
- "**/Gemfile"
|
23
|
+
|
24
|
+
Style/FrozenStringLiteralComment:
|
25
|
+
EnforcedStyle: always
|
26
|
+
|
27
|
+
Style/MutableConstant:
|
28
|
+
EnforcedStyle: literals
|
29
|
+
|
30
|
+
Style/MethodCallWithArgsParentheses:
|
31
|
+
Enabled: true
|
32
|
+
EnforcedStyle: require_parentheses
|
33
|
+
AllowedMethods:
|
34
|
+
- yield
|
35
|
+
- raise
|
36
|
+
- fail
|
37
|
+
- puts
|
38
|
+
- require
|
39
|
+
- require_relative
|
40
|
+
- render
|
41
|
+
- redirect_to
|
42
|
+
- head
|
43
|
+
- throw
|
44
|
+
# RSpec
|
45
|
+
- to
|
46
|
+
- not_to
|
47
|
+
- to_not
|
48
|
+
- and
|
49
|
+
- or
|
50
|
+
Exclude:
|
51
|
+
- "**/Gemfile"
|
52
|
+
- "**/db/migrate/*"
|
53
|
+
- "**/db/schema.rb"
|
54
|
+
|
55
|
+
Style/RedundantInitialize:
|
56
|
+
Enabled: false
|
57
|
+
|
58
|
+
Layout:
|
59
|
+
Enabled: false
|
60
|
+
|
61
|
+
Metrics:
|
62
|
+
Enabled: false
|
63
|
+
|
64
|
+
Naming/AccessorMethodName:
|
65
|
+
Enabled: false
|
66
|
+
|
67
|
+
Naming/MethodParameterName:
|
68
|
+
Enabled: false
|
69
|
+
|
70
|
+
Naming/PredicateName:
|
71
|
+
Enabled: false
|
72
|
+
|
73
|
+
Naming/VariableNumber:
|
74
|
+
Enabled: false
|
75
|
+
|
76
|
+
Style/AsciiComments:
|
77
|
+
Enabled: false
|
78
|
+
|
79
|
+
Style/BlockDelimiters:
|
80
|
+
Enabled: false
|
81
|
+
|
82
|
+
Style/CaseLikeIf:
|
83
|
+
Enabled: false
|
84
|
+
|
85
|
+
Style/ClassAndModuleChildren:
|
86
|
+
Enabled: false
|
87
|
+
|
88
|
+
Style/CommentAnnotation:
|
89
|
+
Enabled: false
|
90
|
+
|
91
|
+
Style/Documentation:
|
92
|
+
Enabled: false
|
93
|
+
|
94
|
+
Style/IfUnlessModifier:
|
95
|
+
Enabled: false
|
96
|
+
|
97
|
+
Style/Lambda:
|
98
|
+
Enabled: false
|
99
|
+
|
100
|
+
Style/ModuleFunction:
|
101
|
+
Enabled: false
|
102
|
+
|
103
|
+
Style/MultilineBlockChain:
|
104
|
+
Enabled: false
|
105
|
+
|
106
|
+
Style/NumericLiterals:
|
107
|
+
Enabled: false
|
108
|
+
|
109
|
+
Style/NumericPredicate:
|
110
|
+
Enabled: false
|
111
|
+
|
112
|
+
Style/ParallelAssignment:
|
113
|
+
Enabled: false
|
114
|
+
|
115
|
+
Style/PerlBackrefs:
|
116
|
+
Enabled: false
|
117
|
+
|
118
|
+
Style/QuotedSymbols:
|
119
|
+
EnforcedStyle: double_quotes
|
120
|
+
Enabled: false
|
121
|
+
|
122
|
+
Style/RaiseArgs:
|
123
|
+
Enabled: false
|
124
|
+
|
125
|
+
Style/RescueStandardError:
|
126
|
+
Enabled: false
|
127
|
+
|
128
|
+
Style/SingleArgumentDig:
|
129
|
+
Enabled: false
|
130
|
+
|
131
|
+
Style/StringLiterals:
|
132
|
+
EnforcedStyle: double_quotes
|
133
|
+
Enabled: false
|
134
|
+
|
135
|
+
Style/StringLiteralsInInterpolation:
|
136
|
+
Enabled: false
|
137
|
+
|
138
|
+
Style/SymbolArray:
|
139
|
+
Enabled: false
|
140
|
+
|
141
|
+
Style/TrailingCommaInArguments:
|
142
|
+
Enabled: false
|
143
|
+
|
144
|
+
Style/TrailingCommaInArrayLiteral:
|
145
|
+
Enabled: false
|
146
|
+
EnforcedStyleForMultiline: consistent_comma
|
147
|
+
|
148
|
+
Style/TrailingCommaInHashLiteral:
|
149
|
+
Enabled: false
|
150
|
+
|
151
|
+
Style/TrailingUnderscoreVariable:
|
152
|
+
Enabled: false
|
153
|
+
|
154
|
+
Style/ZeroLengthPredicate:
|
155
|
+
Enabled: false
|
156
|
+
|
157
|
+
Style/DateTime:
|
158
|
+
Enabled: true
|
159
|
+
|
160
|
+
RSpec/ExpectChange:
|
161
|
+
EnforcedStyle: block
|
162
|
+
|
163
|
+
Gemspec/RequireMFA:
|
164
|
+
Enabled: true
|
165
|
+
|
166
|
+
Gemspec/DevelopmentDependencies:
|
167
|
+
Enabled: false
|
168
|
+
|
169
|
+
# Temporary Rubocop exclusions
|
170
|
+
Style/OpenStructUse:
|
171
|
+
Enabled: false
|
172
|
+
|
173
|
+
# Ruby 3 migration exclusions
|
174
|
+
Style/HashSyntax:
|
175
|
+
Enabled: false
|
176
|
+
|
177
|
+
Naming/BlockForwarding:
|
178
|
+
Enabled: false
|
179
|
+
|
180
|
+
Lint/RedundantDirGlobSort:
|
181
|
+
Enabled: false
|
182
|
+
|
183
|
+
RSpec/ExampleLength:
|
184
|
+
Enabled: false
|
185
|
+
|
186
|
+
RSpec/MultipleExpectations:
|
187
|
+
Enabled: false
|
188
|
+
|
189
|
+
RSpec/VerifiedDoubles:
|
190
|
+
Enabled: false
|
191
|
+
|
192
|
+
RSpec/ContextWording:
|
193
|
+
Enabled: false
|
194
|
+
|
195
|
+
RSpec/AnyInstance:
|
196
|
+
Enabled: false
|
197
|
+
|
198
|
+
RSpec/MessageSpies:
|
199
|
+
Enabled: false
|
200
|
+
|
201
|
+
RSpec/RepeatedDescription:
|
202
|
+
Enabled: false
|
203
|
+
|
204
|
+
RSpec/RepeatedExample:
|
205
|
+
Enabled: false
|
206
|
+
|
207
|
+
RSpec/HookArgument:
|
208
|
+
Enabled: false
|
209
|
+
|
210
|
+
RSpec/DescribeClass:
|
211
|
+
Enabled: false
|
212
|
+
|
213
|
+
RSpec/DescribedClass:
|
214
|
+
Enabled: false
|
215
|
+
|
216
|
+
RSpec/FilePath:
|
217
|
+
Enabled: false
|
218
|
+
|
219
|
+
RSpec/IdenticalEqualityAssertion:
|
220
|
+
Enabled: false
|
221
|
+
|
222
|
+
RSpec/InstanceVariable:
|
223
|
+
Enabled: false
|
224
|
+
|
225
|
+
RSpec/MissingExampleGroupArgument:
|
226
|
+
Enabled: false
|
227
|
+
|
228
|
+
RSpec/MultipleDescribes:
|
229
|
+
Enabled: false
|
230
|
+
|
231
|
+
RSpec/NestedGroups:
|
232
|
+
Enabled: false
|
233
|
+
|
234
|
+
RSpec/PredicateMatcher:
|
235
|
+
Enabled: false
|
236
|
+
|
237
|
+
RSpec/Rails/HttpStatus:
|
238
|
+
Enabled: false
|
239
|
+
|
240
|
+
RSpec/RepeatedExampleGroupDescription:
|
241
|
+
Enabled: false
|
242
|
+
|
243
|
+
RSpec/StubbedMock:
|
244
|
+
Enabled: false
|
245
|
+
|
246
|
+
Lint/UnusedMethodArgument:
|
247
|
+
Enabled: false
|
248
|
+
|
249
|
+
Lint/MissingSuper:
|
250
|
+
Enabled: false
|
251
|
+
|
252
|
+
RSpec/NoExpectationExample:
|
253
|
+
Enabled: false
|
254
|
+
|
255
|
+
Style/AccessorGrouping:
|
256
|
+
Enabled: false
|
257
|
+
|
258
|
+
Style/FormatStringToken:
|
259
|
+
Enabled: false
|
data/Dockerfile
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,124 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
branch_base (0.1.0)
|
5
|
+
rugged
|
6
|
+
sqlite3
|
7
|
+
thor (~> 1.0)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
addressable (2.8.5)
|
13
|
+
public_suffix (>= 2.0.2, < 6.0)
|
14
|
+
ast (2.4.2)
|
15
|
+
coderay (1.1.3)
|
16
|
+
diff-lcs (1.5.0)
|
17
|
+
git (1.18.0)
|
18
|
+
addressable (~> 2.8)
|
19
|
+
rchardet (~> 1.8)
|
20
|
+
haml (6.0.7)
|
21
|
+
temple (>= 0.8.2)
|
22
|
+
thor
|
23
|
+
tilt
|
24
|
+
json (2.7.0)
|
25
|
+
language_server-protocol (3.17.0.3)
|
26
|
+
method_source (1.0.0)
|
27
|
+
parallel (1.23.0)
|
28
|
+
parser (3.2.2.4)
|
29
|
+
ast (~> 2.4.1)
|
30
|
+
racc
|
31
|
+
prettier_print (1.2.1)
|
32
|
+
pry (0.14.2)
|
33
|
+
coderay (~> 1.1)
|
34
|
+
method_source (~> 1.0)
|
35
|
+
public_suffix (5.0.4)
|
36
|
+
racc (1.7.3)
|
37
|
+
rainbow (3.1.1)
|
38
|
+
rake (13.1.0)
|
39
|
+
rbs (1.0.0)
|
40
|
+
rchardet (1.8.0)
|
41
|
+
regexp_parser (2.8.2)
|
42
|
+
rexml (3.2.6)
|
43
|
+
rspec (3.12.0)
|
44
|
+
rspec-core (~> 3.12.0)
|
45
|
+
rspec-expectations (~> 3.12.0)
|
46
|
+
rspec-mocks (~> 3.12.0)
|
47
|
+
rspec-core (3.12.1)
|
48
|
+
rspec-support (~> 3.12.0)
|
49
|
+
rspec-expectations (3.12.2)
|
50
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
51
|
+
rspec-support (~> 3.12.0)
|
52
|
+
rspec-mocks (3.12.5)
|
53
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
54
|
+
rspec-support (~> 3.12.0)
|
55
|
+
rspec-support (3.12.0)
|
56
|
+
rubocop (1.58.0)
|
57
|
+
json (~> 2.3)
|
58
|
+
language_server-protocol (>= 3.17.0)
|
59
|
+
parallel (~> 1.10)
|
60
|
+
parser (>= 3.2.2.4)
|
61
|
+
rainbow (>= 2.2.2, < 4.0)
|
62
|
+
regexp_parser (>= 1.8, < 3.0)
|
63
|
+
rexml (>= 3.2.5, < 4.0)
|
64
|
+
rubocop-ast (>= 1.30.0, < 2.0)
|
65
|
+
ruby-progressbar (~> 1.7)
|
66
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
67
|
+
rubocop-ast (1.30.0)
|
68
|
+
parser (>= 3.2.1.0)
|
69
|
+
rubocop-capybara (2.19.0)
|
70
|
+
rubocop (~> 1.41)
|
71
|
+
rubocop-factory_bot (2.24.0)
|
72
|
+
rubocop (~> 1.33)
|
73
|
+
rubocop-packaging (0.5.2)
|
74
|
+
rubocop (>= 1.33, < 2.0)
|
75
|
+
rubocop-performance (1.19.1)
|
76
|
+
rubocop (>= 1.7.0, < 2.0)
|
77
|
+
rubocop-ast (>= 0.4.0)
|
78
|
+
rubocop-rake (0.6.0)
|
79
|
+
rubocop (~> 1.0)
|
80
|
+
rubocop-rspec (2.25.0)
|
81
|
+
rubocop (~> 1.40)
|
82
|
+
rubocop-capybara (~> 2.17)
|
83
|
+
rubocop-factory_bot (~> 2.22)
|
84
|
+
ruby-progressbar (1.13.0)
|
85
|
+
rugged (1.7.1)
|
86
|
+
sqlite3 (1.6.9-arm64-darwin)
|
87
|
+
sqlite3 (1.6.9-x86_64-linux)
|
88
|
+
syntax_tree (6.2.0)
|
89
|
+
prettier_print (>= 1.2.0)
|
90
|
+
syntax_tree-haml (4.0.3)
|
91
|
+
haml (>= 5.2)
|
92
|
+
prettier_print (>= 1.2.1)
|
93
|
+
syntax_tree (>= 6.0.0)
|
94
|
+
syntax_tree-rbs (1.0.0)
|
95
|
+
prettier_print
|
96
|
+
rbs
|
97
|
+
syntax_tree (>= 2.0.1)
|
98
|
+
temple (0.8.2)
|
99
|
+
thor (1.3.0)
|
100
|
+
tilt (2.0.11)
|
101
|
+
unicode-display_width (2.5.0)
|
102
|
+
|
103
|
+
PLATFORMS
|
104
|
+
arm64-darwin-21
|
105
|
+
x86_64-linux
|
106
|
+
|
107
|
+
DEPENDENCIES
|
108
|
+
branch_base!
|
109
|
+
git
|
110
|
+
prettier_print
|
111
|
+
pry
|
112
|
+
rake
|
113
|
+
rspec
|
114
|
+
rubocop
|
115
|
+
rubocop-packaging
|
116
|
+
rubocop-performance
|
117
|
+
rubocop-rake
|
118
|
+
rubocop-rspec
|
119
|
+
syntax_tree
|
120
|
+
syntax_tree-haml
|
121
|
+
syntax_tree-rbs
|
122
|
+
|
123
|
+
BUNDLED WITH
|
124
|
+
2.4.13
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2023 Shayon Mukherjee
|
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
|
13
|
+
all 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
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,152 @@
|
|
1
|
+
# BranchBase
|
2
|
+
|
3
|
+
`branch_base` is a Ruby gem to synchronize data from a Git repository into a SQLite database. It provides a CLI to easily build and store the data, including commits, branches, and file changes, into a SQLite database.
|
4
|
+
|
5
|
+
You can now easily run, any kind of analytics on your Git directory using the SQLite database.
|
6
|
+
|
7
|
+

|
8
|
+
|
9
|
+
## Features β¨
|
10
|
+
|
11
|
+
- Synchronize Git repository data into a SQLite database.
|
12
|
+
- Query commit history, branch details, and file changes using SQL.
|
13
|
+
- Easy-to-use CLI for quick setup and execution.
|
14
|
+
- πΈ Check out the example below on how you can use `branch_base` to create a Spotify themed Git Wrapped using SQL
|
15
|
+
|
16
|
+
## Usage π οΈ
|
17
|
+
|
18
|
+
After installation, you can use `branch_base` to generate a SQLite Database of a Git repository:
|
19
|
+
|
20
|
+
```bash
|
21
|
+
$ branch_base sync ~/src/rails
|
22
|
+
```
|
23
|
+
|
24
|
+
## Git wrapped πΈ
|
25
|
+
|
26
|
+
Easily generate a Git wrapped with some built-queries and style using `branch_base`
|
27
|
+
|
28
|
+
```bash
|
29
|
+
$ branch_base git-wrapped ~/src/rails
|
30
|
+
2023-12-03 11:40:50 -0500: INFO - BranchBase: Generating Git wrapped for /Users/shayon/src/rails...
|
31
|
+
2023-12-03 11:40:53 -0500: INFO - BranchBase: Git wrapped JSON stored in /Users/shayon/src/rails/git-wrapped.json
|
32
|
+
2023-12-03 11:40:53 -0500: INFO - BranchBase: Git wrapped HTML stored in /Users/shayon/src/rails/git-wrapped.html
|
33
|
+
```
|
34
|
+
|
35
|
+

|
36
|
+
|
37
|
+
## Example SQL Queries π
|
38
|
+
|
39
|
+
Once your repository data is synchronized into a SQLite database, you can run various SQL queries to analyze the data. Here are some examples:
|
40
|
+
|
41
|
+
1. **List all commits**:
|
42
|
+
|
43
|
+
```sql
|
44
|
+
SELECT * FROM commits;
|
45
|
+
```
|
46
|
+
|
47
|
+
2. **Find commits by a specific author**:
|
48
|
+
|
49
|
+
```sql
|
50
|
+
SELECT * FROM commits WHERE author = 'John Doe';
|
51
|
+
```
|
52
|
+
|
53
|
+
3. **Get the number of commits in each branch**:
|
54
|
+
|
55
|
+
```sql
|
56
|
+
SELECT branches.name, COUNT(commits.commit_hash) as commit_count
|
57
|
+
FROM branches
|
58
|
+
JOIN commits ON branches.head_commit = commits.commit_hash
|
59
|
+
GROUP BY branches.name;
|
60
|
+
```
|
61
|
+
|
62
|
+
4. **List files changed in a specific commit**:
|
63
|
+
|
64
|
+
```sql
|
65
|
+
SELECT files.file_path
|
66
|
+
FROM commit_files
|
67
|
+
JOIN files ON commit_files.file_id = files.file_id
|
68
|
+
WHERE commit_files.commit_hash = 'ABC123';
|
69
|
+
```
|
70
|
+
|
71
|
+
5. **Count of Commits per Author**
|
72
|
+
|
73
|
+
```sql
|
74
|
+
SELECT author, COUNT(*) as commit_count
|
75
|
+
FROM commits
|
76
|
+
GROUP BY author
|
77
|
+
ORDER BY commit_count DESC;
|
78
|
+
```
|
79
|
+
|
80
|
+
6. **Authors Who Have Worked on a Specific File**
|
81
|
+
|
82
|
+
```sql
|
83
|
+
SELECT files.file_path, commits.author, COUNT(*) as times_contributed
|
84
|
+
FROM commits
|
85
|
+
JOIN commit_files ON commits.commit_hash = commit_files.commit_hash
|
86
|
+
JOIN files ON commit_files.file_id = files.file_id
|
87
|
+
WHERE files.file_path LIKE '%connection_adapters/sqlite%'
|
88
|
+
GROUP BY files.file_path, commits.author
|
89
|
+
ORDER BY times_contributed DESC;
|
90
|
+
```
|
91
|
+
|
92
|
+
## Installation π₯
|
93
|
+
|
94
|
+
### Via RubyGems π
|
95
|
+
|
96
|
+
You can install `branch_base` directly using RubyGems:
|
97
|
+
|
98
|
+
```bash
|
99
|
+
$ gem install branch_base
|
100
|
+
```
|
101
|
+
|
102
|
+
### Via Docker π³
|
103
|
+
|
104
|
+
`branch_base` is also available as a Docker image, which can be used to run the tool without setting up a Ruby environment:
|
105
|
+
|
106
|
+
```bash
|
107
|
+
$ docker pull shayonj/branch_base:latest
|
108
|
+
```
|
109
|
+
|
110
|
+
To use `branch_base` with Docker, you can mount your Git repository as a volume:
|
111
|
+
|
112
|
+
```bash
|
113
|
+
$ docker run -v /repo/path:/repo shayonj/branch_base sync /repo
|
114
|
+
```
|
115
|
+
|
116
|
+
This command will create a SQLite database with the repository's data in the path where the command is called from
|
117
|
+
|
118
|
+
## Database Schema πΊοΈ
|
119
|
+
|
120
|
+
The SQLite database of the follow tables:
|
121
|
+
|
122
|
+
```
|
123
|
+
repositories
|
124
|
+
β
|
125
|
+
ββ commits βββββ commit_files ββ files
|
126
|
+
β β β
|
127
|
+
ββ branches ββββββββ β
|
128
|
+
β β
|
129
|
+
ββ commit_parents βββββββββββββββββ
|
130
|
+
```
|
131
|
+
|
132
|
+
**Table Descriptions**:
|
133
|
+
|
134
|
+
- `repositories`: Contains details about the repositories.
|
135
|
+
- `commits`: Stores individual commits. Each commit is linked to a repository.
|
136
|
+
- `branches`: Branch information linked to their latest commits.
|
137
|
+
- `files`: Information about files changed in commits. We don't store file contents.
|
138
|
+
- `commit_files`: Associates commits with files, including changes.
|
139
|
+
- `commit_parents`: Tracks parent-child relationships between commits.
|
140
|
+
|
141
|
+
## Contributing π€
|
142
|
+
|
143
|
+
Contributions to `branch_base` are welcome!
|
144
|
+
|
145
|
+
## License π
|
146
|
+
|
147
|
+
Distributed under the MIT License. See `LICENSE` for more information.
|
148
|
+
|
149
|
+
## Development π»
|
150
|
+
|
151
|
+
- Install ruby `3.1.4` using RVM ([instruction](https://rvm.io/rvm/install#any-other-system))
|
152
|
+
- `bundle exec rspec` for specs
|
data/Rakefile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "bundler/gem_tasks"
|
4
|
+
require "rspec/core/rake_task"
|
5
|
+
require "standalone_migrations"
|
6
|
+
|
7
|
+
RSpec::Core::RakeTask.new(:spec)
|
8
|
+
|
9
|
+
require "rubocop/rake_task"
|
10
|
+
|
11
|
+
RuboCop::RakeTask.new
|
12
|
+
|
13
|
+
task default: %i[spec rubocop]
|