ruby_git 0.3.1 → 0.3.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b12470df80fc020031e73898e6332def5b5d6e7c419acb3036a58585263269b7
4
- data.tar.gz: d1138d2381fc7272397357105b8e884a78bed2396289608df6dc746896018b4b
3
+ metadata.gz: 49c6945719de157cce37ff7fc1db26942f2e72cd52af4705d24dbf77f7417c3f
4
+ data.tar.gz: cf947e2e02562cc8815f074c1e60cabefa2bfa4904a010203f836c6f28c84fb8
5
5
  SHA512:
6
- metadata.gz: f1cbdfcdea413421d06bf15ad2c205866dff32a1b92ffea0b260dbecf31fe62313fb6b355ae81fff9cb0f07fab26af622c90eeb28c1b1e28c63c27a02223e499
7
- data.tar.gz: e51b5c257998f8a2c9cad6927bfd1b32d4f397c793b82edd6017a00b4581b9b6f6f00623f05ec9d2052b42a72c62fabc94268bb4caa6b1d6b408a3b2d5041f46
6
+ metadata.gz: 8886578e9cd719cfb9495bcf557216ad57632b39ced741d6e88caab28e59c65ad5c2b9b3d03933ef7b43f5b5e8da66ee0222f54f0c39c4b4cedb6f26597d4f8d
7
+ data.tar.gz: b9ad7a689dd88b0f705880df7bd7b0abdf9dd472c0be9750f207918cf988b6d445f4b5e0c0e71204cfd220cb05444700c36bd59aefc5b43f82e20ec74d4b0a44
@@ -1,9 +1,6 @@
1
1
  name: Continuous Integration
2
2
 
3
3
  on:
4
- push:
5
- branches: [main]
6
-
7
4
  pull_request:
8
5
  branches: [main]
9
6
 
@@ -26,6 +23,10 @@ jobs:
26
23
  build:
27
24
  name: Ruby ${{ matrix.ruby }} on ${{ matrix.operating-system }}
28
25
 
26
+ if: >-
27
+ github.event_name == 'workflow_dispatch' ||
28
+ (github.event_name == 'pull_request' && !startsWith(github.event.pull_request.head.ref, 'release-please--'))
29
+
29
30
  runs-on: ${{ matrix.operating-system }}
30
31
  continue-on-error: true
31
32
 
@@ -35,19 +36,9 @@ jobs:
35
36
  strategy:
36
37
  fail-fast: false
37
38
  matrix:
38
- ruby: ["3.1", "3.2", "3.3", "3.4"]
39
+ ruby: ["3.1", "3.4"]
39
40
  operating-system: [ubuntu-latest]
40
41
  fail_on_low_coverage: [true]
41
- include:
42
- - ruby: "3.1"
43
- operating-system: windows-latest
44
- fail_on_low_coverage: false
45
- - ruby: "jruby-9.4"
46
- operating-system: ubuntu-latest
47
- fail_on_low_coverage: false
48
- - ruby: "truffleruby-24"
49
- operating-system: ubuntu-latest
50
- fail_on_low_coverage: false
51
42
 
52
43
  steps:
53
44
  - name: Checkout
@@ -61,27 +52,3 @@ jobs:
61
52
 
62
53
  - name: Run rake
63
54
  run: bundle exec rake
64
-
65
- coverage:
66
- name: Report test coverage to CodeClimate
67
-
68
- needs: [build]
69
- runs-on: ubuntu-latest
70
-
71
- steps:
72
- - name: Checkout
73
- uses: actions/checkout@v4
74
-
75
- - name: Initialize Ruby
76
- uses: ruby/setup-ruby@v1
77
- with:
78
- ruby-version: 3.1
79
- bundler-cache: true
80
-
81
- - name: Report test coverage
82
- uses: paambaati/codeclimate-action@v9
83
- env:
84
- CC_TEST_REPORTER_ID: b86e77bc6980a43dc09314502fe13334e0f663770b840628ca0716e6dcdeeb5d
85
- with:
86
- coverageCommand: bundle exec rake spec
87
- coverageLocations: ${{github.workspace}}/coverage/lcov/*.lcov:lcov
@@ -9,6 +9,10 @@ jobs:
9
9
  commit-lint:
10
10
  name: Verify Conventional Commits
11
11
 
12
+ if: >-
13
+ github.event_name == 'workflow_dispatch' ||
14
+ (github.event_name == 'pull_request' && !startsWith(github.event.pull_request.head.ref, 'release-please--'))
15
+
12
16
  runs-on: ubuntu-latest
13
17
 
14
18
  steps:
@@ -1,9 +1,6 @@
1
1
  name: Experimental Ruby Builds
2
2
 
3
3
  on:
4
- push:
5
- branches: [main]
6
-
7
4
  workflow_dispatch:
8
5
 
9
6
  env:
@@ -34,19 +31,28 @@ jobs:
34
31
  matrix:
35
32
  fail_on_low_coverage: [true]
36
33
  include:
34
+ - ruby: "3.1"
35
+ operating-system: windows-latest
36
+ fail_on_low_coverage: false
37
37
  - ruby: head
38
38
  operating-system: ubuntu-latest
39
39
  - ruby: head
40
40
  operating-system: windows-latest
41
+ - ruby: "truffleruby-24"
42
+ operating-system: ubuntu-latest
43
+ fail_on_low_coverage: false
41
44
  - ruby: truffleruby-head
42
45
  operating-system: ubuntu-latest
43
46
  fail_on_low_coverage: false
44
- - ruby: jruby-head
47
+ - ruby: "jruby-9.4"
45
48
  operating-system: ubuntu-latest
46
49
  fail_on_low_coverage: false
47
50
  - ruby: "jruby-9.4"
48
51
  operating-system: windows-latest
49
52
  fail_on_low_coverage: false
53
+ - ruby: jruby-head
54
+ operating-system: ubuntu-latest
55
+ fail_on_low_coverage: false
50
56
  - ruby: jruby-head
51
57
  operating-system: windows-latest
52
58
  fail_on_low_coverage: false
@@ -0,0 +1,51 @@
1
+ ---
2
+ name: Release Gem
3
+ description: |
4
+ This workflow creates a new release on GitHub and publishes the gem to
5
+ RubyGems.org.
6
+
7
+ The workflow uses the `googleapis/release-please-action` to handle the
8
+ release creation process and the `rubygems/release-gem` action to publish
9
+ the gem.
10
+
11
+ on:
12
+ push:
13
+ branches: ["main"]
14
+
15
+ workflow_dispatch:
16
+
17
+ jobs:
18
+ release:
19
+ runs-on: ubuntu-latest
20
+
21
+ environment:
22
+ name: RubyGems
23
+ url: https://rubygems.org/gems/ruby_git
24
+
25
+ permissions:
26
+ contents: write
27
+ pull-requests: write
28
+ id-token: write
29
+
30
+ steps:
31
+ - name: Checkout project
32
+ uses: actions/checkout@v4
33
+
34
+ - name: Create release
35
+ uses: googleapis/release-please-action@v4
36
+ id: release
37
+ with:
38
+ token: ${{ secrets.AUTO_RELEASE_TOKEN }}
39
+ config-file: release-please-config.json
40
+ manifest-file: .release-please-manifest.json
41
+
42
+ - name: Setup ruby
43
+ uses: ruby/setup-ruby@v1
44
+ if: ${{ steps.release.outputs.release_created }}
45
+ with:
46
+ bundler-cache: true
47
+ ruby-version: ruby
48
+
49
+ - name: Push to RubyGems.org
50
+ uses: rubygems/release-gem@v1
51
+ if: ${{ steps.release.outputs.release_created }}
@@ -0,0 +1,3 @@
1
+ {
2
+ ".": "0.3.3"
3
+ }
data/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # Change Log
2
2
 
3
+ ## [0.3.3](https://github.com/main-branch/ruby_git/compare/v0.3.2...v0.3.3) (2025-04-17)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * Do not trigger build workflows after merging to main or for release PRs ([0678dd3](https://github.com/main-branch/ruby_git/commit/0678dd347235aaa9f55d84853de94d01935f974d))
9
+ * Move unneeded builds from continuous_integration to experimental_ruby_builds ([2d15e1c](https://github.com/main-branch/ruby_git/commit/2d15e1c7aef848e4d3cc857e6f606a0f68d7bf6f))
10
+
11
+ ## [0.3.2](https://github.com/main-branch/ruby_git/compare/v0.3.1...v0.3.2) (2025-04-16)
12
+
13
+
14
+ ### Bug Fixes
15
+
16
+ * Automate commit-to-publish workflow ([9850fed](https://github.com/main-branch/ruby_git/commit/9850fed2230f154eaf6319644d0e6b40c5352e7f))
17
+
3
18
  ## v0.3.1 (2025-03-28)
4
19
 
5
20
  [Full Changelog](https://github.com/main-branch/ruby_git/compare/v0.3.0..v0.3.1)
data/README.md CHANGED
@@ -7,8 +7,6 @@ and the order of implementing new features.
7
7
  [![Build Status](https://github.com/main-branch/ruby_git/actions/workflows/continuous_integration.yml/badge.svg)](https://github.com/main-branch/ruby_git/actions/workflows/continuous_integration.yml)
8
8
  [![Documentation](https://img.shields.io/badge/Documentation-Latest-green)](https://rubydoc.info/gems/ruby_git/)
9
9
  [![Change Log](https://img.shields.io/badge/CHANGELOG-Latest-green)](https://rubydoc.info/gems/ruby_git/file/CHANGELOG.md)
10
- [![Maintainability](https://api.codeclimate.com/v1/badges/5403e4613b7518f70da7/maintainability)](https://codeclimate.com/github/main-branch/ruby_git/maintainability)
11
- [![Test Coverage](https://api.codeclimate.com/v1/badges/5403e4613b7518f70da7/test_coverage)](https://codeclimate.com/github/main-branch/ruby_git/test_coverage)
12
10
  [![Slack](https://img.shields.io/badge/slack-main--branch/ruby__git-yellow.svg?logo=slack)](https://main-branch.slack.com/archives/C01CHR7TMM2)
13
11
 
14
12
  Git Is Hard™ but it doesn't have to be that way. Git has this reputation because it has an
data/Rakefile CHANGED
@@ -17,6 +17,13 @@ Bundler::Audit::Task.new
17
17
  require 'bundler'
18
18
  require 'bundler/gem_tasks'
19
19
 
20
+ # Make it so that calling `rake release` just calls `rake release:rubygems_push` to
21
+ # avoid creating and pushing a new tag.
22
+
23
+ Rake::Task['release'].clear
24
+ desc 'Customized release task to avoid creating a new tag'
25
+ task release: 'release:rubygem_push'
26
+
20
27
  # RSpec
21
28
 
22
29
  require 'rspec/core/rake_task'
@@ -26,8 +26,36 @@ module RubyGit
26
26
  #
27
27
  # @param [String] repository_path the path to the repository
28
28
  #
29
+ # The purpose of this flag is to allow tests to not have to mock the
30
+ # normalization of the path. This allows testing that the right git command
31
+ # is contructed based on the options passed any particular method.
32
+ #
33
+ # @raise [ArgumentError] if the path is not a directory
34
+ #
29
35
  def initialize(repository_path)
30
- @path = File.realpath(repository_path)
36
+ @path = normalize_path(repository_path)
37
+ end
38
+
39
+ private
40
+
41
+ # Expand and convert the given path to an absolute, real path
42
+ #
43
+ # @example Expand the path
44
+ # normalize_path('~/repository.git') #=> '/Users/james/repository.git'
45
+ #
46
+ # @example Convert to an absolute path
47
+ # File.chdir('/User/james/repository/.git')
48
+ # normalize_path('.') #=> '/User/james/repository/.git'
49
+ #
50
+ # @param path [String] the path to normalize
51
+ #
52
+ # @return [String]
53
+ #
54
+ # @api private
55
+ def normalize_path(path)
56
+ raise ArgumentError, "Directory '#{path}' does not exist." unless File.directory?(path)
57
+
58
+ File.realpath(File.expand_path(path))
31
59
  end
32
60
  end
33
61
  end
@@ -3,5 +3,5 @@
3
3
  module RubyGit
4
4
  # The ruby_git gem version
5
5
  #
6
- VERSION = '0.3.1'
6
+ VERSION = '0.3.3'
7
7
  end
@@ -105,17 +105,6 @@ module RubyGit
105
105
  new(cloned_to(clone_output))
106
106
  end
107
107
 
108
- # Get path of the cloned worktree from `git clone` stderr output
109
- #
110
- # @param clone_output [String] the stderr output of the `git clone` command
111
- #
112
- # @return [String] the path of the cloned worktree
113
- #
114
- # @api private
115
- def self.cloned_to(clone_output)
116
- clone_output.match(/Cloning into ['"](.+)['"]\.\.\./)[1]
117
- end
118
-
119
108
  # Show the working tree and index status
120
109
  #
121
110
  # @example worktree = Worktree.open(worktree_path) worktree.status #=>
@@ -154,7 +143,7 @@ module RubyGit
154
143
  command << '--' unless path_specs.empty?
155
144
  command.concat(path_specs)
156
145
  options = { out: StringIO.new, err: StringIO.new }
157
- status_output = run(*command, **options).stdout
146
+ status_output = run_with_context(*command, **options).stdout
158
147
  RubyGit::Status.parse(status_output)
159
148
  end
160
149
 
@@ -194,7 +183,7 @@ module RubyGit
194
183
 
195
184
  options = { out: StringIO.new, err: StringIO.new }
196
185
 
197
- run(*command, **options)
186
+ run_with_context(*command, **options)
198
187
  end
199
188
 
200
189
  # Return the repository associated with the worktree
@@ -206,42 +195,95 @@ module RubyGit
206
195
  # @return [RubyGit::Repository] the repository associated with the worktree
207
196
  #
208
197
  def repository
209
- @repository ||= begin
210
- command = %w[rev-parse --git-dir]
211
- options = { chdir: path, chomp: true, out: StringIO.new, err: StringIO.new }
212
- # rev-parse path might be relative to the worktree, thus the need to expand it
213
- git_dir = File.realpath(RubyGit::CommandLine.run(*command, **options).stdout, path)
214
- Repository.new(git_dir)
215
- end
198
+ @repository ||= Repository.new(repository_path)
216
199
  end
217
200
 
218
201
  private
219
202
 
203
+ # The path to the repository associated with this worktree
204
+ #
205
+ # @return [String]
206
+ #
207
+ # @api private
208
+ #
209
+ def repository_path
210
+ command = %w[rev-parse --git-dir]
211
+ options = { chdir: path, chomp: true, out: StringIO.new, err: StringIO.new }
212
+ # rev-parse path might be relative to the worktree, thus the need to expand it
213
+ File.realpath(RubyGit::CommandLine.run(*command, **options).stdout, path)
214
+ end
215
+
220
216
  # Create a Worktree object
221
217
  #
222
218
  # @param worktree_path [String] a path anywhere in the worktree
223
219
  #
220
+ # The purpose of this flag is to allow tests to not have to mock the
221
+ # normalization of the path. This allows testing that the right git command
222
+ # is contructed based on the options passed any particular method.
223
+ #
224
+ # @raise [ArgumentError] if the path is not a directory or the path is not in a
225
+ # git working tree
226
+ #
227
+ # @return [RubyGit::Worktree] the worktree whose root is at `path`
224
228
  # @api private
225
229
  #
226
230
  def initialize(worktree_path)
227
- raise RubyGit::Error, "Path '#{worktree_path}' not valid." unless File.directory?(worktree_path)
228
-
229
- @path = root_path(worktree_path)
231
+ @path = normalize_path(worktree_path)
230
232
  RubyGit.logger.debug("Created #{inspect}")
231
233
  end
232
234
 
233
- # Find the root path of a Git working tree containing `path`
235
+ # Get path of the cloned worktree from `git clone` stderr output
234
236
  #
235
- # @raise [RubyGit::FailedError] if the path is not in a Git working tree
237
+ # @param clone_output [String] the stderr output of the `git clone` command
238
+ #
239
+ # @return [String] the path of the cloned worktree
240
+ #
241
+ # @api private
242
+ private_class_method def self.cloned_to(clone_output)
243
+ clone_output.match(/Cloning into ['"](.+)['"]\.\.\./)[1]
244
+ end
245
+
246
+ # Return the absolute path to the root of the working tree containing path
247
+ #
248
+ # @example Expand the path
249
+ # normalize_path('~/worktree') #=> '/Users/james/worktree'
250
+ #
251
+ # @example Convert to an absolute path
252
+ # File.chdir('/User/james/worktree')
253
+ # normalize_path('.') #=> '/User/james/worktree'
254
+ #
255
+ # @param path [String] a (possibly relative) path within the worktree
256
+ #
257
+ # @return [String]
258
+ #
259
+ # @raise [ArgumentError] if the path is not a directory or the path is not in a
260
+ # git working tree
261
+ #
262
+ # @api private
263
+ #
264
+ def normalize_path(path)
265
+ raise ArgumentError, "Directory '#{path}' does not exist." unless File.directory?(path)
266
+
267
+ begin
268
+ root_path(path)
269
+ rescue RubyGit::FailedError => e
270
+ raise ArgumentError, e.message
271
+ end
272
+ end
273
+
274
+ # Find the root path of a Git working tree containing `path`
236
275
  #
237
276
  # @return [String] the root path of the Git working tree containing `path`
238
277
  #
278
+ # @raise [ArgumentError] if the path is not in a Git working tree
279
+ #
239
280
  # @api private
240
281
  #
241
282
  def root_path(worktree_path)
242
283
  command = %w[rev-parse --show-toplevel]
243
284
  options = { chdir: worktree_path, chomp: true, out: StringIO.new, err: StringIO.new }
244
- File.realpath(RubyGit::CommandLine.run(*command, **options).stdout)
285
+ root_path = RubyGit::CommandLine.run(*command, **options).stdout
286
+ File.realpath(File.expand_path(root_path))
245
287
  end
246
288
 
247
289
  # Run a Git command in this worktree
@@ -255,7 +297,7 @@ module RubyGit
255
297
  #
256
298
  # @api private
257
299
  #
258
- def run(*command, **options)
300
+ def run_with_context(*command, **options)
259
301
  RubyGit::CommandLine.run(*command, repository_path: repository.path, worktree_path: path, **options)
260
302
  end
261
303
 
@@ -0,0 +1,22 @@
1
+ {
2
+ "bootstrap-sha": "b03a7aebb563e4a25eca7f664dd39c7a0595eb61",
3
+ "packages": {
4
+ ".": {
5
+ "release-type": "ruby",
6
+ "package-name": "ruby_git",
7
+ "changelog-path": "CHANGELOG.md",
8
+ "version-file": "lib/ruby_git/version.rb",
9
+ "bump-minor-pre-major": true,
10
+ "bump-patch-for-minor-pre-major": true,
11
+ "draft": false,
12
+ "prerelease": false,
13
+ "include-component-in-tag": false
14
+ }
15
+ },
16
+ "plugins": [
17
+ {
18
+ "type": "sentence-case"
19
+ }
20
+ ],
21
+ "$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json"
22
+ }
data/ruby_git.gemspec CHANGED
@@ -56,7 +56,7 @@ Gem::Specification.new do |spec|
56
56
  spec.add_development_dependency 'yardstick', '~> 0.9'
57
57
  end
58
58
 
59
- spec.add_dependency 'process_executer', '~> 3.0'
59
+ spec.add_dependency 'process_executer', '~> 3.2'
60
60
  spec.add_dependency 'rchardet', '~> 1.9'
61
61
 
62
62
  spec.metadata['rubygems_mfa_required'] = 'true'
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_git
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Couball
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-03-28 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: bundler-audit
@@ -203,14 +203,14 @@ dependencies:
203
203
  requirements:
204
204
  - - "~>"
205
205
  - !ruby/object:Gem::Version
206
- version: '3.0'
206
+ version: '3.2'
207
207
  type: :runtime
208
208
  prerelease: false
209
209
  version_requirements: !ruby/object:Gem::Requirement
210
210
  requirements:
211
211
  - - "~>"
212
212
  - !ruby/object:Gem::Version
213
- version: '3.0'
213
+ version: '3.2'
214
214
  - !ruby/object:Gem::Dependency
215
215
  name: rchardet
216
216
  requirement: !ruby/object:Gem::Requirement
@@ -241,9 +241,11 @@ files:
241
241
  - ".github/workflows/continuous_integration.yml"
242
242
  - ".github/workflows/enforce_conventional_commits.yml"
243
243
  - ".github/workflows/experimental_ruby_builds.yml"
244
+ - ".github/workflows/release.yml"
244
245
  - ".gitignore"
245
246
  - ".husky/commit-msg"
246
247
  - ".markdownlint.yml"
248
+ - ".release-please-manifest.json"
247
249
  - ".rspec"
248
250
  - ".rubocop.yml"
249
251
  - ".yardopts"
@@ -283,6 +285,7 @@ files:
283
285
  - lib/ruby_git/worktree.rb
284
286
  - package.json
285
287
  - pre-commit
288
+ - release-please-config.json
286
289
  - ruby_git.gemspec
287
290
  homepage: https://github.com/main-branch/ruby_git
288
291
  licenses:
@@ -291,8 +294,8 @@ metadata:
291
294
  allowed_push_host: https://rubygems.org
292
295
  homepage_uri: https://github.com/main-branch/ruby_git
293
296
  source_code_uri: https://github.com/main-branch/ruby_git
294
- documentation_uri: https://rubydoc.info/gems/ruby_git/0.3.1
295
- changelog_uri: https://rubydoc.info/gems/ruby_git/0.3.1/file/CHANGELOG.md
297
+ documentation_uri: https://rubydoc.info/gems/ruby_git/0.3.3
298
+ changelog_uri: https://rubydoc.info/gems/ruby_git/0.3.3/file/CHANGELOG.md
296
299
  rubygems_mfa_required: 'true'
297
300
  rdoc_options: []
298
301
  require_paths:
@@ -311,7 +314,7 @@ requirements:
311
314
  - 'Platform: Mac, Linux, or Windows'
312
315
  - 'Ruby: MRI 3.1 or later, TruffleRuby 24 or later, or JRuby 9.4 or later'
313
316
  - Git 2.28.0 or later
314
- rubygems_version: 3.6.2
317
+ rubygems_version: 3.6.7
315
318
  specification_version: 4
316
319
  summary: An object-oriented interface to working with the git command line
317
320
  test_files: []