git 2.0.0.pre3 → 2.0.1

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: 0bd064fe363a807e4c9a77eaf61810f6fc41323ad1b60a57eb0379460f26e91c
4
- data.tar.gz: 890bb2663ba5e3cc9b12f3dae403a019e3b7eb0ffb95ad2fdf5989073d53e807
3
+ metadata.gz: 7c7aebf8b61eb75a0d3e587fae03711b1d9cec89c7fb69462bda24c069daeaa4
4
+ data.tar.gz: f73bd8a6e030209305ffbcc1bae372cd6820745569142ddd7239b366ef78d322
5
5
  SHA512:
6
- metadata.gz: bbd732fb4061c1b68500860218eb14248adc48d4e4ff77d9b2c19cd13de5cb54c9c1bf313949131c91c7e3a25b24d8d105abb485571e06b25415875a67ce4f94
7
- data.tar.gz: 6bf02024406485e4150cc76073d859446e490a659e6a17dad1f0f04c9d0084bcb063ccbc12dc839baa1b20094e2a2dcaf800c744560c49eab29264b588d154fb
6
+ metadata.gz: 32c0e605d3ee280c19cf863f5b9a5fc9437171b9facbbee074b2ddca096c4cae3f08ddf42cb6cad7a91512824f40cd51940e1846c1f1a3e5bb7f4e7ee52e154b
7
+ data.tar.gz: 528bf8926dbf6b76681b8333ca3d797b1e28854921f6abcd5b2fd9a13c6861c25e6ad75462efb818c1c74de0980c96974a423ad2a19aaf87d5b27e3e2ffca8cf
@@ -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
+
@@ -22,20 +22,10 @@ jobs:
22
22
  operating-system: [ubuntu-latest]
23
23
  experimental: [No]
24
24
  include:
25
- - # Building against head version of Ruby is considered experimental
26
- ruby: head
27
- operating-system: ubuntu-latest
28
- experimental: Yes
29
-
30
25
  - # Only test with minimal Ruby version on Windows
31
26
  ruby: 3.0
32
27
  operating-system: windows-latest
33
28
 
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
38
-
39
29
  steps:
40
30
  - name: Checkout Code
41
31
  uses: actions/checkout@v4
@@ -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,44 @@
5
5
 
6
6
  # Change Log
7
7
 
8
+ ## v2.0.1 (2024-05-21)
9
+
10
+ [Full Changelog](https://github.com/ruby-git/ruby-git/compare/v2.0.0..v2.0.1)
11
+
12
+ Changes since v2.0.0:
13
+
14
+ * da435b1 Document and add tests for Git::Status
15
+ * c8a77db Fix Git::Base#status on an empty repo
16
+ * 712fdad Fix Git::Status#untracked when run from worktree subdir
17
+ * 6a59bc8 Remove the Git::Base::Factory module
18
+
19
+ ## v2.0.0 (2024-05-10)
20
+
21
+ [Full Changelog](https://github.com/ruby-git/ruby-git/compare/v2.0.0.pre4..v2.0.0)
22
+
23
+ Changes since v2.0.0.pre4:
24
+
25
+ * 1afc4c6 Update 2.x release line description
26
+ * ed52420 Make the pull request template more concise
27
+ * 299ae6b Remove stale bot integration
28
+ * efb724b Remove the DCO requirement for commits
29
+
30
+ ## v2.0.0.pre4 (2024-05-10)
31
+
32
+ [Full Changelog](https://jcouball@github.com/ruby-git/ruby-git/compare/v2.0.0.pre3..v2.0.0.pre4)
33
+
34
+ Changes since v2.0.0.pre3:
35
+
36
+ * 56783e7 Update create_github_release dependency so pre-releases can be made
37
+ * 8566929 Add dependency on create_github_release gem used for releasing the git gem
38
+ * 7376d76 Refactor errors that are raised by this gem
39
+ * 7e99b17 Update documentation for new timeout functionality
40
+ * 705e983 Move experimental builds to a separate workflow that only runs when pushed to master
41
+ * e056d64 Build with jruby-head on Windows until jruby/jruby#7515 is fixed
42
+ * ec7c257 Remove unneeded scripts to create a new release
43
+ * d9570ab Move issue and pull request templates to the .github directory
44
+ * e4d6a77 Show log(x).since combination in README
45
+
8
46
  ## v2.0.0.pre3 (2024-03-15)
9
47
 
10
48
  [Full Changelog](https://github.com/ruby-git/ruby-git/compare/v2.0.0.pre2..v2.0.0.pre3)
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
- * All commits for a PR must be squashed into one commit
75
- * To avoid an extra merge commit, the PR must be able to be merged as [a fast forward merge](https://git-scm.com/book/en/v2/Git-Branching-Basic-Branching-and-Merging)
76
- * The easiest way to ensure a fast forward merge is to rebase your local branch
77
- to the ruby-git master branch
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
- * All changes must be accompanied by new or modified unit tests
81
- * The entire test suite must pass when `bundle exec rake default` is run from the
82
- project's local working copy.
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
- * All tests must pass in the project's [GitHub Continuous Integration build](https://github.com/ruby-git/ruby-git/actions?query=workflow%3ACI)
98
- before the pull request will be merged.
99
- * The [Continuous Integration workflow](https://github.com/ruby-git/ruby-git/blob/master/.github/workflows/continuous_integration.yml)
100
- 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).
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
- ### Licensing sign-off
109
- * Each commit must contain [the DCO sign-off](#developer-certificate-of-origin-dco)
110
- in the form: `Signed-off-by: Name <email>`
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
@@ -12,7 +12,7 @@
12
12
  [![Code Climate](https://codeclimate.com/github/ruby-git/ruby-git.png)](https://codeclimate.com/github/ruby-git/ruby-git)
13
13
 
14
14
  * [Summary](#summary)
15
- * [v2.0.0 pre-release](#v200-pre-release)
15
+ * [v2.x Release](#v2x-release)
16
16
  * [Install](#install)
17
17
  * [Major Objects](#major-objects)
18
18
  * [Errors Raised By This Gem](#errors-raised-by-this-gem)
@@ -23,11 +23,8 @@
23
23
 
24
24
  ## Summary
25
25
 
26
- The [git gem](https://rubygems.org/gems/git) provides an API that can be used to
27
- create, read, and manipulate Git repositories by wrapping system calls to the `git`
28
- command line. The API can be used for working with Git in complex interactions
29
- including branching and merging, object inspection and manipulation, history, patch
30
- generation and more.
26
+ The [git gem](https://rubygems.org/gems/git) provides a Ruby interface to the `git`
27
+ command line.
31
28
 
32
29
  Get started by obtaining a repository object by:
33
30
 
@@ -37,15 +34,19 @@ Get started by obtaining a repository object by:
37
34
 
38
35
  Methods that can be called on a repository object are documented in [Git::Base](https://rubydoc.info/gems/git/Git/Base)
39
36
 
40
- ## v2.0.0 pre-release
37
+ ## v2.x Release
41
38
 
42
- git 2.0.0 is available as a pre-release version for testing! Please give it a try.
39
+ git 2.0.0 has recently been released. Please give it a try.
40
+
41
+ **If you have problems with the 2.x release, open an issue and use the 1.x version
42
+ instead.** We will do our best to fix your issues in a timely fashion.
43
43
 
44
44
  **JRuby on Windows is not yet supported by the 2.x release line. Users running JRuby
45
45
  on Windows should continue to use the 1.x release line.**
46
46
 
47
- The changes coming in this major release include:
47
+ The changes in this major release include:
48
48
 
49
+ * Added a dependency on the activesupport gem to use the deprecation functionality
49
50
  * Create a policy of supported Ruby versions to support only non-EOL Ruby versions
50
51
  * Create a policy of supported Git CLI versions (released 2020-12-25)
51
52
  * Update the required Ruby version to at least 3.0 (released 2020-07-27)
@@ -55,9 +56,6 @@ The changes coming in this major release include:
55
56
  See [PR #684](https://github.com/ruby-git/ruby-git/pull/684) for more details
56
57
  on the motivation for this implementation.
57
58
 
58
- The tentative plan is to release `2.0.0` near the end of March 2024 depending on
59
- the feedback received during the pre-release period.
60
-
61
59
  The `master` branch will be used for `2.x` development. If needed, fixes for `1.x`
62
60
  version will be done on the `v1` branch.
63
61
 
@@ -69,12 +67,24 @@ Install the gem and add to the application's Gemfile by executing:
69
67
  bundle add git
70
68
  ```
71
69
 
70
+ to install version 1.x:
71
+
72
+ ```shell
73
+ bundle add git --version "~> 1.19"
74
+ ```
75
+
72
76
  If bundler is not being used to manage dependencies, install the gem by executing:
73
77
 
74
78
  ```shell
75
79
  gem install git
76
80
  ```
77
81
 
82
+ to install version 1.x:
83
+
84
+ ```shell
85
+ gem install git --version "~> 1.19"
86
+ ```
87
+
78
88
  ## Major Objects
79
89
 
80
90
  **Git::Base** - The object returned from a `Git.open` or `Git.clone`. Most major actions are called from this object.
@@ -104,76 +114,45 @@ Pass the `--all` option to `git log` as follows:
104
114
 
105
115
  ## Errors Raised By This Gem
106
116
 
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:
117
+ The git gem will only raise an `ArgumentError` or an error that is a subclass of
118
+ `Git::Error`. It does not explicitly raise any other types of errors.
111
119
 
112
- ```text
113
- Error
114
- └── CommandLineError
115
- ├── FailedError
116
- └── SignaledError
117
- └── TimeoutError
118
- ```
119
-
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:
120
+ It is recommended to rescue `Git::Error` to catch any runtime error raised by
121
+ this gem unless you need more specific error handling.
146
122
 
147
123
  ```ruby
148
124
  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}"
125
+ # some git operation
153
126
  rescue Git::Error => e
154
- puts "Received the following error: #{e}"
127
+ puts "An error occurred: #{e.message}"
128
+ end
155
129
  ```
156
130
 
131
+ See [`Git::Error`](https://rubydoc.info/gems/git/Git/Error) for more information.
132
+
157
133
  ## Specifying And Handling Timeouts
158
134
 
159
135
  The timeout feature was added in git gem version `2.0.0`.
160
136
 
161
- A timeout for git operations can be set either globally or for specific method calls
162
- that accept a `:timeout` parameter.
137
+ A timeout for git command line operations can be set either globally or for specific
138
+ method calls that accept a `:timeout` parameter.
163
139
 
164
140
  The timeout value must be a real, non-negative `Numeric` value that specifies a
165
141
  number of seconds a `git` command will be given to complete before being sent a KILL
166
142
  signal. This library may hang if the `git` command does not terminate after receiving
167
143
  the KILL signal.
168
144
 
169
- When a command times out, a `Git::TimeoutError` is raised.
145
+ When a command times out, it is killed by sending it the `SIGKILL` signal and a
146
+ `Git::TimeoutError` is raised. This error derives from the `Git::SignaledError` and
147
+ `Git::Error`.
170
148
 
171
149
  If the timeout value is `0` or `nil`, no timeout will be enforced.
172
150
 
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.
151
+ If a method accepts a `:timeout` parameter and a receives a non-nil value, the value
152
+ of this parameter will override the global timeout value. In this context, a value of
153
+ `nil` (which is usually the default) will use the global timeout value and a value of
154
+ `0` will turn off timeout enforcement for that method call no matter what the global
155
+ value is.
177
156
 
178
157
  To set a global timeout, use the `Git.config` object:
179
158
 
@@ -193,19 +172,20 @@ Git.clone(repo_url, timeout: 0) # Do not enforce a timeout
193
172
  Git.clone(repo_url, timeout: 10.5) # Timeout after 10.5 seconds raising Git::SignaledError
194
173
  ```
195
174
 
196
- If the command takes too long, a `Git::SignaledError` will be raised:
175
+ If the command takes too long, a `Git::TimeoutError` will be raised:
197
176
 
198
177
  ```ruby
199
178
  begin
200
179
  Git.clone(repo_url, timeout: 10)
201
180
  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
181
+ e.result.tap do |r|
182
+ r.class #=> Git::CommandLineResult
183
+ r.status #=> #<Process::Status: pid 62173 SIGKILL (signal 9)>
184
+ r.status.timeout? #=> true
185
+ r.git_cmd # The git command ran as an array of strings
186
+ r.stdout # The command's output to stdout until it was terminated
187
+ r.stderr # The command's output to stderr until it was terminated
188
+ end
209
189
  end
210
190
  ```
211
191
 
@@ -244,9 +224,12 @@ g.index.writable?
244
224
  g.repo
245
225
  g.dir
246
226
 
247
- g.log # returns a Git::Log object, which is an Enumerator of Git::Commit objects
248
- g.log(200)
249
- g.log.since('2 weeks ago')
227
+ # log - returns a Git::Log object, which is an Enumerator of Git::Commit objects
228
+ # default configuration returns a max of 30 commits
229
+ g.log
230
+ g.log(200) # 200 most recent commits
231
+ g.log.since('2 weeks ago') # default count of commits since 2 weeks ago.
232
+ g.log(200).since('2 weeks ago') # commits since 2 weeks ago, limited to 200.
250
233
  g.log.between('v2.5', 'v2.6')
251
234
  g.log.each {|l| puts l.sha }
252
235
  g.gblob('v2.5:Makefile').log.since('2 weeks ago')
@@ -532,9 +515,15 @@ end
532
515
  This gem will be expected to function correctly on:
533
516
 
534
517
  * All non-EOL versions of the MRI Ruby on Mac, Linux, and Windows
535
- * The latest version of JRuby on Linux and Windows
518
+ * The latest version of JRuby on Linux
536
519
  * The latest version of Truffle Ruby on Linus
537
520
 
521
+ It is this project's intent to support the latest version of JRuby on Windows
522
+ once the following JRuby bug is fixed:
523
+
524
+ jruby/jruby#7515
525
+
538
526
  ## License
539
527
 
540
- licensed under MIT License Copyright (c) 2008 Scott Chacon. See LICENSE for further details.
528
+ Licensed under MIT License Copyright (c) 2008 Scott Chacon. See LICENSE for further
529
+ details.
data/git.gemspec CHANGED
@@ -27,10 +27,12 @@ Gem::Specification.new do |s|
27
27
  s.required_ruby_version = '>= 3.0.0'
28
28
  s.requirements = ['git 2.28.0 or greater']
29
29
 
30
+ s.add_runtime_dependency 'activesupport', '>= 5.0'
30
31
  s.add_runtime_dependency 'addressable', '~> 2.8'
31
32
  s.add_runtime_dependency 'process_executer', '~> 1.1'
32
33
  s.add_runtime_dependency 'rchardet', '~> 1.8'
33
34
 
35
+ s.add_development_dependency 'create_github_release', '~> 1.4'
34
36
  s.add_development_dependency 'minitar', '~> 0.9'
35
37
  s.add_development_dependency 'mocha', '~> 2.1'
36
38
  s.add_development_dependency 'rake', '~> 13.1'
data/lib/git/base.rb CHANGED
@@ -1,4 +1,3 @@
1
- require 'git/base/factory'
2
1
  require 'logger'
3
2
  require 'open3'
4
3
 
@@ -10,8 +9,6 @@ module Git
10
9
  # {Git.clone}, or {Git.bare}.
11
10
  #
12
11
  class Base
13
- include Git::Base::Factory
14
-
15
12
  # (see Git.bare)
16
13
  def self.bare(git_dir, options = {})
17
14
  normalize_paths(options, default_repository: git_dir, bare: true)
@@ -632,6 +629,96 @@ module Git
632
629
  self.lib.branch_current
633
630
  end
634
631
 
632
+ # @return [Git::Branch] an object for branch_name
633
+ def branch(branch_name = self.current_branch)
634
+ Git::Branch.new(self, branch_name)
635
+ end
636
+
637
+ # @return [Git::Branches] a collection of all the branches in the repository.
638
+ # Each branch is represented as a {Git::Branch}.
639
+ def branches
640
+ Git::Branches.new(self)
641
+ end
642
+
643
+ # returns a Git::Worktree object for dir, commitish
644
+ def worktree(dir, commitish = nil)
645
+ Git::Worktree.new(self, dir, commitish)
646
+ end
647
+
648
+ # returns a Git::worktrees object of all the Git::Worktrees
649
+ # objects for this repo
650
+ def worktrees
651
+ Git::Worktrees.new(self)
652
+ end
653
+
654
+ # @return [Git::Object::Commit] a commit object
655
+ def commit_tree(tree = nil, opts = {})
656
+ Git::Object::Commit.new(self, self.lib.commit_tree(tree, opts))
657
+ end
658
+
659
+ # @return [Git::Diff] a Git::Diff object
660
+ def diff(objectish = 'HEAD', obj2 = nil)
661
+ Git::Diff.new(self, objectish, obj2)
662
+ end
663
+
664
+ # @return [Git::Object] a Git object
665
+ def gblob(objectish)
666
+ Git::Object.new(self, objectish, 'blob')
667
+ end
668
+
669
+ # @return [Git::Object] a Git object
670
+ def gcommit(objectish)
671
+ Git::Object.new(self, objectish, 'commit')
672
+ end
673
+
674
+ # @return [Git::Object] a Git object
675
+ def gtree(objectish)
676
+ Git::Object.new(self, objectish, 'tree')
677
+ end
678
+
679
+ # @return [Git::Log] a log with the specified number of commits
680
+ def log(count = 30)
681
+ Git::Log.new(self, count)
682
+ end
683
+
684
+ # returns a Git::Object of the appropriate type
685
+ # you can also call @git.gtree('tree'), but that's
686
+ # just for readability. If you call @git.gtree('HEAD') it will
687
+ # still return a Git::Object::Commit object.
688
+ #
689
+ # object calls a method that will run a rev-parse
690
+ # on the objectish and determine the type of the object and return
691
+ # an appropriate object for that type
692
+ #
693
+ # @return [Git::Object] an instance of the appropriate type of Git::Object
694
+ def object(objectish)
695
+ Git::Object.new(self, objectish)
696
+ end
697
+
698
+ # @return [Git::Remote] a remote of the specified name
699
+ def remote(remote_name = 'origin')
700
+ Git::Remote.new(self, remote_name)
701
+ end
702
+
703
+ # @return [Git::Status] a status object
704
+ def status
705
+ Git::Status.new(self)
706
+ end
707
+
708
+ # @return [Git::Object::Tag] a tag object
709
+ def tag(tag_name)
710
+ Git::Object.new(self, tag_name, 'tag', true)
711
+ end
712
+
713
+ # Find as good common ancestors as possible for a merge
714
+ # example: g.merge_base('master', 'some_branch', 'some_sha', octopus: true)
715
+ #
716
+ # @return [Array<Git::Object::Commit>] a collection of common ancestors
717
+ def merge_base(*args)
718
+ shas = self.lib.merge_base(*args)
719
+ shas.map { |sha| gcommit(sha) }
720
+ end
721
+
635
722
  private
636
723
 
637
724
  # Normalize options before they are sent to Git::Base.new