git 2.3.0 → 2.3.2

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: 1e24e434e4639e6c31133234cee6d96708baf23d212c2f78cf4b94159810b090
4
- data.tar.gz: 9fc37b011ac0cb0e87a0ee50b7993e751a7075a7496d6feb41431d2f3612e823
3
+ metadata.gz: f4c3080ee5b1fd4b591abe1e3e94917ea4307c97a3cf75f93cbc910e5320142b
4
+ data.tar.gz: 1b5a4682825b282577918929d21967846191fdcf16a8dc3c72de71820fee74f9
5
5
  SHA512:
6
- metadata.gz: 232624614200233e3f2ed308a4e73580345fef5be0a98e64f35992ecb222fa96c4163399b2f08afbfcdf69cd3b2f8f6c57c309fe9122f18a56e9bc31f827b301
7
- data.tar.gz: 4ae699244e5ff9f679795279b8dbfeebe35ce8c9bfb7e5d9a18552b77b3d86b630f50bd9fedb4eec4f697269cfec6c90f72adfa2edeada25258ab457f3b5dad8
6
+ metadata.gz: 57434c5742779e9769f3a6ce85a5b25c5f3c4e5974427965bca0df4922a266ffb3225839ccf2964f2391d5b8c7eda68de4aa1d46bbbd264b6d5c53a2c7852f77
7
+ data.tar.gz: 6c1a1bc6010f883eb8b0d4ccd677a5f46c98db9f3f9e582b8c06f6b4294903c1949fe288fe2ae2c17c41ae9e5319fdc9fc64870e5f3f1219b03351a22f475d4c
data/CHANGELOG.md CHANGED
@@ -5,6 +5,28 @@
5
5
 
6
6
  # Change Log
7
7
 
8
+ ## v2.3.2 (2024-11-19)
9
+
10
+ [Full Changelog](https://github.com/ruby-git/ruby-git/compare/v2.3.1..v2.3.2)
11
+
12
+ Changes since v2.3.1:
13
+
14
+ * 7646e38 fix: improve error message for Git::Lib#branches_all
15
+
16
+ ## v2.3.1 (2024-10-23)
17
+
18
+ [Full Changelog](https://github.com/ruby-git/ruby-git/compare/v2.3.0..v2.3.1)
19
+
20
+ Changes since v2.3.0:
21
+
22
+ * e236007 test: allow bin/test-in-docker to accept the test file(s) to run on command line
23
+ * f4747e1 test: rename bin/tests to bin/test-in-docker
24
+ * 51f781c test: remove duplicate test from test_stashes.rb
25
+ * 2e79dbe Fixed "unbranched" stash message support:
26
+ * da6fa6e Conatinerised the test suite with Docker:
27
+ * 2e23d47 Update instructions for building a specific version of Git
28
+ * 70565e3 Add Git.binary_version to return the version of the git command line
29
+
8
30
  ## v2.3.0 (2024-09-01)
9
31
 
10
32
  [Full Changelog](https://github.com/ruby-git/ruby-git/compare/v2.2.0..v2.3.0)
data/CONTRIBUTING.md CHANGED
@@ -3,6 +3,9 @@
3
3
  # @title How To Contribute
4
4
  -->
5
5
 
6
+ # Contributing to the git gem
7
+
8
+ * [Summary](#summary)
6
9
  * [How to contribute](#how-to-contribute)
7
10
  * [How to report an issue or request a feature](#how-to-report-an-issue-or-request-a-feature)
8
11
  * [How to submit a code or documentation change](#how-to-submit-a-code-or-documentation-change)
@@ -18,10 +21,14 @@
18
21
  * [Unit tests](#unit-tests)
19
22
  * [Continuous integration](#continuous-integration)
20
23
  * [Documentation](#documentation)
24
+ * [Building a specific version of the Git command-line](#building-a-specific-version-of-the-git-command-line)
25
+ * [Install pre-requisites](#install-pre-requisites)
26
+ * [Obtain Git source code](#obtain-git-source-code)
27
+ * [Build git](#build-git)
28
+ * [Use the new Git version](#use-the-new-git-version)
21
29
  * [Licensing](#licensing)
22
30
 
23
-
24
- # Contributing to the git gem
31
+ ## Summary
25
32
 
26
33
  Thank you for your interest in contributing to the `ruby-git` project.
27
34
 
@@ -172,22 +179,100 @@ $ bin/test test_object test_archive
172
179
 
173
180
  # run all unit tests:
174
181
  $ bin/test
182
+
183
+ # run unit tests with a different version of the git command line:
184
+ $ GIT_PATH=/Users/james/Downloads/git-2.30.2/bin-wrappers bin/test
175
185
  ```
176
186
 
177
187
  ### Continuous integration
178
188
 
179
- All tests must pass in the project's [GitHub Continuous Integration build](https://github.com/ruby-git/ruby-git/actions?query=workflow%3ACI) before the pull request will be merged.
189
+ All tests must pass in the project's [GitHub Continuous Integration
190
+ build](https://github.com/ruby-git/ruby-git/actions?query=workflow%3ACI) before the
191
+ pull request will be merged.
180
192
 
181
- The [Continuous Integration workflow](https://github.com/ruby-git/ruby-git/blob/master/.github/workflows/continuous_integration.yml) runs both `bundle exec rake default` and `bundle exec rake test:gem` from the project's [Rakefile](https://github.com/ruby-git/ruby-git/blob/master/Rakefile).
193
+ The [Continuous Integration
194
+ workflow](https://github.com/ruby-git/ruby-git/blob/master/.github/workflows/continuous_integration.yml)
195
+ runs both `bundle exec rake default` and `bundle exec rake test:gem` from the
196
+ project's [Rakefile](https://github.com/ruby-git/ruby-git/blob/master/Rakefile).
182
197
 
183
198
  ### Documentation
184
199
 
185
- New and updated public methods must include [YARD](https://yardoc.org/) documentation.
200
+ New and updated public methods must include [YARD](https://yardoc.org/)
201
+ documentation.
202
+
203
+ New and updated public-facing features should be documented in the project's
204
+ [README.md](README.md).
205
+
206
+ ## Building a specific version of the Git command-line
207
+
208
+ To test with a specific version of the Git command-line, you may need to build that
209
+ version from source code. The following instructions are adapted from Atlassian’s
210
+ [How to install Git](https://www.atlassian.com/git/tutorials/install-git) page for
211
+ building Git on macOS.
212
+
213
+ ### Install pre-requisites
214
+
215
+ Prerequisites only need to be installed if they are not already present.
216
+
217
+ From your terminal, install Xcode’s Command Line Tools:
218
+
219
+ ```shell
220
+ xcode-select --install
221
+ ```
222
+
223
+ Install [Homebrew](http://brew.sh/) by following the instructions on the Homebrew
224
+ page.
225
+
226
+ Using Homebrew, install OpenSSL:
227
+
228
+ ```shell
229
+ brew install openssl
230
+ ```
231
+
232
+ ### Obtain Git source code
233
+
234
+ Download and extract the source tarball for the desired Git version from [this source
235
+ code mirror](https://mirrors.edge.kernel.org/pub/software/scm/git/).
236
+
237
+ ### Build git
238
+
239
+ From your terminal, change to the root directory of the extracted source code and run
240
+ the build with following command:
241
+
242
+ ```shell
243
+ NO_GETTEXT=1 make CFLAGS="-I/usr/local/opt/openssl/include" LDFLAGS="-L/usr/local/opt/openssl/lib"
244
+ ```
245
+
246
+ The build script will place the newly compiled Git executables in the `bin-wrappers`
247
+ directory (e.g., `bin-wrappers/git`).
248
+
249
+ ### Use the new Git version
250
+
251
+ To configure programs that use the Git gem to utilize the newly built version, do the
252
+ following:
253
+
254
+ ```ruby
255
+ require 'git'
256
+
257
+ # Set the binary path
258
+ Git.configure { |c| c.binary_path = '/Users/james/Downloads/git-2.30.2/bin-wrappers/git' }
259
+
260
+ # Validate the version (if desired)
261
+ assert_equal([2, 30, 2], Git.binary_version)
262
+ ```
263
+
264
+ Tests can be run using the newly built Git version as follows:
265
+
266
+ ```shell
267
+ GIT_PATH=/Users/james/Downloads/git-2.30.2/bin-wrappers bin/test
268
+ ```
186
269
 
187
- New and updated public-facing features should be documented in the project's [README.md](README.md).
270
+ Note: `GIT_PATH` refers to the directory containing the `git` executable.
188
271
 
189
272
  ## Licensing
190
273
 
191
- `ruby-git` uses [the MIT license](https://choosealicense.com/licenses/mit/) as declared in the [LICENSE](LICENSE) file.
274
+ `ruby-git` uses [the MIT license](https://choosealicense.com/licenses/mit/) as
275
+ declared in the [LICENSE](LICENSE) file.
192
276
 
193
- Licensing is critical to open-source projects as it ensures the software remains available under the terms desired by the author.
277
+ Licensing is critical to open-source projects as it ensures the software remains
278
+ available under the terms desired by the author.
data/lib/git/base.rb CHANGED
@@ -36,6 +36,20 @@ module Git
36
36
  @@config ||= Config.new
37
37
  end
38
38
 
39
+ def self.binary_version(binary_path)
40
+ git_cmd = "#{binary_path} -c core.quotePath=true -c color.ui=false version 2>&1"
41
+ result, status = Open3.capture2(git_cmd)
42
+ result = result.chomp
43
+
44
+ if status.success?
45
+ version = result[/\d+(\.\d+)+/]
46
+ version_parts = version.split('.').collect { |i| i.to_i }
47
+ version_parts.fill(0, version_parts.length...3)
48
+ else
49
+ raise RuntimeError, "Failed to get git version: #{status}\n#{result}"
50
+ end
51
+ end
52
+
39
53
  # (see Git.init)
40
54
  def self.init(directory = '.', options = {})
41
55
  normalize_paths(options, default_working_directory: directory, default_repository: directory, bare: options[:bare])
data/lib/git/lib.rb CHANGED
@@ -362,7 +362,7 @@ module Git
362
362
  #
363
363
  # @example Get the contents of a file with a block
364
364
  # lib.cat_file_contents('README.md') { |f| f.read } # => "This is a README file\n"
365
- #
365
+ #
366
366
  # @param object [String] the object whose contents to return
367
367
  #
368
368
  # @return [String] the object contents
@@ -641,10 +641,13 @@ module Git
641
641
  /x
642
642
 
643
643
  def branches_all
644
- command_lines('branch', '-a').map do |line|
644
+ lines = command_lines('branch', '-a')
645
+ lines.each_with_index.map do |line, line_index|
645
646
  match_data = line.match(BRANCH_LINE_REGEXP)
646
- raise Git::UnexpectedResultError, 'Unexpected branch line format' unless match_data
647
+
648
+ raise Git::UnexpectedResultError, unexpected_branch_line_error(lines, line, line_index) unless match_data
647
649
  next nil if match_data[:not_a_branch] || match_data[:detached_ref]
650
+
648
651
  [
649
652
  match_data[:refname],
650
653
  !match_data[:current].nil?,
@@ -654,6 +657,18 @@ module Git
654
657
  end.compact
655
658
  end
656
659
 
660
+ def unexpected_branch_line_error(lines, line, index)
661
+ <<~ERROR
662
+ Unexpected line in output from `git branch -a`, line #{index + 1}
663
+
664
+ Full output:
665
+ #{lines.join("\n ")}
666
+
667
+ Line #{index + 1}:
668
+ "#{line}"
669
+ ERROR
670
+ end
671
+
657
672
  def worktrees_all
658
673
  arr = []
659
674
  directory = ''
@@ -1134,8 +1149,10 @@ module Git
1134
1149
  if File.exist?(filename)
1135
1150
  File.open(filename) do |f|
1136
1151
  f.each_with_index do |line, i|
1137
- m = line.match(/:(.*)$/)
1138
- arr << [i, m[1].strip]
1152
+ _, msg = line.split("\t")
1153
+ # NOTE this logic may be removed/changed in 3.x
1154
+ m = msg.match(/^[^:]+:(.*)$/)
1155
+ arr << [i, (m ? m[1] : msg).strip]
1139
1156
  end
1140
1157
  end
1141
1158
  end
data/lib/git/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Git
2
2
  # The current gem version
3
3
  # @return [String] the current gem version.
4
- VERSION='2.3.0'
4
+ VERSION='2.3.2'
5
5
  end
data/lib/git.rb CHANGED
@@ -381,4 +381,15 @@ module Git
381
381
  def self.open(working_dir, options = {})
382
382
  Base.open(working_dir, options)
383
383
  end
384
+
385
+ # Return the version of the git binary
386
+ #
387
+ # @example
388
+ # Git.binary_version # => [2, 46, 0]
389
+ #
390
+ # @return [Array<Integer>] the version of the git binary
391
+ #
392
+ def self.binary_version(binary_path = Git::Base.config.binary_path)
393
+ Base.binary_version(binary_path)
394
+ end
384
395
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.0
4
+ version: 2.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott Chacon and others
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-09-01 00:00:00.000000000 Z
11
+ date: 2024-11-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -243,8 +243,8 @@ licenses:
243
243
  metadata:
244
244
  homepage_uri: http://github.com/ruby-git/ruby-git
245
245
  source_code_uri: http://github.com/ruby-git/ruby-git
246
- changelog_uri: https://rubydoc.info/gems/git/2.3.0/file/CHANGELOG.md
247
- documentation_uri: https://rubydoc.info/gems/git/2.3.0
246
+ changelog_uri: https://rubydoc.info/gems/git/2.3.2/file/CHANGELOG.md
247
+ documentation_uri: https://rubydoc.info/gems/git/2.3.2
248
248
  post_install_message:
249
249
  rdoc_options: []
250
250
  require_paths:
@@ -261,7 +261,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
261
261
  version: '0'
262
262
  requirements:
263
263
  - git 2.28.0 or greater
264
- rubygems_version: 3.5.9
264
+ rubygems_version: 3.5.22
265
265
  signing_key:
266
266
  specification_version: 4
267
267
  summary: An API to create, read, and manipulate Git repositories