gitt 3.12.0 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f1c6fdd2f657d51c18a3a0886351529fe259f36e6a75ed618b250bbe27a29715
4
- data.tar.gz: f8ddf8f2f56d1aa092c25e00636b8ef6f3b767e2b4dc5d7df1ea1287e3d02a1f
3
+ metadata.gz: cf995a1e83d2a4b629d45413b6368c0597ee4860bea8116537114a93ee4dfbb4
4
+ data.tar.gz: b83e9922914f836999e24aecaa9204aa112e50fd9d8b3a44397b202b3e257ecb
5
5
  SHA512:
6
- metadata.gz: 8246fdb37693e702974504a4fc3af1198b50b33299b34be52be26ebe0bcece7acbc802af5cc461a09184913dfaa5bba4b4b8fbfda1ae286fcb2670d5fd2c26ca
7
- data.tar.gz: fa8dc14d97590cc2ef83ea0673599cf759413b3916272bb0fea6a6e2e8b6b84743614b5d45bc95901369bd595e93749380962cd8f0ba348a8a7c02d9fd419f6b
6
+ metadata.gz: af182dd15da70427375a655da1b74d74bb15fa3980bc954f931b591c84bf6cf0fb87aea892b42f65e70ea22b8680dfef2979ed96430f57b1d27fd20dc2af9954
7
+ data.tar.gz: b8f3056ba6fa218c79c663d0536404db6f4dd7d061f8c1b45ee3c67a6cf958e143c665c840b00d86d9e659b46643b74bb41a9ec419891eeff683072de008c597
checksums.yaml.gz.sig CHANGED
Binary file
data/README.adoc CHANGED
@@ -8,13 +8,13 @@
8
8
 
9
9
  = Gitt
10
10
 
11
- Provides a monadic Object API to the {git_link} CLI. This project is also an extraction of work originally implemented within the following projects:
11
+ Provides a monadic Object API around the {git_link} CLI with full access to all functionality found when using Git natively. This includes convenience methods for answering fully parsed and enhanced commits, tags, trailers, and so forth. This project is an extraction of work originally implemented within the following projects:
12
12
 
13
13
  * link:https://alchemists.io/projects/git-lint[Git Lint]
14
14
  * link:https://alchemists.io/projects/milestoner[Milestoner]
15
15
  * link:https://alchemists.io/projects/rubysmith[Rubysmith]
16
16
 
17
- This project doesn't try to encompass the vast feature set natively provided by {git_link} but only exposes the most used features, limited as this may be. Over time, more of the {git_link} feature set will be implemented but it'll most likely happen slowly and organically. If you are looking for alternatives to this gem, then you might find the following of interest:
17
+ If you are looking for alternatives to this gem, then you might find the following of interest:
18
18
 
19
19
  * link:https://github.com/ruby-git/ruby-git[Ruby Git]
20
20
  * link:https://github.com/libgit2/rugged[Rugged]
@@ -24,7 +24,7 @@ toc::[]
24
24
  == Features
25
25
 
26
26
  * Wraps a subset of native {git_link} commands with additional enhancements to improve your working experience.
27
- * Answers link:https://dry-rb.org/gems/dry-monads[monads] you can link:https://alchemists.io/projects/transactable[pipe] together for more complex workflows.
27
+ * Answers link:https://dry-rb.org/gems/dry-monads[monads] you can link:https://alchemists.io/articles/ruby_function_composition[pipe] together for more complex workflows.
28
28
  * Provides _optional_ {rspec_link} shared contexts that speed up the testing of your own Git related implementations.
29
29
 
30
30
  == Requirements
@@ -47,20 +47,22 @@ At a high level, this project provides a centralized Object API via a single obj
47
47
 
48
48
  [source,ruby]
49
49
  ----
50
- git = Gitt::Repository.new
50
+ git = Gitt.new
51
51
 
52
52
  git.branch # Equivalent to `git branch <arguments>`.
53
53
  git.branch_default # Answers default branch.
54
54
  git.branch_name # Answers current branch.
55
55
  git.call # Allows you to run any Git command.
56
- git.commits # Answers commit records.
56
+ git.commits # Answers enhanced commit records.
57
57
  git.config # Equivalent to `git config <arguments>`.
58
58
  git.exist? # Answers if current directory is a Git repository or not.
59
59
  git.get # Equivalent to `git config get`.
60
+ git.inspect # Allows you to inspect the current instance.
60
61
  git.log # Equivalent to `git log <arguments>`.
61
62
  git.origin? # Answers if repository has an origin or not.
62
63
  git.set # Equivalent to `get config set`.
63
64
  git.tag # Equivalent to `git tag <arguments>`.
65
+ git.tags # Answers enhanced tag records.
64
66
  git.tag? # Answers if local or remote tag exists.
65
67
  git.tag_create # Create a new tag.
66
68
  git.tag_last # Answers last tag created.
@@ -68,16 +70,14 @@ git.tag_local? # Answers if local tag exists?
68
70
  git.tag_remote? # Answers if remote tag exists?
69
71
  git.tag_show # Answers information about a single tag.
70
72
  git.tagged? # Answers if the repository has any tags.
71
- git.tags # Answers all tags.
72
73
  git.tags_push # Pushes local tags to remote git.
73
- git.uncommitted # Parses a file and answers an unsaved commit message.
74
-
74
+ git.uncommitted # Parses `COMMIT_EDITMSG` file and answers the unsaved commit message.
75
75
  ----
76
76
 
77
77
  === Commands
78
78
 
79
- Should you want to use individual commands instead of interacting with the `Repository` object, you
80
- can leverage any of the objects in the `Commands` namespace which -- at a minimum -- use the link:https://alchemists.io/articles/interactor_pattern[Command Pattern]. Here are the specific commands which are enhanced further:
79
+ Should you want to use individual commands instead of interacting with the `Gitt` object, you
80
+ can leverage any of the objects in the `Commands` namespace which -- at a minimum -- use the link:https://alchemists.io/articles/command_pattern[Command Pattern]. Here are the specific commands which are enhanced further:
81
81
 
82
82
  ==== link:https://git-scm.com/docs/git-branch[Branch]
83
83
 
@@ -148,7 +148,7 @@ The second, is:
148
148
  commit log.uncommitted ".git/COMMIT_EDITMSG"
149
149
  ----
150
150
 
151
- The above will answer a single commit record. This is great for building a commit object from an unsaved commit message. The only disadvantage of this approach is that you will get template commits which are always stripped out by Git when processing a _saved_ commit.
151
+ The above will answer a single commit record. This is great for building a commit object from an unsaved commit message. The only disadvantage to this approach is you will get template commits which are always stripped out by Git when processing a _saved_ commit.
152
152
 
153
153
  ==== link:https://git-scm.com/docs/git-tag[Tag]
154
154
 
@@ -168,6 +168,9 @@ tag.create "0.0.0", "Version 0.0.0"
168
168
  # Answers true or false base on whether local and remote tag exist.
169
169
  tag.exist? "0.1.0"
170
170
 
171
+ # Answers enhanced tag records. Can take any argument accepted with `--list`.
172
+ tag.index
173
+
171
174
  # Answers last tag for git.
172
175
  tag.last
173
176
 
@@ -197,30 +200,30 @@ An instance of `Gitt::Models::Commit` is what is answered back to when using `Gi
197
200
 
198
201
  [source,ruby]
199
202
  ----
200
- # #<Struct:Gitt::Models::Commit:0x0001d4e8
201
- # author_email = "demo@example.io",
203
+ # #<Struct:Gitt::Models::Commit:0x00015c70
204
+ # author_email = "brooke@alchemists.io",
202
205
  # author_name = "Brooke Kuhlmann",
203
- # authored_at = "1720130186",
204
- # authored_relative_at = "33 seconds ago",
206
+ # authored_at = "1731517717",
207
+ # authored_relative_at = "28 seconds ago",
205
208
  # body = "",
206
209
  # body_lines = [],
207
210
  # body_paragraphs = [],
208
- # committed_at = "1720130186",
209
- # committed_relative_at = "33 seconds ago",
210
- # committer_email = "demo@example.io",
211
+ # committed_at = "1731517717",
212
+ # committed_relative_at = "28 seconds ago",
213
+ # committer_email = "brooke@alchemists.io",
211
214
  # committer_name = "Brooke Kuhlmann",
212
- # deletions = 3,
215
+ # deletions = 11,
213
216
  # encoding = "",
214
- # files_changed = 3,
217
+ # files_changed = 1,
215
218
  # fingerprint = "F2BC49BC4FFB9A48",
216
219
  # fingerprint_key = "D1488588D2DEDF73E62F07A1F2BC49BC4FFB9A48",
217
- # insertions = 9,
220
+ # insertions = 14,
218
221
  # lines = [
219
222
  # "Added version release notes"
220
223
  # ],
221
224
  # notes = "",
222
225
  # raw = "Added version release notes\n",
223
- # sha = "49e033d7020068630fd3823a29c2eb8a1ef01770",
226
+ # sha = "0f1e2387ed89d6dab95af384096c95bc04b28e9b",
224
227
  # signature = "Good",
225
228
  # subject = "Added version release notes",
226
229
  # trailers = []
@@ -241,7 +244,7 @@ You get a {struct_link} with the following attributes:
241
244
  * `committer_email`: Stores the committer email.
242
245
  * `committer_name`: Stores the committer name.
243
246
  * `deletions`: Stores number of deleted lines.
244
- * `encoding`: Stored encoding. Blank if UTF-8 andf filled if otherwise.
247
+ * `encoding`: Stored encoding. Blank if UTF-8 and filled if otherwise.
245
248
  * `files_changed`: Stores number of files changed.
246
249
  * `fingerprint`: Stores the fingerprint used when creating a secure commit.
247
250
  * `fingerprint_key`: Stores the fingerprint key used when creating a secure commit.
@@ -252,7 +255,7 @@ You get a {struct_link} with the following attributes:
252
255
  * `sha`: Stores the commit SHA.
253
256
  * `signature`: Stores the signature type and level of security.
254
257
  * `subject`: Stores the commit subject.
255
- * `trailers`: Stores any commit trailers as an array of `Gitt::Models::Trailer` records.
258
+ * `trailers`: Stores trailers as an array of `Gitt::Models::Trailer` records.
256
259
 
257
260
  ==== Tag
258
261
 
@@ -260,21 +263,22 @@ An instance of `Gitt::Models::Tag` is what is answered back to when using `Gitt`
260
263
 
261
264
  [source,ruby]
262
265
  ----
263
- #<Struct:Gitt::Models::Tag:0x000314c0
264
- author_email = "demo@example.io",
265
- author_name = "Brooke Kuhlmann",
266
- authored_at = "1671892451",
267
- authored_relative_at = "1 year, 6 months ago",
268
- body = "Example.\n\n-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEE0UiFiNLe33PmLweh8rxJvE/Nii2FB9wo6oc\nhVJ+beT6vnmZHKsvrqkpb1BAE10/pS8RkXjjaBmYaUIBYmG6RQ/+yUvyNjldWLuO\nBkYyUawSBT94V/ve/oYxTdylCkWj1TGYG+iP4NNnhz64rMikckY=\n=ptac\n-----END PGP SIGNATURE-----\n",
269
- committed_at = "1671997684",
270
- committed_relative_at = "1 year, 6 months ago",
271
- committer_email = "demo@example.io",
272
- committer_name = "Brooke Kuhlmann",
273
- sha = "662f32b2846c7bd4f153560478f035197f5279d5",
274
- signature = "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEE0UiFiNLe33PmLweh8rxJvE/Nii2FB9wo6oc\nhVJ+beT6vnmZHKsvrqkpb1BAE10/pS8RkXjjaBmYaUIBYmG6RQ/+yUvyNjldWLuO\nBkYyUawSBT94V/ve/oYxTdylCkWj1TGYG+iP4NNnhz64rMikckY=\n=ptac\n-----END PGP SIGNATURE-----\n",
275
- subject = "Version 1.0.0",
276
- version = "1.0.0"
277
- >
266
+ # #<Struct:Gitt::Models::Tag:0x0003a5c0
267
+ # author_email = "brooke@alchemists.io",
268
+ # author_name = "Brooke Kuhlmann",
269
+ # authored_at = "1671892451",
270
+ # authored_relative_at = "1 year, 11 months ago",
271
+ # body = "* Added Dry Monads gem - Brooke Kuhlmann\n\n-----BEGIN PGP SIGNATURE-----\n",
272
+ # committed_at = "1671997684",
273
+ # committed_relative_at = "1 year, 11 months ago",
274
+ # committer_email = "brooke@alchemists.io",
275
+ # committer_name = "Brooke Kuhlmann",
276
+ # sha = "662f32b2846c7bd4f153560478f035197f5279d5",
277
+ # signature = "-----BEGIN PGP SIGNATURE-----\n",
278
+ # subject = "Version 1.0.0",
279
+ # trailers = [],
280
+ # version = "1.0.0"
281
+ # >
278
282
  ----
279
283
 
280
284
  You get a {struct_link} with the following attributes:
@@ -291,6 +295,7 @@ You get a {struct_link} with the following attributes:
291
295
  * `sha`: Stores the commit SHA for which this tag labels
292
296
  * `signature`: Stores the signature when the tag was securely created.
293
297
  * `subject`: Stores the subject.
298
+ * `trailers`: Stores trailers as an array of `Gitt::Models::Trailer` records.
294
299
  * `version`: Stores the version.
295
300
 
296
301
  ==== Trailer
data/gitt.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "gitt"
5
- spec.version = "3.12.0"
5
+ spec.version = "4.0.0"
6
6
  spec.authors = ["Brooke Kuhlmann"]
7
7
  spec.email = ["brooke@alchemists.io"]
8
8
  spec.homepage = "https://alchemists.io/projects/gitt"
@@ -22,10 +22,10 @@ Gem::Specification.new do |spec|
22
22
  spec.signing_key = Gem.default_key_path
23
23
  spec.cert_chain = [Gem.default_cert_path]
24
24
 
25
- spec.required_ruby_version = ">= 3.3", "<= 3.4"
26
- spec.add_dependency "core", "~> 1.10"
25
+ spec.required_ruby_version = "~> 3.4"
26
+ spec.add_dependency "core", "~> 2.0"
27
27
  spec.add_dependency "dry-monads", "~> 1.6"
28
- spec.add_dependency "refinements", "~> 12.10"
28
+ spec.add_dependency "refinements", "~> 13.0"
29
29
  spec.add_dependency "zeitwerk", "~> 2.7"
30
30
 
31
31
  spec.extra_rdoc_files = Dir["README*", "LICENSE*"]
@@ -57,7 +57,7 @@ module Gitt
57
57
 
58
58
  # :reek:FeatureEnvy
59
59
  def process_statistics attributes
60
- attributes.merge! statistic_sanitizer.call(attributes.delete(:statistics))
60
+ attributes.merge! statistics_sanitizer.call(attributes.delete(:statistics))
61
61
  end
62
62
 
63
63
  def lines_sanitizer = sanitizers.fetch :lines
@@ -66,7 +66,7 @@ module Gitt
66
66
 
67
67
  def scissors_sanitizer = sanitizers.fetch :scissors
68
68
 
69
- def statistic_sanitizer = sanitizers.fetch :statistic
69
+ def statistics_sanitizer = sanitizers.fetch :statistics
70
70
 
71
71
  def signature_sanitizer = sanitizers.fetch :signature
72
72
 
@@ -5,12 +5,12 @@ module Gitt
5
5
  # Parses raw trailer data to produce a trailer record.
6
6
  class Trailer
7
7
  PATTERN = /
8
- \A # Start of line.
9
- (?<key>.+) # Key.
10
- (?<delimiter>:) # Colon delimiter.
11
- (?<space>\s?) # Space (optional).
12
- (?<value>.*?) # Value.
13
- \Z # End of line.
8
+ \A # Start of line.
9
+ (?<key>[a-zA-Z\-]+) # Key.
10
+ (?<delimiter>:) # Delimiter (colon).
11
+ (?<space>\s?) # Space (optional).
12
+ (?<value>.*?) # Value.
13
+ \Z # End of line.
14
14
  /x
15
15
 
16
16
  EMPTY = Models::Trailer[key: nil, value: nil]
@@ -24,6 +24,6 @@ RSpec.shared_context "with Git repository" do
24
24
 
25
25
  example.run
26
26
 
27
- temp_dir.remove_tree
27
+ temp_dir.rmtree
28
28
  end
29
29
  end
@@ -1,13 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  RSpec.shared_context "with temporary directory" do
4
- using Refinements::Pathname
5
-
6
4
  let(:temp_dir) { Bundler.root.join "tmp", "rspec" }
7
5
 
8
6
  around do |example|
9
- temp_dir.make_path
7
+ temp_dir.mkpath
10
8
  example.run
11
- temp_dir.remove_tree
9
+ temp_dir.rmtree
12
10
  end
13
11
  end
@@ -9,7 +9,7 @@ module Gitt
9
9
  paragraphs: Paragraphs.new,
10
10
  scissors: Scissors,
11
11
  signature: Signature,
12
- statistic: Statistic.new,
12
+ statistics: Statistics.new,
13
13
  trailers: Trailers.new,
14
14
  version: Version
15
15
  }.freeze
@@ -3,7 +3,7 @@
3
3
  module Gitt
4
4
  module Sanitizers
5
5
  # Converts raw text into a statistics hash.
6
- class Statistic
6
+ class Statistics
7
7
  EMPTY = {files_changed: 0, insertions: 0, deletions: 0}.freeze
8
8
 
9
9
  PATTERN = /
@@ -12,7 +12,7 @@ module Gitt
12
12
  (?<kind>file|insertion|deletion) # Kind capture group.
13
13
  /x
14
14
 
15
- def self.update_stats attributes, kind, total
15
+ def self.update attributes, kind, total
16
16
  case kind
17
17
  when "file" then attributes[:files_changed] = total
18
18
  when "insertion" then attributes[:insertions] = total
@@ -21,22 +21,22 @@ module Gitt
21
21
  end
22
22
  end
23
23
 
24
- def initialize empty: EMPTY, pattern: PATTERN
25
- @empty = empty
24
+ def initialize attributes = EMPTY, pattern: PATTERN
25
+ @attributes = attributes
26
26
  @pattern = pattern
27
27
  end
28
28
 
29
29
  def call text
30
- return empty unless text
30
+ return attributes unless text
31
31
 
32
- text.scan(pattern).each.with_object(empty.dup) do |(number, kind), aggregate|
33
- self.class.update_stats aggregate, kind, number.to_i
32
+ text.scan(pattern).each.with_object(attributes.dup) do |(number, kind), aggregate|
33
+ self.class.update aggregate, kind, number.to_i
34
34
  end
35
35
  end
36
36
 
37
37
  private
38
38
 
39
- attr_reader :empty, :pattern
39
+ attr_reader :attributes, :pattern
40
40
  end
41
41
  end
42
42
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,11 +1,10 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitt
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.12.0
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brooke Kuhlmann
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain:
11
10
  - |
@@ -35,7 +34,7 @@ cert_chain:
35
34
  3n5C8/6Zh9DYTkpcwPSuIfAga6wf4nXc9m6JAw8AuMLaiWN/r/2s4zJsUHYERJEu
36
35
  gZGm4JqtuSg8pYjPeIJxS960owq+SfuC+jxqmRA54BisFCv/0VOJi7tiJVY=
37
36
  -----END CERTIFICATE-----
38
- date: 2024-11-09 00:00:00.000000000 Z
37
+ date: 2024-12-27 00:00:00.000000000 Z
39
38
  dependencies:
40
39
  - !ruby/object:Gem::Dependency
41
40
  name: core
@@ -43,14 +42,14 @@ dependencies:
43
42
  requirements:
44
43
  - - "~>"
45
44
  - !ruby/object:Gem::Version
46
- version: '1.10'
45
+ version: '2.0'
47
46
  type: :runtime
48
47
  prerelease: false
49
48
  version_requirements: !ruby/object:Gem::Requirement
50
49
  requirements:
51
50
  - - "~>"
52
51
  - !ruby/object:Gem::Version
53
- version: '1.10'
52
+ version: '2.0'
54
53
  - !ruby/object:Gem::Dependency
55
54
  name: dry-monads
56
55
  requirement: !ruby/object:Gem::Requirement
@@ -71,14 +70,14 @@ dependencies:
71
70
  requirements:
72
71
  - - "~>"
73
72
  - !ruby/object:Gem::Version
74
- version: '12.10'
73
+ version: '13.0'
75
74
  type: :runtime
76
75
  prerelease: false
77
76
  version_requirements: !ruby/object:Gem::Requirement
78
77
  requirements:
79
78
  - - "~>"
80
79
  - !ruby/object:Gem::Version
81
- version: '12.10'
80
+ version: '13.0'
82
81
  - !ruby/object:Gem::Dependency
83
82
  name: zeitwerk
84
83
  requirement: !ruby/object:Gem::Requirement
@@ -93,7 +92,6 @@ dependencies:
93
92
  - - "~>"
94
93
  - !ruby/object:Gem::Version
95
94
  version: '2.7'
96
- description:
97
95
  email:
98
96
  - brooke@alchemists.io
99
97
  executables: []
@@ -131,7 +129,7 @@ files:
131
129
  - lib/gitt/sanitizers/paragraphs.rb
132
130
  - lib/gitt/sanitizers/scissors.rb
133
131
  - lib/gitt/sanitizers/signature.rb
134
- - lib/gitt/sanitizers/statistic.rb
132
+ - lib/gitt/sanitizers/statistics.rb
135
133
  - lib/gitt/sanitizers/trailers.rb
136
134
  - lib/gitt/sanitizers/version.rb
137
135
  - lib/gitt/shell.rb
@@ -147,16 +145,12 @@ metadata:
147
145
  label: Gitt
148
146
  rubygems_mfa_required: 'true'
149
147
  source_code_uri: https://github.com/bkuhlmann/gitt
150
- post_install_message:
151
148
  rdoc_options: []
152
149
  require_paths:
153
150
  - lib
154
151
  required_ruby_version: !ruby/object:Gem::Requirement
155
152
  requirements:
156
- - - ">="
157
- - !ruby/object:Gem::Version
158
- version: '3.3'
159
- - - "<="
153
+ - - "~>"
160
154
  - !ruby/object:Gem::Version
161
155
  version: '3.4'
162
156
  required_rubygems_version: !ruby/object:Gem::Requirement
@@ -165,8 +159,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
165
159
  - !ruby/object:Gem::Version
166
160
  version: '0'
167
161
  requirements: []
168
- rubygems_version: 3.5.23
169
- signing_key:
162
+ rubygems_version: 3.6.2
170
163
  specification_version: 4
171
164
  summary: A monadic Object API for the Git CLI.
172
165
  test_files: []
metadata.gz.sig CHANGED
Binary file