git 1.19.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/pull_request_template.md +8 -0
- data/.github/workflows/continuous_integration.yml +14 -20
- data/.github/workflows/experimental_continuous_integration.yml +43 -0
- data/CHANGELOG.md +54 -0
- data/CONTRIBUTING.md +22 -67
- data/README.md +147 -41
- data/RELEASING.md +49 -34
- data/git.gemspec +8 -8
- data/lib/git/base.rb +21 -8
- data/lib/git/command_line.rb +377 -0
- data/lib/git/config.rb +5 -1
- data/lib/git/errors.rb +206 -0
- data/lib/git/lib.rb +151 -153
- data/lib/git/object.rb +69 -67
- data/lib/git/version.rb +1 -1
- data/lib/git.rb +8 -7
- metadata +41 -29
- data/.github/stale.yml +0 -25
- data/Dockerfile.changelog-rs +0 -12
- data/PULL_REQUEST_TEMPLATE.md +0 -9
- data/lib/git/failed_error.rb +0 -53
- data/lib/git/git_execute_error.rb +0 -7
- data/lib/git/signaled_error.rb +0 -50
- /data/{ISSUE_TEMPLATE.md → .github/issue_template.md} +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ebad290719cdefc27125cf9a2ebb0d3544334c2d49a079220c0714a701ce141
|
4
|
+
data.tar.gz: 293499cbb61ca9b4d374e86d0bd4357ed3f3b1254a46aa57c095cf0816afd7f6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8fc0929f6ff79eea57f5dbd5f05da813bb55f6c44f925ce45f4ad4f3a011c99e3cfa2d00c4a18824e1521ab975fa70057127b143d77e301f0d5d2382cd4d7480
|
7
|
+
data.tar.gz: 5ef0e326223cc983605c8afc002e3fe77808d337a3a3dcfd1b25588adf58b5c697a3451fd8baae777f727a5f2ba3cb92f2c3e811c79bc9f5da836b24ad5a8a6b
|
@@ -0,0 +1,8 @@
|
|
1
|
+
Review our [guidelines for contributing](https://github.com/ruby-git/ruby-git/blob/master/CONTRIBUTING.md) to this repository. A good start is to:
|
2
|
+
|
3
|
+
* Write tests for your changes
|
4
|
+
* Run `rake` before pushing
|
5
|
+
* Include / update docs in the README.md and in YARD documentation
|
6
|
+
|
7
|
+
# Description
|
8
|
+
|
@@ -2,39 +2,33 @@ 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
|
-
|
12
|
-
|
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
|
-
|
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
|
-
-
|
20
|
-
|
21
|
-
- ruby: truffleruby-head
|
22
|
-
operating-system: ubuntu-latest
|
23
|
-
- ruby: 2.7
|
25
|
+
- # Only test with minimal Ruby version on Windows
|
26
|
+
ruby: 3.0
|
24
27
|
operating-system: windows-latest
|
25
|
-
- ruby: jruby-head
|
26
|
-
operating-system: windows-latest
|
27
|
-
|
28
|
-
name: Ruby ${{ matrix.ruby }} on ${{ matrix.operating-system }}
|
29
|
-
|
30
|
-
runs-on: ${{ matrix.operating-system }}
|
31
|
-
|
32
|
-
env:
|
33
|
-
JAVA_OPTS: -Djdk.io.File.enableADS=true
|
34
28
|
|
35
29
|
steps:
|
36
30
|
- name: Checkout Code
|
37
|
-
uses: actions/checkout@
|
31
|
+
uses: actions/checkout@v4
|
38
32
|
|
39
33
|
- name: Setup Ruby
|
40
34
|
uses: ruby/setup-ruby@v1
|
@@ -0,0 +1,43 @@
|
|
1
|
+
name: CI Experimental
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [master,v1]
|
6
|
+
workflow_dispatch:
|
7
|
+
|
8
|
+
jobs:
|
9
|
+
build:
|
10
|
+
name: Ruby ${{ matrix.ruby }} on ${{ matrix.operating-system }}
|
11
|
+
runs-on: ${{ matrix.operating-system }}
|
12
|
+
continue-on-error: true
|
13
|
+
env: { JAVA_OPTS: -Djdk.io.File.enableADS=true }
|
14
|
+
|
15
|
+
strategy:
|
16
|
+
fail-fast: false
|
17
|
+
matrix:
|
18
|
+
include:
|
19
|
+
- # Building against head version of Ruby is considered experimental
|
20
|
+
ruby: head
|
21
|
+
operating-system: ubuntu-latest
|
22
|
+
experimental: Yes
|
23
|
+
|
24
|
+
- # Since JRuby on Windows is known to not work, consider this experimental
|
25
|
+
ruby: jruby-head
|
26
|
+
operating-system: windows-latest
|
27
|
+
experimental: Yes
|
28
|
+
|
29
|
+
steps:
|
30
|
+
- name: Checkout Code
|
31
|
+
uses: actions/checkout@v4
|
32
|
+
|
33
|
+
- name: Setup Ruby
|
34
|
+
uses: ruby/setup-ruby@v1
|
35
|
+
with:
|
36
|
+
ruby-version: ${{ matrix.ruby }}
|
37
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
38
|
+
|
39
|
+
- name: Run Build
|
40
|
+
run: bundle exec rake default
|
41
|
+
|
42
|
+
- name: Test Gem
|
43
|
+
run: bundle exec rake test:gem
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,60 @@
|
|
5
5
|
|
6
6
|
# Change Log
|
7
7
|
|
8
|
+
## v2.0.0 (2024-05-10)
|
9
|
+
|
10
|
+
[Full Changelog](https://github.com/ruby-git/ruby-git/compare/v2.0.0.pre4..v2.0.0)
|
11
|
+
|
12
|
+
Changes since v2.0.0.pre4:
|
13
|
+
|
14
|
+
* 1afc4c6 Update 2.x release line description
|
15
|
+
* ed52420 Make the pull request template more concise
|
16
|
+
* 299ae6b Remove stale bot integration
|
17
|
+
* efb724b Remove the DCO requirement for commits
|
18
|
+
|
19
|
+
## v2.0.0.pre4 (2024-05-10)
|
20
|
+
|
21
|
+
[Full Changelog](https://jcouball@github.com/ruby-git/ruby-git/compare/v2.0.0.pre3..v2.0.0.pre4)
|
22
|
+
|
23
|
+
Changes since v2.0.0.pre3:
|
24
|
+
|
25
|
+
* 56783e7 Update create_github_release dependency so pre-releases can be made
|
26
|
+
* 8566929 Add dependency on create_github_release gem used for releasing the git gem
|
27
|
+
* 7376d76 Refactor errors that are raised by this gem
|
28
|
+
* 7e99b17 Update documentation for new timeout functionality
|
29
|
+
* 705e983 Move experimental builds to a separate workflow that only runs when pushed to master
|
30
|
+
* e056d64 Build with jruby-head on Windows until jruby/jruby#7515 is fixed
|
31
|
+
* ec7c257 Remove unneeded scripts to create a new release
|
32
|
+
* d9570ab Move issue and pull request templates to the .github directory
|
33
|
+
* e4d6a77 Show log(x).since combination in README
|
34
|
+
|
35
|
+
## v2.0.0.pre3 (2024-03-15)
|
36
|
+
|
37
|
+
[Full Changelog](https://github.com/ruby-git/ruby-git/compare/v2.0.0.pre2..v2.0.0.pre3)
|
38
|
+
|
39
|
+
Changes since v2.0.0.pre2:
|
40
|
+
|
41
|
+
* 5d4b34e Allow allow_unrelated_histories option for Base#pull
|
42
|
+
|
43
|
+
## v2.0.0.pre2 (2024-02-24)
|
44
|
+
|
45
|
+
[Full Changelog](https://github.com/ruby-git/ruby-git/compare/v2.0.0.pre1..v2.0.0.pre2)
|
46
|
+
|
47
|
+
Changes since v2.0.0.pre1:
|
48
|
+
|
49
|
+
* 023017b Add a timeout for git commands (#692)
|
50
|
+
* 8286ceb Refactor the Error heriarchy (#693)
|
51
|
+
|
52
|
+
## v2.0.0.pre1 (2024-01-15)
|
53
|
+
|
54
|
+
[Full Changelog](https://github.com/ruby-git/ruby-git/compare/v1.19.1..v2.0.0.pre1)
|
55
|
+
|
56
|
+
Changes since v1.19.1:
|
57
|
+
|
58
|
+
* 7585c39 Change how the git CLI subprocess is executed (#684)
|
59
|
+
* f93e042 Update instructions for releasing a new version of the git gem (#686)
|
60
|
+
* f48930d Update minimum required version of Ruby and Git (#685)
|
61
|
+
|
8
62
|
## v1.19.1 (2024-01-13)
|
9
63
|
|
10
64
|
[Full Changelog](https://github.com/ruby-git/ruby-git/compare/v1.19.0..v1.19.1)
|
data/CONTRIBUTING.md
CHANGED
@@ -40,10 +40,6 @@ There is three step process for code or documentation changes:
|
|
40
40
|
|
41
41
|
Make your changes in a fork of the ruby-git repository.
|
42
42
|
|
43
|
-
Each commit must include a [DCO sign-off](#developer-certificate-of-origin-dco)
|
44
|
-
by adding the line `Signed-off-by: Name <email>` to the end of the commit
|
45
|
-
message.
|
46
|
-
|
47
43
|
### Create a pull request
|
48
44
|
|
49
45
|
See [this article](https://help.github.com/articles/about-pull-requests/) if you
|
@@ -71,15 +67,18 @@ request meets [the project's coding standards](#coding-standards).
|
|
71
67
|
In order to ensure high quality, all pull requests must meet these requirements:
|
72
68
|
|
73
69
|
### 1 PR = 1 Commit
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
70
|
+
|
71
|
+
* All commits for a PR must be squashed into one commit
|
72
|
+
* To avoid an extra merge commit, the PR must be able to be merged as [a fast forward
|
73
|
+
merge](https://git-scm.com/book/en/v2/Git-Branching-Basic-Branching-and-Merging)
|
74
|
+
* The easiest way to ensure a fast forward merge is to rebase your local branch to
|
75
|
+
the ruby-git master branch
|
78
76
|
|
79
77
|
### Unit tests
|
80
|
-
|
81
|
-
|
82
|
-
|
78
|
+
|
79
|
+
* All changes must be accompanied by new or modified unit tests
|
80
|
+
* The entire test suite must pass when `bundle exec rake default` is run from the
|
81
|
+
project's local working copy.
|
83
82
|
|
84
83
|
While working on specific features you can run individual test files or
|
85
84
|
a group of tests using `bin/test`:
|
@@ -94,20 +93,21 @@ a group of tests using `bin/test`:
|
|
94
93
|
$ bin/test
|
95
94
|
|
96
95
|
### Continuous integration
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
96
|
+
|
97
|
+
* All tests must pass in the project's [GitHub Continuous Integration
|
98
|
+
build](https://github.com/ruby-git/ruby-git/actions?query=workflow%3ACI) before the
|
99
|
+
pull request will be merged.
|
100
|
+
* The [Continuous Integration
|
101
|
+
workflow](https://github.com/ruby-git/ruby-git/blob/master/.github/workflows/continuous_integration.yml)
|
102
|
+
runs both `bundle exec rake default` and `bundle exec rake test:gem` from the
|
103
|
+
project's [Rakefile](https://github.com/ruby-git/ruby-git/blob/master/Rakefile).
|
101
104
|
|
102
105
|
### Documentation
|
103
|
-
* New and updated public methods must have [YARD](https://yardoc.org/)
|
104
|
-
documentation added to them
|
105
|
-
* New and updated public facing features should be documented in the project's
|
106
|
-
[README.md](README.md)
|
107
106
|
|
108
|
-
|
109
|
-
|
110
|
-
|
107
|
+
* New and updated public methods must have [YARD](https://yardoc.org/) documentation
|
108
|
+
added to them
|
109
|
+
* New and updated public facing features should be documented in the project's
|
110
|
+
[README.md](README.md)
|
111
111
|
|
112
112
|
## Licensing
|
113
113
|
|
@@ -116,48 +116,3 @@ declared in the [LICENSE](LICENSE) file.
|
|
116
116
|
|
117
117
|
Licensing is very important to open source projects. It helps ensure the
|
118
118
|
software continues to be available under the terms that the author desired.
|
119
|
-
|
120
|
-
### Developer Certificate of Origin (DCO)
|
121
|
-
|
122
|
-
This project requires that authors have permission to submit their contributions
|
123
|
-
under the MIT license. To make a good faith effort to ensure this, ruby-git
|
124
|
-
requires the [Developer Certificate of Origin (DCO)](https://elinux.org/Developer_Certificate_Of_Origin)
|
125
|
-
process be followed.
|
126
|
-
|
127
|
-
This process requires that each commit include a `Signed-off-by` line that
|
128
|
-
indicates the author accepts the DCO. Here is an example DCO sign-off line:
|
129
|
-
|
130
|
-
```
|
131
|
-
Signed-off-by: John Doe <john.doe@hisdomain.com>
|
132
|
-
```
|
133
|
-
|
134
|
-
The full text of the DCO version 1.1 is below or at <http://developercertificate.org/>.
|
135
|
-
|
136
|
-
```
|
137
|
-
Developer's Certificate of Origin 1.1
|
138
|
-
|
139
|
-
By making a contribution to this project, I certify that:
|
140
|
-
|
141
|
-
(a) The contribution was created in whole or in part by me and I
|
142
|
-
have the right to submit it under the open source license
|
143
|
-
indicated in the file; or
|
144
|
-
|
145
|
-
(b) The contribution is based upon previous work that, to the
|
146
|
-
best of my knowledge, is covered under an appropriate open
|
147
|
-
source license and I have the right under that license to
|
148
|
-
submit that work with modifications, whether created in whole
|
149
|
-
or in part by me, under the same open source license (unless
|
150
|
-
I am permitted to submit under a different license), as
|
151
|
-
Indicated in the file; or
|
152
|
-
|
153
|
-
(c) The contribution was provided directly to me by some other
|
154
|
-
person who certified (a), (b) or (c) and I have not modified
|
155
|
-
it.
|
156
|
-
|
157
|
-
(d) I understand and agree that this project and the contribution
|
158
|
-
are public and that a record of the contribution (including
|
159
|
-
all personal information I submit with it, including my
|
160
|
-
sign-off) is maintained indefinitely and may be redistributed
|
161
|
-
consistent with this project or the open source license(s)
|
162
|
-
involved.
|
163
|
-
```
|
data/README.md
CHANGED
@@ -11,66 +11,83 @@
|
|
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.x Release](#v2x-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
|
|
20
|
-
|
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
|
+
|
40
|
+
## v2.x Release
|
41
|
+
|
42
|
+
git 2.0.0 has recently been released. Please give it a try.
|
21
43
|
|
22
|
-
|
44
|
+
|
45
|
+
**If you have problems with the 2.x release, open an issue and use the 1.9.1 version
|
46
|
+
instead.** We will do our best to fix your issues in a timely fashion.
|
23
47
|
|
24
48
|
**JRuby on Windows is not yet supported by the 2.x release line. Users running JRuby
|
25
49
|
on Windows should continue to use the 1.x release line.**
|
26
50
|
|
27
|
-
The changes
|
51
|
+
The changes in this major release include:
|
28
52
|
|
53
|
+
* Added a dependency on the activesupport gem to use the deprecation functionality
|
29
54
|
* Create a policy of supported Ruby versions to support only non-EOL Ruby versions
|
30
55
|
* Create a policy of supported Git CLI versions (released 2020-12-25)
|
31
56
|
* Update the required Ruby version to at least 3.0 (released 2020-07-27)
|
32
57
|
* Update the required Git command line version to at least 2.28
|
33
58
|
* Update how CLI commands are called to use the [process_executer](https://github.com/main-branch/process_executer)
|
34
59
|
gem which is built on top of [Kernel.spawn](https://ruby-doc.org/3.3.0/Kernel.html#method-i-spawn).
|
35
|
-
See [PR #
|
60
|
+
See [PR #684](https://github.com/ruby-git/ruby-git/pull/684) for more details
|
36
61
|
on the motivation for this implementation.
|
37
62
|
|
38
|
-
The tentative plan is to release `2.0.0` near the end of March 2024 depending on
|
39
|
-
the feedback received during the pre-release period.
|
40
|
-
|
41
63
|
The `master` branch will be used for `2.x` development. If needed, fixes for `1.x`
|
42
64
|
version will be done on the `v1` branch.
|
43
65
|
|
44
|
-
##
|
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
|
66
|
+
## Install
|
55
67
|
|
56
|
-
|
68
|
+
Install the gem and add to the application's Gemfile by executing:
|
57
69
|
|
58
|
-
|
59
|
-
|
60
|
-
|
70
|
+
```shell
|
71
|
+
bundle add git
|
72
|
+
```
|
61
73
|
|
62
|
-
|
74
|
+
to install version 1.x:
|
63
75
|
|
64
|
-
|
76
|
+
```shell
|
77
|
+
bundle add git --version "~> 1.19"
|
78
|
+
```
|
65
79
|
|
66
|
-
|
80
|
+
If bundler is not being used to manage dependencies, install the gem by executing:
|
67
81
|
|
68
|
-
```
|
69
|
-
|
82
|
+
```shell
|
83
|
+
gem install git
|
70
84
|
```
|
71
85
|
|
72
|
-
|
86
|
+
to install version 1.x:
|
73
87
|
|
88
|
+
```shell
|
89
|
+
gem install git --version "~> 1.19"
|
90
|
+
```
|
74
91
|
|
75
92
|
## Major Objects
|
76
93
|
|
@@ -99,17 +116,89 @@ Pass the `--all` option to `git log` as follows:
|
|
99
116
|
|
100
117
|
**Git::Worktrees** - Enumerable object that holds `Git::Worktree objects`.
|
101
118
|
|
102
|
-
##
|
119
|
+
## Errors Raised By This Gem
|
103
120
|
|
104
|
-
|
121
|
+
The git gem will only raise an `ArgumentError` or an error that is a subclass of
|
122
|
+
`Git::Error`. It does not explicitly raise any other types of errors.
|
105
123
|
|
106
|
-
|
124
|
+
It is recommended to rescue `Git::Error` to catch any runtime error raised by
|
125
|
+
this gem unless you need more specific error handling.
|
107
126
|
|
108
127
|
```ruby
|
109
|
-
|
128
|
+
begin
|
129
|
+
# some git operation
|
130
|
+
rescue Git::Error => e
|
131
|
+
puts "An error occurred: #{e.message}"
|
132
|
+
end
|
110
133
|
```
|
111
134
|
|
135
|
+
See [`Git::Error`](https://rubydoc.info/gems/git/Git/Error) for more information.
|
136
|
+
|
137
|
+
## Specifying And Handling Timeouts
|
138
|
+
|
139
|
+
The timeout feature was added in git gem version `2.0.0`.
|
140
|
+
|
141
|
+
A timeout for git command line operations can be set either globally or for specific
|
142
|
+
method calls that accept a `:timeout` parameter.
|
143
|
+
|
144
|
+
The timeout value must be a real, non-negative `Numeric` value that specifies a
|
145
|
+
number of seconds a `git` command will be given to complete before being sent a KILL
|
146
|
+
signal. This library may hang if the `git` command does not terminate after receiving
|
147
|
+
the KILL signal.
|
148
|
+
|
149
|
+
When a command times out, it is killed by sending it the `SIGKILL` signal and a
|
150
|
+
`Git::TimeoutError` is raised. This error derives from the `Git::SignaledError` and
|
151
|
+
`Git::Error`.
|
152
|
+
|
153
|
+
If the timeout value is `0` or `nil`, no timeout will be enforced.
|
154
|
+
|
155
|
+
If a method accepts a `:timeout` parameter and a receives a non-nil value, the value
|
156
|
+
of this parameter will override the global timeout value. In this context, a value of
|
157
|
+
`nil` (which is usually the default) will use the global timeout value and a value of
|
158
|
+
`0` will turn off timeout enforcement for that method call no matter what the global
|
159
|
+
value is.
|
160
|
+
|
161
|
+
To set a global timeout, use the `Git.config` object:
|
162
|
+
|
163
|
+
```ruby
|
164
|
+
Git.config.timeout = nil # a value of nil or 0 means no timeout is enforced
|
165
|
+
Git.config.timeout = 1.5 # can be any real, non-negative Numeric interpreted as number of seconds
|
166
|
+
```
|
167
|
+
|
168
|
+
The global timeout can be overridden for a specific method if the method accepts a
|
169
|
+
`:timeout` parameter:
|
170
|
+
|
171
|
+
```ruby
|
172
|
+
repo_url = 'https://github.com/ruby-git/ruby-git.git'
|
173
|
+
Git.clone(repo_url) # Use the global timeout value
|
174
|
+
Git.clone(repo_url, timeout: nil) # Also uses the global timeout value
|
175
|
+
Git.clone(repo_url, timeout: 0) # Do not enforce a timeout
|
176
|
+
Git.clone(repo_url, timeout: 10.5) # Timeout after 10.5 seconds raising Git::SignaledError
|
177
|
+
```
|
178
|
+
|
179
|
+
If the command takes too long, a `Git::TimeoutError` will be raised:
|
180
|
+
|
181
|
+
```ruby
|
182
|
+
begin
|
183
|
+
Git.clone(repo_url, timeout: 10)
|
184
|
+
rescue Git::TimeoutError => e
|
185
|
+
e.result.tap do |r|
|
186
|
+
r.class #=> Git::CommandLineResult
|
187
|
+
r.status #=> #<Process::Status: pid 62173 SIGKILL (signal 9)>
|
188
|
+
r.status.timeout? #=> true
|
189
|
+
r.git_cmd # The git command ran as an array of strings
|
190
|
+
r.stdout # The command's output to stdout until it was terminated
|
191
|
+
r.stderr # The command's output to stderr until it was terminated
|
192
|
+
end
|
193
|
+
end
|
194
|
+
```
|
195
|
+
|
196
|
+
## Examples
|
197
|
+
|
198
|
+
Here are a bunch of examples of how to use the Ruby/Git package.
|
199
|
+
|
112
200
|
Require the 'git' gem.
|
201
|
+
|
113
202
|
```ruby
|
114
203
|
require 'git'
|
115
204
|
```
|
@@ -139,9 +228,12 @@ g.index.writable?
|
|
139
228
|
g.repo
|
140
229
|
g.dir
|
141
230
|
|
142
|
-
|
143
|
-
|
144
|
-
g.log
|
231
|
+
# log - returns a Git::Log object, which is an Enumerator of Git::Commit objects
|
232
|
+
# default configuration returns a max of 30 commits
|
233
|
+
g.log
|
234
|
+
g.log(200) # 200 most recent commits
|
235
|
+
g.log.since('2 weeks ago') # default count of commits since 2 weeks ago.
|
236
|
+
g.log(200).since('2 weeks ago') # commits since 2 weeks ago, limited to 200.
|
145
237
|
g.log.between('v2.5', 'v2.6')
|
146
238
|
g.log.each {|l| puts l.sha }
|
147
239
|
g.gblob('v2.5:Makefile').log.since('2 weeks ago')
|
@@ -276,11 +368,11 @@ g.add(:all=>true) # git add --all -- "."
|
|
276
368
|
g.add('file_path') # git add -- "file_path"
|
277
369
|
g.add(['file_path_1', 'file_path_2']) # git add -- "file_path_1" "file_path_2"
|
278
370
|
|
279
|
-
g.remove()
|
280
|
-
g.remove('file.txt')
|
281
|
-
g.remove(['file.txt', 'file2.txt'])
|
282
|
-
g.remove('file.txt', :recursive => true)
|
283
|
-
g.remove('file.txt', :cached => true)
|
371
|
+
g.remove() # git rm -f -- "."
|
372
|
+
g.remove('file.txt') # git rm -f -- "file.txt"
|
373
|
+
g.remove(['file.txt', 'file2.txt']) # git rm -f -- "file.txt" "file2.txt"
|
374
|
+
g.remove('file.txt', :recursive => true) # git rm -f -r -- "file.txt"
|
375
|
+
g.remove('file.txt', :cached => true) # git rm -f --cached -- "file.txt"
|
284
376
|
|
285
377
|
g.commit('message')
|
286
378
|
g.commit_all('message')
|
@@ -422,6 +514,20 @@ g.with_temp_working(dir) do
|
|
422
514
|
end
|
423
515
|
```
|
424
516
|
|
517
|
+
## Ruby version support policy
|
518
|
+
|
519
|
+
This gem will be expected to function correctly on:
|
520
|
+
|
521
|
+
* All non-EOL versions of the MRI Ruby on Mac, Linux, and Windows
|
522
|
+
* The latest version of JRuby on Linux
|
523
|
+
* The latest version of Truffle Ruby on Linus
|
524
|
+
|
525
|
+
It is this project's intent to support the latest version of JRuby on Windows
|
526
|
+
once the following JRuby bug is fixed:
|
527
|
+
|
528
|
+
jruby/jruby#7515
|
529
|
+
|
425
530
|
## License
|
426
531
|
|
427
|
-
|
532
|
+
Licensed under MIT License Copyright (c) 2008 Scott Chacon. See LICENSE for further
|
533
|
+
details.
|