git 1.19.1 → 2.0.0.pre2

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: 6f12803468275850ae680a4df2719890e8f84de95258f30dc898f817c7155d44
4
- data.tar.gz: d24540a708538775d2ff1af495f04e7f42a297aaf790d0fe7b65ad71fe402550
3
+ metadata.gz: 23b5fa33a9a0cb112334c8b243abd6b388984d5f63aa2ee57f83e67d66e68f4b
4
+ data.tar.gz: 292e0d1c9aa4ce4671206abcdb1a547ab606090ecd7b8f2d182def4721347c03
5
5
  SHA512:
6
- metadata.gz: 15a09f75d84fb1ff7547403eb36c7342bee11fc1a23cf86e5eae224a2494da0e0bc60bf288c04924c87bdf6736f156f4d98f0468cf815d03b3291509ab234e8d
7
- data.tar.gz: 7fe2633018ec2e38805b987271cc033d023b1a32b429cf2f75e88d1ac1c86c913689fc46806ea49c38fce66005215b05fc700ca3adc925afd0b3dcd3fefdc091
6
+ metadata.gz: 2332e16fc52d5ff5fd67cea38a1e4196bb98c06256746e81d13b0572ac78957743559eb27b8de752ba8c960e72f912cb5077fce625b6233ed6e63e1c2ef67890
7
+ data.tar.gz: bf769b8943941cec7efa01bae6152302023045d01a69c6aaddf9c04f8815eb18828a2e81b8133d0c7ab873235f08acfecce528d3e7f8659fb032baa73e44c6a1
@@ -2,39 +2,43 @@ name: CI
2
2
 
3
3
  on:
4
4
  push:
5
- branches: [master]
5
+ branches: [master,v1]
6
6
  pull_request:
7
- branches: [master]
7
+ branches: [master,v1]
8
8
  workflow_dispatch:
9
9
 
10
10
  jobs:
11
- continuous_integration_build:
12
- continue-on-error: true
11
+ build:
12
+ name: Ruby ${{ matrix.ruby }} on ${{ matrix.operating-system }}
13
+ runs-on: ${{ matrix.operating-system }}
14
+ continue-on-error: ${{ matrix.experimental == 'Yes' }}
15
+ env: { JAVA_OPTS: -Djdk.io.File.enableADS=true }
16
+
13
17
  strategy:
14
18
  fail-fast: false
15
19
  matrix:
16
- ruby: [2.7, 3.0, 3.1, 3.2]
20
+ # Only the latest versions of JRuby and TruffleRuby are tested
21
+ ruby: ["3.0", "3.1", "3.2", "3.3", "truffleruby-24.0.0", "jruby-9.4.5.0"]
17
22
  operating-system: [ubuntu-latest]
23
+ experimental: [No]
18
24
  include:
19
- - ruby: head
25
+ - # Building against head version of Ruby is considered experimental
26
+ ruby: head
20
27
  operating-system: ubuntu-latest
21
- - ruby: truffleruby-head
22
- operating-system: ubuntu-latest
23
- - ruby: 2.7
24
- operating-system: windows-latest
25
- - ruby: jruby-head
26
- operating-system: windows-latest
28
+ experimental: Yes
27
29
 
28
- name: Ruby ${{ matrix.ruby }} on ${{ matrix.operating-system }}
29
-
30
- runs-on: ${{ matrix.operating-system }}
30
+ - # Only test with minimal Ruby version on Windows
31
+ ruby: 3.0
32
+ operating-system: windows-latest
31
33
 
32
- env:
33
- JAVA_OPTS: -Djdk.io.File.enableADS=true
34
+ - # Since JRuby on Windows is known to not work, consider this experimental
35
+ ruby: jruby-9.4.5.0
36
+ operating-system: windows-latest
37
+ experimental: Yes
34
38
 
35
39
  steps:
36
40
  - name: Checkout Code
37
- uses: actions/checkout@v3
41
+ uses: actions/checkout@v4
38
42
 
39
43
  - name: Setup Ruby
40
44
  uses: ruby/setup-ruby@v1
data/CHANGELOG.md CHANGED
@@ -5,6 +5,25 @@
5
5
 
6
6
  # Change Log
7
7
 
8
+ ## v2.0.0.pre2 (2024-02-24)
9
+
10
+ [Full Changelog](https://github.com/ruby-git/ruby-git/compare/v2.0.0.pre1..v2.0.0.pre2)
11
+
12
+ Changes since v2.0.0.pre1:
13
+
14
+ * 023017b Add a timeout for git commands (#692)
15
+ * 8286ceb Refactor the Error heriarchy (#693)
16
+
17
+ ## v2.0.0.pre1 (2024-01-15)
18
+
19
+ [Full Changelog](https://github.com/ruby-git/ruby-git/compare/v1.19.1..v2.0.0.pre1)
20
+
21
+ Changes since v1.19.1:
22
+
23
+ * 7585c39 Change how the git CLI subprocess is executed (#684)
24
+ * f93e042 Update instructions for releasing a new version of the git gem (#686)
25
+ * f48930d Update minimum required version of Ruby and Git (#685)
26
+
8
27
  ## v1.19.1 (2024-01-13)
9
28
 
10
29
  [Full Changelog](https://github.com/ruby-git/ruby-git/compare/v1.19.0..v1.19.1)
data/README.md CHANGED
@@ -11,12 +11,32 @@
11
11
  [![Build Status](https://github.com/ruby-git/ruby-git/workflows/CI/badge.svg?branch=master)](https://github.com/ruby-git/ruby-git/actions?query=workflow%3ACI)
12
12
  [![Code Climate](https://codeclimate.com/github/ruby-git/ruby-git.png)](https://codeclimate.com/github/ruby-git/ruby-git)
13
13
 
14
+ * [Summary](#summary)
15
+ * [v2.0.0 pre-release](#v200-pre-release)
16
+ * [Install](#install)
17
+ * [Major Objects](#major-objects)
18
+ * [Errors Raised By This Gem](#errors-raised-by-this-gem)
19
+ * [Specifying And Handling Timeouts](#specifying-and-handling-timeouts)
20
+ * [Examples](#examples)
21
+ * [Ruby version support policy](#ruby-version-support-policy)
22
+ * [License](#license)
23
+
24
+ ## Summary
25
+
14
26
  The [git gem](https://rubygems.org/gems/git) provides an API that can be used to
15
27
  create, read, and manipulate Git repositories by wrapping system calls to the `git`
16
28
  command line. The API can be used for working with Git in complex interactions
17
29
  including branching and merging, object inspection and manipulation, history, patch
18
30
  generation and more.
19
31
 
32
+ Get started by obtaining a repository object by:
33
+
34
+ * opening an existing working copy with [Git.open](https://rubydoc.info/gems/git/Git#open-class_method)
35
+ * initializing a new repository with [Git.init](https://rubydoc.info/gems/git/Git#init-class_method)
36
+ * cloning a repository with [Git.clone](https://rubydoc.info/gems/git/Git#clone-class_method)
37
+
38
+ Methods that can be called on a repository object are documented in [Git::Base](https://rubydoc.info/gems/git/Git/Base)
39
+
20
40
  ## v2.0.0 pre-release
21
41
 
22
42
  git 2.0.0 is available as a pre-release version for testing! Please give it a try.
@@ -32,7 +52,7 @@ The changes coming in this major release include:
32
52
  * Update the required Git command line version to at least 2.28
33
53
  * Update how CLI commands are called to use the [process_executer](https://github.com/main-branch/process_executer)
34
54
  gem which is built on top of [Kernel.spawn](https://ruby-doc.org/3.3.0/Kernel.html#method-i-spawn).
35
- See [PR #617](https://github.com/ruby-git/ruby-git/pull/617) for more details
55
+ See [PR #684](https://github.com/ruby-git/ruby-git/pull/684) for more details
36
56
  on the motivation for this implementation.
37
57
 
38
58
  The tentative plan is to release `2.0.0` near the end of March 2024 depending on
@@ -41,36 +61,19 @@ the feedback received during the pre-release period.
41
61
  The `master` branch will be used for `2.x` development. If needed, fixes for `1.x`
42
62
  version will be done on the `v1` branch.
43
63
 
44
- ## Homepage
45
-
46
- The project source code is at:
47
-
48
- http://github.com/ruby-git/ruby-git
49
-
50
- ## Documentation
51
-
52
- Detailed documentation can be found at:
53
-
54
- https://rubydoc.info/gems/git/Git.html
55
-
56
- Get started by obtaining a repository object by:
57
-
58
- * opening an existing working copy with [Git.open](https://rubydoc.info/gems/git/Git#open-class_method)
59
- * initializing a new repository with [Git.init](https://rubydoc.info/gems/git/Git#init-class_method)
60
- * cloning a repository with [Git.clone](https://rubydoc.info/gems/git/Git#clone-class_method)
61
-
62
- Methods that can be called on a repository object are documented in [Git::Base](https://rubydoc.info/gems/git/Git/Base)
63
-
64
64
  ## Install
65
65
 
66
- You can install Ruby/Git like this:
66
+ Install the gem and add to the application's Gemfile by executing:
67
67
 
68
- ```
69
- sudo gem install git
68
+ ```shell
69
+ bundle add git
70
70
  ```
71
71
 
72
- ## Code Status
72
+ If bundler is not being used to manage dependencies, install the gem by executing:
73
73
 
74
+ ```shell
75
+ gem install git
76
+ ```
74
77
 
75
78
  ## Major Objects
76
79
 
@@ -99,17 +102,119 @@ Pass the `--all` option to `git log` as follows:
99
102
 
100
103
  **Git::Worktrees** - Enumerable object that holds `Git::Worktree objects`.
101
104
 
102
- ## Examples
105
+ ## Errors Raised By This Gem
103
106
 
104
- Here are a bunch of examples of how to use the Ruby/Git package.
107
+ This gem raises custom errors that derive from `Git::Error`. These errors are
108
+ arranged in the following class heirarchy:
109
+
110
+ Error heirarchy:
111
+
112
+ ```text
113
+ Error
114
+ └── CommandLineError
115
+ ├── FailedError
116
+ └── SignaledError
117
+ └── TimeoutError
118
+ ```
105
119
 
106
- Ruby < 1.9 will require rubygems to be loaded.
120
+ Other standard errors may also be raised like `ArgumentError`. Each method should
121
+ document the errors it may raise.
122
+
123
+ Description of each Error class:
124
+
125
+ * `Error`: This catch-all error serves as the base class for other custom errors in this
126
+ gem. Errors of this class are raised when no more approriate specific error to
127
+ raise.
128
+ * `CommandLineError`: This error is raised when there's a problem executing the git
129
+ command line. This gem will raise a more specific error depending on how the
130
+ command line failed.
131
+ * `FailedError`: This error is raised when the git command line exits with a non-zero
132
+ status code that is not expected by the git gem.
133
+ * `SignaledError`: This error is raised when the git command line is terminated as a
134
+ result of receiving a signal. This could happen if the process is forcibly
135
+ terminated or if there is a serious system error.
136
+ * `TimeoutError`: This is a specific type of `SignaledError` that is raised when the
137
+ git command line operation times out and is killed via the SIGKILL signal. This
138
+ happens if the operation takes longer than the timeout duration configured in
139
+ `Git.config.timeout` or via the `:timeout` parameter given in git methods that
140
+ support this parameter.
141
+
142
+ `Git::GitExecuteError` remains as an alias for `Git::Error`. It is considered
143
+ deprecated as of git-2.0.0.
144
+
145
+ Here is an example of catching errors when using the git gem:
107
146
 
108
147
  ```ruby
109
- require 'rubygems'
148
+ begin
149
+ timeout_duration = 0.001 # seconds
150
+ repo = Git.clone('https://github.com/ruby-git/ruby-git', 'ruby-git-temp', timeout: timeout_duration)
151
+ rescue Git::TimeoutError => e # Catch the more specific error first!
152
+ puts "Git clone took too long and timed out #{e}"
153
+ rescue Git::Error => e
154
+ puts "Received the following error: #{e}"
110
155
  ```
111
156
 
157
+ ## Specifying And Handling Timeouts
158
+
159
+ The timeout feature was added in git gem version `2.0.0`.
160
+
161
+ A timeout for git operations can be set either globally or for specific method calls
162
+ that accept a `:timeout` parameter.
163
+
164
+ The timeout value must be a real, non-negative `Numeric` value that specifies a
165
+ number of seconds a `git` command will be given to complete before being sent a KILL
166
+ signal. This library may hang if the `git` command does not terminate after receiving
167
+ the KILL signal.
168
+
169
+ When a command times out, a `Git::TimeoutError` is raised.
170
+
171
+ If the timeout value is `0` or `nil`, no timeout will be enforced.
172
+
173
+ If a method accepts a `:timeout` parameter and a receives a non-nil value, it will
174
+ override the global timeout value. In this context, a value of `nil` (which is
175
+ usually the default) will use the global timeout value and a value of `0` will turn
176
+ off timeout enforcement for that method call no matter what the global value is.
177
+
178
+ To set a global timeout, use the `Git.config` object:
179
+
180
+ ```ruby
181
+ Git.config.timeout = nil # a value of nil or 0 means no timeout is enforced
182
+ Git.config.timeout = 1.5 # can be any real, non-negative Numeric interpreted as number of seconds
183
+ ```
184
+
185
+ The global timeout can be overridden for a specific method if the method accepts a
186
+ `:timeout` parameter:
187
+
188
+ ```ruby
189
+ repo_url = 'https://github.com/ruby-git/ruby-git.git'
190
+ Git.clone(repo_url) # Use the global timeout value
191
+ Git.clone(repo_url, timeout: nil) # Also uses the global timeout value
192
+ Git.clone(repo_url, timeout: 0) # Do not enforce a timeout
193
+ Git.clone(repo_url, timeout: 10.5) # Timeout after 10.5 seconds raising Git::SignaledError
194
+ ```
195
+
196
+ If the command takes too long, a `Git::SignaledError` will be raised:
197
+
198
+ ```ruby
199
+ begin
200
+ Git.clone(repo_url, timeout: 10)
201
+ rescue Git::TimeoutError => e
202
+ result = e.result
203
+ result.class #=> Git::CommandLineResult
204
+ result.status #=> #<Process::Status: pid 62173 SIGKILL (signal 9)>
205
+ result.status.timeout? #=> true
206
+ result.git_cmd # The git command ran as an array of strings
207
+ result.stdout # The command's output to stdout until it was terminated
208
+ result.stderr # The command's output to stderr until it was terminated
209
+ end
210
+ ```
211
+
212
+ ## Examples
213
+
214
+ Here are a bunch of examples of how to use the Ruby/Git package.
215
+
112
216
  Require the 'git' gem.
217
+
113
218
  ```ruby
114
219
  require 'git'
115
220
  ```
@@ -276,11 +381,11 @@ g.add(:all=>true) # git add --all -- "."
276
381
  g.add('file_path') # git add -- "file_path"
277
382
  g.add(['file_path_1', 'file_path_2']) # git add -- "file_path_1" "file_path_2"
278
383
 
279
- g.remove() # git rm -f -- "."
280
- g.remove('file.txt') # git rm -f -- "file.txt"
281
- g.remove(['file.txt', 'file2.txt']) # git rm -f -- "file.txt" "file2.txt"
282
- g.remove('file.txt', :recursive => true) # git rm -f -r -- "file.txt"
283
- g.remove('file.txt', :cached => true) # git rm -f --cached -- "file.txt"
384
+ g.remove() # git rm -f -- "."
385
+ g.remove('file.txt') # git rm -f -- "file.txt"
386
+ g.remove(['file.txt', 'file2.txt']) # git rm -f -- "file.txt" "file2.txt"
387
+ g.remove('file.txt', :recursive => true) # git rm -f -r -- "file.txt"
388
+ g.remove('file.txt', :cached => true) # git rm -f --cached -- "file.txt"
284
389
 
285
390
  g.commit('message')
286
391
  g.commit_all('message')
@@ -422,6 +527,14 @@ g.with_temp_working(dir) do
422
527
  end
423
528
  ```
424
529
 
530
+ ## Ruby version support policy
531
+
532
+ This gem will be expected to function correctly on:
533
+
534
+ * All non-EOL versions of the MRI Ruby on Mac, Linux, and Windows
535
+ * The latest version of JRuby on Linux and Windows
536
+ * The latest version of Truffle Ruby on Linus
537
+
425
538
  ## License
426
539
 
427
540
  licensed under MIT License Copyright (c) 2008 Scott Chacon. See LICENSE for further details.
data/RELEASING.md CHANGED
@@ -7,64 +7,79 @@
7
7
 
8
8
  Releasing a new version of the `git` gem requires these steps:
9
9
 
10
- - [How to release a new git.gem](#how-to-release-a-new-gitgem)
11
- - [Install Prerequisites](#install-prerequisites)
12
- - [Prepare the Release](#prepare-the-release)
13
- - [Review and Merge the Release](#review-and-merge-the-release)
14
- - [Build and Release the Gem](#build-and-release-the-gem)
15
-
16
- These instructions use an example where:
17
-
18
- - The default branch is `master`
19
- - The current release version is `1.5.0`
20
- - You want to create a new *minor* release, `1.6.0`
10
+ * [Install Prerequisites](#install-prerequisites)
11
+ * [Determine the SemVer release type](#determine-the-semver-release-type)
12
+ * [Create the release](#create-the-release)
13
+ * [Review the CHANGELOG and release PR](#review-the-changelog-and-release-pr)
14
+ * [Manually merge the release PR](#manually-merge-the-release-pr)
15
+ * [Publish the git gem to RubyGems.org](#publish-the-git-gem-to-rubygemsorg)
21
16
 
22
17
  ## Install Prerequisites
23
18
 
24
19
  The following tools need to be installed in order to create the release:
25
20
 
26
- - [git](https://git-scm.com) is used to interact with the local and remote repositories
27
- - [gh](https://cli.github.com) is used to create the release and PR in GitHub
28
- - [Docker](https://www.docker.com) is used to run the script to create the release notes
21
+ * [create_githhub_release](https://github.com/main-branch/create_github_release) is used to create the release
22
+ * [git](https://git-scm.com) is used by `create-github-release` to interact with the local and remote repositories
23
+ * [gh](https://cli.github.com) is used by `create-github-release` to create the release and PR in GitHub
29
24
 
30
- On a Mac, these tools can be installed using [brew](https://brew.sh):
25
+ On a Mac, these tools can be installed using [gem](https://guides.rubygems.org/rubygems-basics/) and [brew](https://brew.sh):
31
26
 
32
27
  ```shell
28
+ $ gem install create_github_release
29
+ ...
33
30
  $ brew install git
34
31
  ...
35
32
  $ brew install gh
36
33
  ...
37
- $ brew install --cask docker
38
- ...
39
34
  $
40
35
  ```
41
36
 
42
- ## Prepare the Release
37
+ ## Determine the SemVer release type
43
38
 
44
- Bump the version, create release notes, tag the release and create a GitHub release and PR which can be used to review the release.
39
+ Determine the SemVer version increment that should be applied for the new release:
45
40
 
46
- Steps:
41
+ * `major`: when the release includes incompatible API or functional changes.
42
+ * `minor`: when the release adds functionality in a backward-compatible manner
43
+ * `patch`: when the release includes small user-facing changes that are
44
+ backward-compatible and do not introduce new functionality.
47
45
 
48
- - Check out the code with `git clone https://github.com/ruby-git/ruby-git ruby-git-v1.6.0 && cd ruby-git-v1.6.0`
49
- - Install development dependencies using bundle `bundle install`
50
- - Based upon the nature of the changes, decide on the type of release: `major`, `minor`, or `patch` (in this example we will use `minor`)
51
- - Run the release script `bundle exec create-github-release minor`
46
+ ## Create the release
52
47
 
53
- ## Review and Merge the Release
48
+ Create the release using the `create-github-release` command. If the release type
49
+ is `major`, the command is:
54
50
 
55
- Have the release PR approved and merge the changes into the `master` branch.
51
+ ```shell
52
+ create-github-release major
53
+ ```
56
54
 
57
- **IMPORTANT** DO NOT merge to the `master` branch using the GitHub UI. Instead use the instructions below.
55
+ Follow the directions given by the `create-github-release` command to finish the
56
+ release. Where the instructions given by the command differ than the instructions
57
+ below, follow the instructions given by the command.
58
58
 
59
- Steps:
59
+ ## Review the CHANGELOG and release PR
60
60
 
61
- - Get the release PR reviewed and approved in GitHub
62
- - Merge the changes with the command `git checkout master && git merge --ff-only v1.6.0 && git push`
61
+ The `create-github-release` command will output a link to the CHANGELOG and the PR
62
+ it created for the release. Review the CHANGELOG and have someone review and approve
63
+ the release PR.
63
64
 
64
- ## Build and Release the Gem
65
+ ## Manually merge the release PR
65
66
 
66
- Build the gem and publish it to [rubygems.org](https://rubygems.org/gems/git)
67
+ It is important to manually merge the PR so a separate merge commit can be avoided.
68
+ Use the commands output by the `create-github-release` which will looks like this
69
+ if you are creating a 2.0.0 release:
67
70
 
68
- Steps:
71
+ ```shell
72
+ git checkout master
73
+ git merge --ff-only release-v2.0.0
74
+ git push
75
+ ```
76
+
77
+ This will automatically close the release PR.
78
+
79
+ ## Publish the git gem to RubyGems.org
69
80
 
70
- - Build and release the gem using rake `bundle exec rake release`
81
+ Finally, publish the git gem to RubyGems.org using the following command:
82
+
83
+ ```shell
84
+ rake release:rubygem_push
85
+ ```
data/git.gemspec CHANGED
@@ -24,22 +24,20 @@ Gem::Specification.new do |s|
24
24
  s.metadata['documentation_uri'] = "https://rubydoc.info/gems/#{s.name}/#{s.version}"
25
25
 
26
26
  s.require_paths = ['lib']
27
- s.required_ruby_version = '>= 2.3'
28
- s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to?(:required_rubygems_version=)
29
- s.requirements = ['git 1.6.0.0, or greater']
27
+ s.required_ruby_version = '>= 3.0.0'
28
+ s.requirements = ['git 2.28.0 or greater']
30
29
 
31
30
  s.add_runtime_dependency 'addressable', '~> 2.8'
31
+ s.add_runtime_dependency 'process_executer', '~> 1.1'
32
32
  s.add_runtime_dependency 'rchardet', '~> 1.8'
33
33
 
34
- s.add_development_dependency 'bump', '~> 0.10'
35
- s.add_development_dependency 'create_github_release', '~> 0.2'
36
34
  s.add_development_dependency 'minitar', '~> 0.9'
37
35
  s.add_development_dependency 'mocha', '~> 2.1'
38
- s.add_development_dependency 'rake', '~> 13.0'
39
- s.add_development_dependency 'test-unit', '~> 3.3'
36
+ s.add_development_dependency 'rake', '~> 13.1'
37
+ s.add_development_dependency 'test-unit', '~> 3.6'
40
38
 
41
39
  unless RUBY_PLATFORM == 'java'
42
- s.add_development_dependency 'redcarpet', '~> 3.5'
40
+ s.add_development_dependency 'redcarpet', '~> 3.6'
43
41
  s.add_development_dependency 'yard', '~> 0.9', '>= 0.9.28'
44
42
  s.add_development_dependency 'yardstick', '~> 0.9'
45
43
  end