git 1.5.0 → 1.8.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of git might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 86d44aad4d6c430e5e224d27ddfece08f6a5696c068dbe041df3bd740ae94d7a
4
- data.tar.gz: d7ac8d85b906620006cb5c1fc9206d6f406115490b88fedc7fb8aebe4a8302c9
3
+ metadata.gz: 4baf98bc2847ece4cb13a4f558b1654facb3c8add9ce58eebb024a139f880742
4
+ data.tar.gz: 9c1448896ab666dbe25c38484074fc81814a53fdb6b5e8eac599f58ebdde713b
5
5
  SHA512:
6
- metadata.gz: 19d5093d80ee3a4af8c6ceb27185464378a715330de92893cd81ece19a71986e29f7631c389b7204eb2bb4a47b0dcc8ce56f3a90164a6f2a22b696d53c6e8179
7
- data.tar.gz: 29895e438fec3de810e1b3f78bf2c177b04081a72fdfad72a3e231ee3737df23e6cbebb58678a81c9883bcbb05b29058bee9c4c6189dcdac21249e8ac5bd0959
6
+ metadata.gz: a71409e92d3c79d2c41c2dc693eb031dda63e1d50ddbfcc90c3fea04c30c25341d40a086934f4582f3207fba9a20240c1061ad79a007cdcae19969c9a662c341
7
+ data.tar.gz: 78c864391d9dcc90f238d78cd616e65c7ccc0fddd2ae7d0a206e31f5d5726d4945ceecdb201680c9630bc7123b88696b744ae8a5f0a9094f743ac0473106c4dc
@@ -0,0 +1,25 @@
1
+ # Probot: Stale
2
+ # https://github.com/probot/stale
3
+
4
+ # Number of days of inactivity before an issue becomes stale
5
+ daysUntilStale: 60
6
+
7
+ # Number of days of inactivity before a stale issue is closed
8
+ # Set to false to disable. If disabled, issues still need to be closed
9
+ # manually, but will remain marked as stale.
10
+ daysUntilClose: false
11
+
12
+ # Issues with these labels will never be considered stale
13
+ exemptLabels:
14
+ - pinned
15
+ - security
16
+
17
+ # Label to use when marking an issue as stale
18
+ staleLabel: stale
19
+
20
+ # Comment to post when marking an issue as stale. Set to `false` to disable
21
+ markComment: >
22
+ A friendly reminder that this issue had no activity for 60 days.
23
+
24
+ # Comment to post when closing a stale issue. Set to `false` to disable
25
+ closeComment: false
@@ -0,0 +1,42 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [master]
6
+ pull_request:
7
+ branches: [master]
8
+
9
+ jobs:
10
+ continuous_integration_build:
11
+ continue-on-error: true
12
+ strategy:
13
+ fail-fast: false
14
+ matrix:
15
+ ruby: [2.3, 2.7]
16
+ operating-system: [ubuntu-latest]
17
+ include:
18
+ - ruby: head
19
+ operating-system: ubuntu-latest
20
+ - ruby: truffleruby-head
21
+ operating-system: ubuntu-latest
22
+ - ruby: 2.7
23
+ operating-system: windows-latest
24
+ - ruby: jruby-head
25
+ operating-system: windows-latest
26
+
27
+ name: Ruby ${{ matrix.ruby }} on ${{ matrix.operating-system }}
28
+
29
+ runs-on: ${{ matrix.operating-system }}
30
+
31
+ steps:
32
+ - name: Checkout Code
33
+ uses: actions/checkout@v2
34
+
35
+ - name: Setup Ruby
36
+ uses: ruby/setup-ruby@v1
37
+ with:
38
+ ruby-version: ${{ matrix.ruby }}
39
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
40
+
41
+ - name: Run Build
42
+ run: bundle exec rake default
@@ -0,0 +1,10 @@
1
+ *.gem
2
+ *.kpf
3
+ *.sw?
4
+ .DS_Store
5
+ coverage
6
+ doc
7
+ .yardoc
8
+ pkg
9
+ rdoc
10
+ Gemfile.lock
@@ -0,0 +1,11 @@
1
+ --default-return=''
2
+ --hide-void-return
3
+ --markup-provider=redcarpet
4
+ --markup=markdown
5
+ --fail-on-warning
6
+ -
7
+ README.md
8
+ CHANGELOG.md
9
+ CONTRIBUTING.md
10
+ RELEASING.md
11
+ MAINTAINERS.md
@@ -1,5 +1,30 @@
1
+ <!--
2
+ # @markup markdown
3
+ # @title Change Log
4
+ -->
5
+
1
6
  # Change Log
2
7
 
8
+ ## 1.8.1
9
+
10
+ See https://github.com/ruby-git/ruby-git/releases/tag/v1.8.1
11
+
12
+ ## 1.8.0
13
+
14
+ See https://github.com/ruby-git/ruby-git/releases/tag/v1.8.0
15
+
16
+ ## 1.7.0
17
+
18
+ See https://github.com/ruby-git/ruby-git/releases/tag/v1.7.0
19
+
20
+ ## 1.6.0
21
+
22
+ See https://github.com/ruby-git/ruby-git/releases/tag/v1.6.0
23
+
24
+ ## 1.6.0.pre1
25
+
26
+ See https://github.com/ruby-git/ruby-git/releases/tag/v1.6.0.pre1
27
+
3
28
  ## 1.5.0
4
29
 
5
30
  See https://github.com/ruby-git/ruby-git/releases/tag/v1.5.0
@@ -1,68 +1,123 @@
1
+ <!--
2
+ # @markup markdown
3
+ # @title How To Contribute
4
+ -->
5
+
1
6
  # Contributing to ruby-git
2
7
 
3
- Thank you for your interest in contributing to this project.
8
+ Thank you for your interest in contributing to the ruby-git project.
9
+
10
+ This document gives the guidelines for contributing to the ruby-git project.
11
+ These guidelines may not fit every situation. When contributing use your best
12
+ judgement.
13
+
14
+ Propose changes to these guidelines with a pull request.
15
+
16
+ ## How to contribute
17
+
18
+ You can contribute in two ways:
19
+
20
+ 1. [Report an issue or make a feature request](#how-to-report-an-issue-or-make-a-feature-request)
21
+ 2. [Submit a code or documentation change](#how-to-submit-a-code-or-documentation-change)
22
+
23
+ ## How to report an issue or make a feature request
24
+
25
+ ruby-git utilizes [GitHub Issues](https://help.github.com/en/github/managing-your-work-on-github/about-issues)
26
+ for issue tracking and feature requests.
4
27
 
5
- These are mostly guidelines, not rules.
6
- Use your best judgment, and feel free to propose changes to this document in a pull request.
28
+ Report an issue or feature request by [creating a ruby-git Github issue](https://github.com/ruby-git/ruby-git/issues/new).
29
+ Fill in the template to describe the issue or feature request the best you can.
7
30
 
8
- #### Table Of Contents
31
+ ## How to submit a code or documentation change
9
32
 
10
- [How Can I Contribute?](#how-can-i-contribute)
11
- * [Submitting Issues](#submitting-issues)
12
- * [Contribution Process](#contribution-process)
13
- * [Pull Request Requirements](#pull-request-requirements)
14
- * [Code Review Process](#code-review-process)
15
- * [Developer Certification of Origin (DCO)](#developer-certification-of-origin-dco)
33
+ There is three step process for code or documentation changes:
16
34
 
35
+ 1. [Commit your changes to a fork of ruby-git](#commit-changes-to-a-fork-of-ruby-git)
36
+ 2. [Create a pull request](#create-a-pull-request)
37
+ 3. [Get your pull request reviewed](#get-your-pull-request-reviewed)
17
38
 
18
- ## How Can I Contribute?
39
+ ### Commit changes to a fork of ruby-git
19
40
 
20
- ### Submitting Issues
41
+ Make your changes in a fork of the ruby-git repository.
21
42
 
22
- We utilize **GitHub Issues** for issue tracking and contributions. You can contribute in two ways:
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.
23
46
 
24
- 1. Reporting an issue or making a feature request [here](https://github.com/ruby-git/ruby-git/issues/new).
25
- 2. Adding features or fixing bugs yourself and contributing your code to ruby-git.
47
+ ### Create a pull request
26
48
 
27
- ### Contribution Process
49
+ See [this article](https://help.github.com/articles/about-pull-requests/) if you
50
+ are not familiar with GitHub Pull Requests.
28
51
 
29
- We have a 3 step process for contributions:
52
+ Follow the instructions in the pull request template.
30
53
 
31
- 1. Commit changes to a git branch in your fork. Making sure to sign-off those changes for the [Developer Certificate of Origin](#developer-certification-of-origin-dco).
32
- 2. Create a GitHub Pull Request for your change, following the instructions in the pull request template.
33
- 3. Perform a [Code Review](#code-review-process) with the project maintainers on the pull request.
54
+ ### Get your pull request reviewed
34
55
 
35
- ### Pull Request Requirements
36
- In order to ensure high quality, we require that all pull requests to this project meet these specifications:
56
+ Code review takes place in a GitHub pull request using the [the Github pull request review feature](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/about-pull-request-reviews).
37
57
 
38
- 1. Unit Testing: We require all the new code to include unit tests, and any fixes to pass previous units.
39
- 2. Green CI Tests: We are using [Travis CI](https://travis-ci.org/ruby-git/ruby-git) to run unit tests on various ruby versions, we expect them to all pass before a pull request will be merged.
40
- 3. Up-to-date Documentation: New methods as well as updated methods should have [YARD](https://yardoc.org/) documentation added to them
58
+ Once your pull request is ready for review, request a review from at least one
59
+ [maintainer](MAINTAINERS.md) and any number of other contributors.
41
60
 
42
- ### Code Review Process
61
+ During the review process, you may need to make additional commits which would
62
+ need to be squashed. It may also be necessary to rebase to master again if other
63
+ changes are merged before your PR.
43
64
 
44
- Code review takes place in GitHub pull requests. See [this article](https://help.github.com/articles/about-pull-requests/) if you're not familiar with GitHub Pull Requests.
65
+ At least one approval is required from a project maintainer before your pull
66
+ request can be merged. The maintainer is responsible for ensuring that the pull
67
+ request meets [the project's coding standards](#coding-standards).
45
68
 
46
- Once you open a pull request, project maintainers will review your code and respond to your pull request with any feedback they might have.
69
+ ## Coding standards
47
70
 
48
- The process at this point is as follows:
71
+ In order to ensure high quality, all pull requests must meet these requirements:
49
72
 
50
- 1. One thumbs-up (:+1:) is required from project maintainers. See the master maintainers document for the ruby-git project at <https://github.com/ruby-git/ruby-git/blob/master/MAINTAINERS.md>.
51
- 2. When ready, your pull request will be merged into `master`, we may require you to rebase your PR to the latest `master`.
73
+ ### 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
52
78
 
53
- ### Developer Certification of Origin (DCO)
79
+ ### 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 test` is run from the
82
+ project's local working copy
54
83
 
55
- Licensing is very important to open source projects. It helps ensure the software continues to be available under the terms that the author desired.
84
+ ### Continuous Integration
85
+ * All tests must pass in the project's [Travis CI](https://travis-ci.org/ruby-git/ruby-git)
86
+ build before the pull request will be merged
56
87
 
57
- ruby-git uses [the MIT license](https://github.com/ruby-git/ruby-git/blob/master/LICENSE)
88
+ ### Documentation
89
+ * New and updated public methods must have [YARD](https://yardoc.org/)
90
+ documentation added to them
91
+ * New and updated public facing features should be documented in the project's
92
+ [README.md](README.md)
58
93
 
59
- Detail about the LICENSE can be found [here](https://choosealicense.com/licenses/mit/)
94
+ ### Licensing sign-off
95
+ * Each commit must contain [the DCO sign-off](#developer-certificate-of-origin-dco)
96
+ in the form: `Signed-off-by: Name <email>`
60
97
 
61
- To make a good faith effort to ensure these criteria are met, ruby-git requires the Developer Certificate of Origin (DCO) process to be followed.
98
+ ## Licensing
62
99
 
63
- The DCO is an attestation attached to every contribution made by every developer.
100
+ ruby-git uses [the MIT license](https://choosealicense.com/licenses/mit/) as
101
+ declared in the [LICENSE](LICENSE) file.
102
+
103
+ Licensing is very important to open source projects. It helps ensure the
104
+ software continues to be available under the terms that the author desired.
105
+
106
+ ### Developer Certificate of Origin (DCO)
107
+
108
+ This project requires that authors have permission to submit their contributions
109
+ under the MIT license. To make a good faith effort to ensure this, ruby-git
110
+ requires the [Developer Certificate of Origin (DCO)](https://elinux.org/Developer_Certificate_Of_Origin)
111
+ process be followed.
112
+
113
+ This process requires that each commit include a `Signed-off-by` line that
114
+ indicates the author accepts the DCO. Here is an example DCO sign-off line:
115
+
116
+ ```
117
+ Signed-off-by: John Doe <john.doe@hisdomain.com>
118
+ ```
64
119
 
65
- In the commit message of the contribution, the developer simply adds a Signed-off-by statement and thereby agrees to the DCO, which you can find below or at <http://developercertificate.org/>.
120
+ The full text of the DCO version 1.1 is below or at <http://developercertificate.org/>.
66
121
 
67
122
  ```
68
123
  Developer's Certificate of Origin 1.1
@@ -75,7 +130,7 @@ By making a contribution to this project, I certify that:
75
130
 
76
131
  (b) The contribution is based upon previous work that, to the
77
132
  best of my knowledge, is covered under an appropriate open
78
- source license and I have the right under that license to
133
+ source license and I have the right under that license to
79
134
  submit that work with modifications, whether created in whole
80
135
  or in part by me, under the same open source license (unless
81
136
  I am permitted to submit under a different license), as
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec :name => 'git'
4
+
@@ -0,0 +1,15 @@
1
+ ### Subject of the issue
2
+ Describe your issue here.
3
+
4
+ ### Your environment
5
+ * version of git and ruby-git
6
+ * version of ruby
7
+
8
+ ### Steps to reproduce
9
+ Tell us how to reproduce this issue.
10
+
11
+ ### Expected behaviour
12
+ What did you expect to happen?
13
+
14
+ ### Actual behaviour
15
+ What actually happened?
@@ -1,8 +1,14 @@
1
+ <!--
2
+ # @markup markdown
3
+ # @title Maintainers
4
+ -->
5
+
1
6
  # Maintainers
2
7
 
3
- When making changes to the system, this file tells you who needs to review your patch - you need at least two maintainers to provide a :+1: on your pull request.
8
+ When making changes in this repository, one of the maintainers below must review and approve your pull request.
4
9
 
5
10
  ### Maintainers
6
11
 
7
12
  * [Per Lundberg](https://github.com/perlun)
8
- * [Vern Burton](https://github.com/tarcinil)
13
+ * [Vern Burton](https://github.com/tarcinil)
14
+ * [James Couball](https://github.com/jcouball)
@@ -0,0 +1,9 @@
1
+ ### Your checklist for this pull request
2
+ 🚨Please review the [guidelines for contributing](https://github.com/ruby-git/ruby-git/blob/master/CONTRIBUTING.md) to this repository.
3
+
4
+ - [ ] Ensure all commits include DCO sign-off.
5
+ - [ ] Ensure that your contributions pass unit testing.
6
+ - [ ] Ensure that your contributions contain documentation if applicable.
7
+
8
+ ### Description
9
+ Please describe your pull request.
data/README.md CHANGED
@@ -1,24 +1,49 @@
1
- # Git Library for Ruby
1
+ <!--
2
+ # @markup markdown
3
+ # @title README
4
+ -->
2
5
 
3
- Library for using Git in Ruby.
6
+ # The Git Gem
7
+
8
+ The Git Gem provides an API that can be used to create, read, and manipulate
9
+ Git repositories by wrapping system calls to the `git` binary. The API can be
10
+ used for working with Git in complex interactions including branching and
11
+ merging, object inspection and manipulation, history, patch generation and
12
+ more.
4
13
 
5
14
  ## Homepage
6
15
 
7
- Git public hosting of the project source code is at:
16
+ The project source code is at:
8
17
 
9
18
  http://github.com/ruby-git/ruby-git
10
19
 
20
+ ## Documentation
21
+
22
+ Detailed documentation can be found at:
23
+
24
+ https://rubydoc.info/gems/git/Git.html
25
+
26
+ Get started by obtaining a repository object by:
27
+
28
+ * opening an existing working copy with [Git.open](https://rubydoc.info/gems/git/Git#open-class_method)
29
+ * initializing a new repository with [Git.init](https://rubydoc.info/gems/git/Git#init-class_method)
30
+ * cloning a repository with [Git.clone](https://rubydoc.info/gems/git/Git#clone-class_method)
31
+
32
+ Methods that can be called on a repository object are documented in [Git::Base](https://rubydoc.info/gems/git/Git/Base)
33
+
11
34
  ## Install
12
35
 
13
36
  You can install Ruby/Git like this:
14
37
 
15
- $ sudo gem install git
38
+ ```
39
+ sudo gem install git
40
+ ```
16
41
 
17
42
  ## Code Status
18
43
 
19
- * [![Build Status](https://travis-ci.org/ruby-git/ruby-git.svg?branch=master)](https://travis-ci.org/ruby-git/ruby-git)
44
+ * [![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)
20
45
  * [![Code Climate](https://codeclimate.com/github/ruby-git/ruby-git.png)](https://codeclimate.com/github/ruby-git/ruby-git)
21
- * [![Gem Version](https://badge.fury.io/rb/git.png)](http://badge.fury.io/rb/git)
46
+ * [![Gem Version](https://badge.fury.io/rb/git.svg)](https://badge.fury.io/rb/git)
22
47
 
23
48
  ## Major Objects
24
49
 
@@ -41,6 +66,8 @@ like:
41
66
 
42
67
  `@git.log(20).object("some_file").since("2 weeks ago").between('v2.6', 'v2.7').each { |commit| [block] }`
43
68
 
69
+ **Git::Worktrees** - Enumerable object that holds `Git::Worktree objects`.
70
+
44
71
  ## Examples
45
72
 
46
73
  Here are a bunch of examples of how to use the Ruby/Git package.
@@ -48,249 +75,268 @@ Here are a bunch of examples of how to use the Ruby/Git package.
48
75
  Ruby < 1.9 will require rubygems to be loaded.
49
76
 
50
77
  ```ruby
51
- require 'rubygems'
78
+ require 'rubygems'
52
79
  ```
53
80
 
54
81
  Require the 'git' gem.
55
82
  ```ruby
56
- require 'git'
83
+ require 'git'
57
84
  ```
58
85
 
59
86
  Git env config
60
87
 
61
88
  ```ruby
62
- Git.configure do |config|
63
- # If you want to use a custom git binary
64
- config.binary_path = '/git/bin/path'
65
-
66
- # If you need to use a custom SSH script
67
- config.git_ssh = '/path/to/ssh/script'
68
- end
89
+ Git.configure do |config|
90
+ # If you want to use a custom git binary
91
+ config.binary_path = '/git/bin/path'
69
92
 
93
+ # If you need to use a custom SSH script
94
+ config.git_ssh = '/path/to/ssh/script'
95
+ end
70
96
  ```
71
97
 
98
+ _NOTE: Another way to specify where is the `git` binary is through the environment variable `GIT_PATH`_
72
99
 
73
100
  Here are the operations that need read permission only.
74
101
 
75
102
  ```ruby
76
- g = Git.open(working_dir, :log => Logger.new(STDOUT))
77
-
78
- g.index
79
- g.index.readable?
80
- g.index.writable?
81
- g.repo
82
- g.dir
83
-
84
- g.log # returns array of Git::Commit objects
85
- g.log.since('2 weeks ago')
86
- g.log.between('v2.5', 'v2.6')
87
- g.log.each {|l| puts l.sha }
88
- g.gblob('v2.5:Makefile').log.since('2 weeks ago')
89
-
90
- g.object('HEAD^').to_s # git show / git rev-parse
91
- g.object('HEAD^').contents
92
- g.object('v2.5:Makefile').size
93
- g.object('v2.5:Makefile').sha
94
-
95
- g.gtree(treeish)
96
- g.gblob(treeish)
97
- g.gcommit(treeish)
98
-
99
-
100
- commit = g.gcommit('1cc8667014381')
101
-
102
- commit.gtree
103
- commit.parent.sha
104
- commit.parents.size
105
- commit.author.name
106
- commit.author.email
107
- commit.author.date.strftime("%m-%d-%y")
108
- commit.committer.name
109
- commit.date.strftime("%m-%d-%y")
110
- commit.message
111
-
112
- tree = g.gtree("HEAD^{tree}")
113
-
114
- tree.blobs
115
- tree.subtrees
116
- tree.children # blobs and subtrees
117
-
118
- g.revparse('v2.5:Makefile')
119
-
120
- g.branches # returns Git::Branch objects
121
- g.branches.local
122
- g.branches.remote
123
- g.branches[:master].gcommit
124
- g.branches['origin/master'].gcommit
125
-
126
- g.grep('hello') # implies HEAD
127
- g.blob('v2.5:Makefile').grep('hello')
128
- g.tag('v2.5').grep('hello', 'docs/')
129
- g.describe()
130
- g.describe('0djf2aa')
131
- g.describe('HEAD', {:all => true, :tags => true})
132
-
133
- g.diff(commit1, commit2).size
134
- g.diff(commit1, commit2).stats
135
- g.diff(commit1, commit2).name_status
136
- g.gtree('v2.5').diff('v2.6').insertions
137
- g.diff('gitsearch1', 'v2.5').path('lib/')
138
- g.diff('gitsearch1', @git.gtree('v2.5'))
139
- g.diff('gitsearch1', 'v2.5').path('docs/').patch
140
- g.gtree('v2.5').diff('v2.6').patch
141
-
142
- g.gtree('v2.5').diff('v2.6').each do |file_diff|
143
- puts file_diff.path
144
- puts file_diff.patch
145
- puts file_diff.blob(:src).contents
146
- end
147
-
148
- g.config('user.name') # returns 'Scott Chacon'
149
- g.config # returns whole config hash
150
-
151
- g.tags # returns array of Git::Tag objects
152
-
153
- g.show()
154
- g.show('HEAD')
155
- g.show('v2.8', 'README.md')
156
-
157
- Git.ls_remote('https://github.com/ruby-git/ruby-git.git') # returns a hash containing the available references of the repo.
158
- Git.ls_remote('/path/to/local/repo')
159
- Git.ls_remote() # same as Git.ls_remote('.')
160
-
103
+ g = Git.open(working_dir, :log => Logger.new(STDOUT))
104
+
105
+ g.index
106
+ g.index.readable?
107
+ g.index.writable?
108
+ g.repo
109
+ g.dir
110
+
111
+ g.log # returns array of Git::Commit objects
112
+ g.log.since('2 weeks ago')
113
+ g.log.between('v2.5', 'v2.6')
114
+ g.log.each {|l| puts l.sha }
115
+ g.gblob('v2.5:Makefile').log.since('2 weeks ago')
116
+
117
+ g.object('HEAD^').to_s # git show / git rev-parse
118
+ g.object('HEAD^').contents
119
+ g.object('v2.5:Makefile').size
120
+ g.object('v2.5:Makefile').sha
121
+
122
+ g.gtree(treeish)
123
+ g.gblob(treeish)
124
+ g.gcommit(treeish)
125
+
126
+
127
+ commit = g.gcommit('1cc8667014381')
128
+
129
+ commit.gtree
130
+ commit.parent.sha
131
+ commit.parents.size
132
+ commit.author.name
133
+ commit.author.email
134
+ commit.author.date.strftime("%m-%d-%y")
135
+ commit.committer.name
136
+ commit.date.strftime("%m-%d-%y")
137
+ commit.message
138
+
139
+ tree = g.gtree("HEAD^{tree}")
140
+
141
+ tree.blobs
142
+ tree.subtrees
143
+ tree.children # blobs and subtrees
144
+
145
+ g.revparse('v2.5:Makefile')
146
+
147
+ g.branches # returns Git::Branch objects
148
+ g.branches.local
149
+ g.branches.remote
150
+ g.branches[:master].gcommit
151
+ g.branches['origin/master'].gcommit
152
+
153
+ g.grep('hello') # implies HEAD
154
+ g.blob('v2.5:Makefile').grep('hello')
155
+ g.tag('v2.5').grep('hello', 'docs/')
156
+ g.describe()
157
+ g.describe('0djf2aa')
158
+ g.describe('HEAD', {:all => true, :tags => true})
159
+
160
+ g.diff(commit1, commit2).size
161
+ g.diff(commit1, commit2).stats
162
+ g.diff(commit1, commit2).name_status
163
+ g.gtree('v2.5').diff('v2.6').insertions
164
+ g.diff('gitsearch1', 'v2.5').path('lib/')
165
+ g.diff('gitsearch1', @git.gtree('v2.5'))
166
+ g.diff('gitsearch1', 'v2.5').path('docs/').patch
167
+ g.gtree('v2.5').diff('v2.6').patch
168
+
169
+ g.gtree('v2.5').diff('v2.6').each do |file_diff|
170
+ puts file_diff.path
171
+ puts file_diff.patch
172
+ puts file_diff.blob(:src).contents
173
+ end
174
+
175
+ g.worktrees # returns Git::Worktree objects
176
+ g.worktrees.count
177
+ g.worktrees.each do |worktree|
178
+ worktree.dir
179
+ worktree.gcommit
180
+ worktree.to_s
181
+ end
182
+
183
+ g.config('user.name') # returns 'Scott Chacon'
184
+ g.config # returns whole config hash
185
+
186
+ g.tags # returns array of Git::Tag objects
187
+
188
+ g.show()
189
+ g.show('HEAD')
190
+ g.show('v2.8', 'README.md')
191
+
192
+ Git.ls_remote('https://github.com/ruby-git/ruby-git.git') # returns a hash containing the available references of the repo.
193
+ Git.ls_remote('/path/to/local/repo')
194
+ Git.ls_remote() # same as Git.ls_remote('.')
161
195
  ```
162
196
 
163
197
  And here are the operations that will need to write to your git repository.
164
198
 
165
199
  ```ruby
166
- g = Git.init
167
- Git.init('project')
168
- Git.init('/home/schacon/proj',
169
- { :repository => '/opt/git/proj.git',
170
- :index => '/tmp/index'} )
171
-
172
- g = Git.clone(URI, NAME, :path => '/tmp/checkout')
173
- g.config('user.name', 'Scott Chacon')
174
- g.config('user.email', 'email@email.com')
175
-
176
- g.add # git add -- "."
177
- g.add(:all=>true) # git add --all -- "."
178
- g.add('file_path') # git add -- "file_path"
179
- g.add(['file_path_1', 'file_path_2']) # git add -- "file_path_1" "file_path_2"
180
-
181
- g.remove() # git rm -f -- "."
182
- g.remove('file.txt') # git rm -f -- "file.txt"
183
- g.remove(['file.txt', 'file2.txt']) # git rm -f -- "file.txt" "file2.txt"
184
- g.remove('file.txt', :recursive => true) # git rm -f -r -- "file.txt"
185
- g.remove('file.txt', :cached => true) # git rm -f --cached -- "file.txt"
186
-
187
- g.commit('message')
188
- g.commit_all('message')
189
-
190
- g = Git.clone(repo, 'myrepo')
191
- g.chdir do
192
- new_file('test-file', 'blahblahblah')
193
- g.status.changed.each do |file|
194
- puts file.blob(:index).contents
195
- end
196
- end
197
-
198
- g.reset # defaults to HEAD
199
- g.reset_hard(Git::Commit)
200
-
201
- g.branch('new_branch') # creates new or fetches existing
202
- g.branch('new_branch').checkout
203
- g.branch('new_branch').delete
204
- g.branch('existing_branch').checkout
205
- g.branch('master').contains?('existing_branch')
206
-
207
- g.checkout('new_branch')
208
- g.checkout(g.branch('new_branch'))
209
-
210
- g.branch(name).merge(branch2)
211
- g.branch(branch2).merge # merges HEAD with branch2
212
-
213
- g.branch(name).in_branch(message) { # add files } # auto-commits
214
- g.merge('new_branch')
215
- g.merge('origin/remote_branch')
216
- g.merge(g.branch('master'))
217
- g.merge([branch1, branch2])
218
-
219
- r = g.add_remote(name, uri) # Git::Remote
220
- r = g.add_remote(name, Git::Base) # Git::Remote
221
-
222
- g.remotes # array of Git::Remotes
223
- g.remote(name).fetch
224
- g.remote(name).remove
225
- g.remote(name).merge
226
- g.remote(name).merge(branch)
227
-
228
- g.fetch
229
- g.fetch(g.remotes.first)
230
- g.fetch('origin', {:ref => 'some/ref/head'} )
231
-
232
- g.pull
233
- g.pull(Git::Repo, Git::Branch) # fetch and a merge
234
-
235
- g.add_tag('tag_name') # returns Git::Tag
236
- g.add_tag('tag_name', 'object_reference')
237
- g.add_tag('tag_name', 'object_reference', {:options => 'here'})
238
- g.add_tag('tag_name', {:options => 'here'})
239
-
240
- Options:
241
- :a | :annotate
242
- :d
243
- :f
244
- :m | :message
245
- :s
246
-
247
- g.delete_tag('tag_name')
248
-
249
- g.repack
250
-
251
- g.push
252
- g.push(g.remote('name'))
200
+ g = Git.init
201
+ Git.init('project')
202
+ Git.init('/home/schacon/proj',
203
+ { :repository => '/opt/git/proj.git',
204
+ :index => '/tmp/index'} )
205
+
206
+ g = Git.clone(URI, NAME, :path => '/tmp/checkout')
207
+ g.config('user.name', 'Scott Chacon')
208
+ g.config('user.email', 'email@email.com')
209
+
210
+ # Clone can take an optional logger
211
+ logger = Logger.new
212
+ g = Git.clone(URI, NAME, :log => logger)
213
+
214
+ g.add # git add -- "."
215
+ g.add(:all=>true) # git add --all -- "."
216
+ g.add('file_path') # git add -- "file_path"
217
+ g.add(['file_path_1', 'file_path_2']) # git add -- "file_path_1" "file_path_2"
218
+
219
+ g.remove() # git rm -f -- "."
220
+ g.remove('file.txt') # git rm -f -- "file.txt"
221
+ g.remove(['file.txt', 'file2.txt']) # git rm -f -- "file.txt" "file2.txt"
222
+ g.remove('file.txt', :recursive => true) # git rm -f -r -- "file.txt"
223
+ g.remove('file.txt', :cached => true) # git rm -f --cached -- "file.txt"
224
+
225
+ g.commit('message')
226
+ g.commit_all('message')
227
+
228
+ g = Git.clone(repo, 'myrepo')
229
+ g.chdir do
230
+ new_file('test-file', 'blahblahblah')
231
+ g.status.changed.each do |file|
232
+ puts file.blob(:index).contents
233
+ end
234
+ end
235
+
236
+ g.reset # defaults to HEAD
237
+ g.reset_hard(Git::Commit)
238
+
239
+ g.branch('new_branch') # creates new or fetches existing
240
+ g.branch('new_branch').checkout
241
+ g.branch('new_branch').delete
242
+ g.branch('existing_branch').checkout
243
+ g.branch('master').contains?('existing_branch')
244
+
245
+ g.checkout('new_branch')
246
+ g.checkout(g.branch('new_branch'))
247
+
248
+ g.branch(name).merge(branch2)
249
+ g.branch(branch2).merge # merges HEAD with branch2
250
+
251
+ g.branch(name).in_branch(message) { # add files } # auto-commits
252
+ g.merge('new_branch')
253
+ g.merge('new_branch', 'merge commit message', no_ff: true)
254
+ g.merge('origin/remote_branch')
255
+ g.merge(g.branch('master'))
256
+ g.merge([branch1, branch2])
257
+
258
+ g.merge_base('branch1', 'branch2')
259
+
260
+ r = g.add_remote(name, uri) # Git::Remote
261
+ r = g.add_remote(name, Git::Base) # Git::Remote
262
+
263
+ g.remotes # array of Git::Remotes
264
+ g.remote(name).fetch
265
+ g.remote(name).remove
266
+ g.remote(name).merge
267
+ g.remote(name).merge(branch)
268
+
269
+ g.fetch
270
+ g.fetch(g.remotes.first)
271
+ g.fetch('origin', {:ref => 'some/ref/head'} )
272
+
273
+ g.pull
274
+ g.pull(Git::Repo, Git::Branch) # fetch and a merge
275
+
276
+ g.add_tag('tag_name') # returns Git::Tag
277
+ g.add_tag('tag_name', 'object_reference')
278
+ g.add_tag('tag_name', 'object_reference', {:options => 'here'})
279
+ g.add_tag('tag_name', {:options => 'here'})
280
+
281
+ Options:
282
+ :a | :annotate
283
+ :d
284
+ :f
285
+ :m | :message
286
+ :s
287
+
288
+ g.delete_tag('tag_name')
289
+
290
+ g.repack
291
+
292
+ g.push
293
+ g.push(g.remote('name'))
294
+
295
+ g.worktree('/tmp/new_worktree').add
296
+ g.worktree('/tmp/new_worktree', 'branch1').add
297
+ g.worktree('/tmp/new_worktree').remove
298
+ g.worktrees.prune
253
299
  ```
254
300
 
255
301
  Some examples of more low-level index and tree operations
256
302
 
257
303
  ```ruby
258
- g.with_temp_index do
304
+ g.with_temp_index do
259
305
 
260
- g.read_tree(tree3) # calls self.index.read_tree
261
- g.read_tree(tree1, :prefix => 'hi/')
306
+ g.read_tree(tree3) # calls self.index.read_tree
307
+ g.read_tree(tree1, :prefix => 'hi/')
262
308
 
263
- c = g.commit_tree('message')
264
- # or #
265
- t = g.write_tree
266
- c = g.commit_tree(t, :message => 'message', :parents => [sha1, sha2])
309
+ c = g.commit_tree('message')
310
+ # or #
311
+ t = g.write_tree
312
+ c = g.commit_tree(t, :message => 'message', :parents => [sha1, sha2])
267
313
 
268
- g.branch('branch_name').update_ref(c)
269
- g.update_ref(branch, c)
314
+ g.branch('branch_name').update_ref(c)
315
+ g.update_ref(branch, c)
270
316
 
271
- g.with_temp_working do # new blank working directory
272
- g.checkout
273
- g.checkout(another_index)
274
- g.commit # commits to temp_index
275
- end
276
- end
317
+ g.with_temp_working do # new blank working directory
318
+ g.checkout
319
+ g.checkout(another_index)
320
+ g.commit # commits to temp_index
321
+ end
322
+ end
277
323
 
278
- g.set_index('/path/to/index')
324
+ g.set_index('/path/to/index')
279
325
 
280
326
 
281
- g.with_index(path) do
282
- # calls set_index, then switches back after
283
- end
327
+ g.with_index(path) do
328
+ # calls set_index, then switches back after
329
+ end
284
330
 
285
- g.with_working(dir) do
286
- # calls set_working, then switches back after
287
- end
331
+ g.with_working(dir) do
332
+ # calls set_working, then switches back after
333
+ end
288
334
 
289
- g.with_temp_working(dir) do
290
- g.checkout_index(:prefix => dir, :path_limiter => path)
291
- # do file work
292
- g.commit # commits to index
293
- end
335
+ g.with_temp_working(dir) do
336
+ g.checkout_index(:prefix => dir, :path_limiter => path)
337
+ # do file work
338
+ g.commit # commits to index
339
+ end
294
340
  ```
295
341
 
296
342
  ## License