git-glimmer 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGELOG.md +106 -0
- data/CONTRIBUTING.md +144 -0
- data/LICENSE +21 -0
- data/MAINTAINERS.md +9 -0
- data/README.md +300 -0
- data/lib/git-glimmer.rb +1 -0
- data/lib/git.rb +167 -0
- data/lib/git/author.rb +14 -0
- data/lib/git/base.rb +551 -0
- data/lib/git/base/factory.rb +83 -0
- data/lib/git/branch.rb +126 -0
- data/lib/git/branches.rb +71 -0
- data/lib/git/config.rb +22 -0
- data/lib/git/diff.rb +154 -0
- data/lib/git/index.rb +5 -0
- data/lib/git/lib.rb +1091 -0
- data/lib/git/log.rb +128 -0
- data/lib/git/object.rb +312 -0
- data/lib/git/path.rb +31 -0
- data/lib/git/remote.rb +36 -0
- data/lib/git/repository.rb +6 -0
- data/lib/git/stash.rb +27 -0
- data/lib/git/stashes.rb +55 -0
- data/lib/git/status.rb +199 -0
- data/lib/git/version.rb +5 -0
- data/lib/git/working_directory.rb +4 -0
- metadata +133 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 4ede8893df1335bae755f81a3d3637cdd1b4802c803a2efc9d148b4211d4bad6
|
4
|
+
data.tar.gz: 8755d505a35644ff248a299d72ba1c536f30b23faa7d7c1e85cfdd649d4a45a5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 682c4a18dda7cd06ba998ae30d53079143b140c10f31bb4903601a98c1bc4f3c9269cc7000211fb53686286ac369b0581c4a74cb32a59f7c106a441f00a143a9
|
7
|
+
data.tar.gz: 621d1b65aeae923a9080e01910da618b8b76c93e8fa7aadce8bc35821d65484c26c7569e4d61010aa49bc1baf7912c259079c7a5c9bfbc098900b3cc4d462506
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
# Change Log
|
2
|
+
|
3
|
+
## 1.7.0
|
4
|
+
|
5
|
+
See https://github.com/ruby-git/ruby-git/releases/tag/v1.7.0
|
6
|
+
|
7
|
+
## 1.6.0
|
8
|
+
|
9
|
+
See https://github.com/ruby-git/ruby-git/releases/tag/v1.6.0
|
10
|
+
|
11
|
+
## 1.6.0.pre1
|
12
|
+
|
13
|
+
See https://github.com/ruby-git/ruby-git/releases/tag/v1.6.0.pre1
|
14
|
+
|
15
|
+
## 1.5.0
|
16
|
+
|
17
|
+
See https://github.com/ruby-git/ruby-git/releases/tag/v1.5.0
|
18
|
+
|
19
|
+
## 1.4.0
|
20
|
+
|
21
|
+
See https://github.com/ruby-git/ruby-git/releases/tag/v1.4.0
|
22
|
+
|
23
|
+
## 1.3.0
|
24
|
+
|
25
|
+
* Dropping Ruby 1.8.x support
|
26
|
+
|
27
|
+
## 1.2.10
|
28
|
+
|
29
|
+
* Adding Git::Diff.name_status
|
30
|
+
* Checking and fixing encoding on commands output to prevent encoding errors afterwards
|
31
|
+
|
32
|
+
## 1.2.9
|
33
|
+
|
34
|
+
* Adding Git.configure (to configure the git env)
|
35
|
+
* Adding Git.ls_remote [Git.ls_remote(repo_path_or_url='.')]
|
36
|
+
* Adding Git.describe [repo.describe(objectish, opts)]
|
37
|
+
* Adding Git.show [repo.show(objectish=nil, path=nil)]
|
38
|
+
* Fixing Git::Diff to support default references (implicit references)
|
39
|
+
* Fixing Git::Diff to support diff over git .patch files
|
40
|
+
* Fixing Git.checkout when using :new_branch opt
|
41
|
+
* Fixing Git::Object::Commit to preserve its sha after fetching metadata
|
42
|
+
* Fixing Git.is_remote_branch? to actually check against remote branches
|
43
|
+
* Improvements over how ENV variables are modified
|
44
|
+
* Improving thrade safety (using --git-dir and --work-tree git opts)
|
45
|
+
* Improving Git::Object::Tag. Adding annotated?, tagger and message
|
46
|
+
* Supporting a submodule path as a valid repo
|
47
|
+
* Git.checkout - supporting -f and -b
|
48
|
+
* Git.clone - supporting --branch
|
49
|
+
* Git.fetch - supporting --prune
|
50
|
+
* Git.tag - supporting
|
51
|
+
|
52
|
+
## 1.2.8
|
53
|
+
|
54
|
+
* Keeping the old escape format for windows users
|
55
|
+
* revparse: Supporting ref names containing SHA like substrings (40-hex strings)
|
56
|
+
* Fix warnings on Ruby 2.1.2
|
57
|
+
|
58
|
+
## 1.2.7
|
59
|
+
|
60
|
+
* Fixing mesages encoding
|
61
|
+
* Fixing -f flag in git push
|
62
|
+
* Fixing log parser for multiline messages
|
63
|
+
* Supporting object references on Git.add_tag
|
64
|
+
* Including dotfiles on Git.status
|
65
|
+
* Git.fetch - supporting --tags
|
66
|
+
* Git.clean - supporting -x
|
67
|
+
* Git.add_tag options - supporting -a, -m and -s
|
68
|
+
* Added Git.delete_tag
|
69
|
+
|
70
|
+
## 1.2.6
|
71
|
+
|
72
|
+
* Ruby 1.9.X/2.0 fully supported
|
73
|
+
* JRuby 1.8/1.9 support
|
74
|
+
* Rubinius support
|
75
|
+
* Git.clone - supporting --recursive and --config
|
76
|
+
* Git.log - supporting last and [] over the results
|
77
|
+
* Git.add_remote - supporting -f and -t
|
78
|
+
* Git.add - supporting --fore
|
79
|
+
* Git.init - supporting --bare
|
80
|
+
* Git.commit - supporting --all and --amend
|
81
|
+
* Added Git.remote_remote, Git.revert and Git.clean
|
82
|
+
* Added Bundler to the formula
|
83
|
+
* Travis configuration
|
84
|
+
* Licence included with the gem
|
85
|
+
|
86
|
+
## 1.0.4
|
87
|
+
|
88
|
+
* added camping/gitweb.rb frontend
|
89
|
+
* added a number of speed-ups
|
90
|
+
|
91
|
+
## 1.0.3
|
92
|
+
|
93
|
+
* Sped up most of the operations
|
94
|
+
* Added some predicate functions (commit?, tree?, etc)
|
95
|
+
* Added a number of lower level operations (read-tree, write-tree, checkout-index, etc)
|
96
|
+
* Fixed a bug with using bare repositories
|
97
|
+
* Updated a good amount of the documentation
|
98
|
+
|
99
|
+
## 1.0.2
|
100
|
+
|
101
|
+
* Added methods to the git objects that might be helpful
|
102
|
+
|
103
|
+
## 1.0.1
|
104
|
+
|
105
|
+
* Initial version
|
106
|
+
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,144 @@
|
|
1
|
+
# Contributing to ruby-git
|
2
|
+
|
3
|
+
Thank you for your interest in contributing to the ruby-git project.
|
4
|
+
|
5
|
+
This document gives the guidelines for contributing to the ruby-git project.
|
6
|
+
These guidelines may not fit every situation. When contributing use your best
|
7
|
+
judgement.
|
8
|
+
|
9
|
+
Propose changes to these guidelines with a pull request.
|
10
|
+
|
11
|
+
## How to contribute to ruby-git
|
12
|
+
|
13
|
+
You can contribute in two ways:
|
14
|
+
|
15
|
+
1. [Report an issue or make a feature request](#how-to-report-an-issue-or-make-a-feature-request)
|
16
|
+
2. [Submit a code or documentation change](#how-to-submit-a-code-or-documentation-change)
|
17
|
+
|
18
|
+
## How to report an issue or make a feature request
|
19
|
+
|
20
|
+
ruby-git utilizes [GitHub Issues](https://help.github.com/en/github/managing-your-work-on-github/about-issues)
|
21
|
+
for issue tracking and feature requests.
|
22
|
+
|
23
|
+
Report an issue or feature request by [creating a ruby-git Github issue](https://github.com/ruby-git/ruby-git/issues/new).
|
24
|
+
Fill in the template to describe the issue or feature request the best you can.
|
25
|
+
|
26
|
+
## How to submit a code or documentation change
|
27
|
+
|
28
|
+
There is three step process for code or documentation changes:
|
29
|
+
|
30
|
+
1. [Commit your changes to a fork of ruby-git](#commit-changes-to-a-fork-of-ruby-git)
|
31
|
+
2. [Create a pull request](#create-a-pull-request)
|
32
|
+
3. [Get your pull request reviewed](#get-your-pull-request-reviewed)
|
33
|
+
|
34
|
+
### Commit changes to a fork of ruby-git
|
35
|
+
|
36
|
+
Make your changes in a fork of the ruby-git repository.
|
37
|
+
|
38
|
+
Each commit must include a [DCO sign-off](#developer-certificate-of-origin-dco)
|
39
|
+
by adding the line `Signed-off-by: Name <email>` to the end of the commit
|
40
|
+
message.
|
41
|
+
|
42
|
+
### Create a pull request
|
43
|
+
|
44
|
+
See [this article](https://help.github.com/articles/about-pull-requests/) if you
|
45
|
+
are not familiar with GitHub Pull Requests.
|
46
|
+
|
47
|
+
Follow the instructions in the pull request template.
|
48
|
+
|
49
|
+
### Get your pull request reviewed
|
50
|
+
|
51
|
+
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).
|
52
|
+
|
53
|
+
Once your pull request is ready for review, request a review from at least one
|
54
|
+
[maintainer](MAINTAINERS.md) and any number of other contributors.
|
55
|
+
|
56
|
+
During the review process, you may need to make additional commits which would
|
57
|
+
need to be squashed. It may also be necessary to rebase to master again if other
|
58
|
+
changes are merged before your PR.
|
59
|
+
|
60
|
+
At least one approval is required from a project maintainer before your pull
|
61
|
+
request can be merged. The maintainer is responsible for ensuring that the pull
|
62
|
+
request meets [the project's coding standards](#coding-standards).
|
63
|
+
|
64
|
+
## Coding standards
|
65
|
+
|
66
|
+
In order to ensure high quality, all pull requests must meet these requirements:
|
67
|
+
|
68
|
+
### 1 PR = 1 Commit
|
69
|
+
* All commits for a PR must be squashed into one commit
|
70
|
+
* 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)
|
71
|
+
* The easiest way to ensure a fast forward merge is to rebase your local branch
|
72
|
+
to the ruby-git master branch
|
73
|
+
|
74
|
+
### Unit tests
|
75
|
+
* All changes must be accompanied by new or modified unit tests
|
76
|
+
* The entire test suite must pass when `bundle exec rake test` is run from the
|
77
|
+
project's local working copy
|
78
|
+
|
79
|
+
### Continuous Integration
|
80
|
+
* All tests must pass in the project's [Travis CI](https://travis-ci.org/ruby-git/ruby-git)
|
81
|
+
build before the pull request will be merged
|
82
|
+
|
83
|
+
### Documentation
|
84
|
+
* New and updated public methods must have [YARD](https://yardoc.org/)
|
85
|
+
documentation added to them
|
86
|
+
* New and updated public facing features should be documented in the project's
|
87
|
+
[README.md](README.md)
|
88
|
+
|
89
|
+
### Licensing sign-off
|
90
|
+
* Each commit must contain [the DCO sign-off](#developer-certificate-of-origin-dco)
|
91
|
+
in the form: `Signed-off-by: Name <email>`
|
92
|
+
|
93
|
+
## Licensing
|
94
|
+
|
95
|
+
ruby-git uses [the MIT license](https://choosealicense.com/licenses/mit/) as
|
96
|
+
declared in the [LICENSE](LICENSE) file.
|
97
|
+
|
98
|
+
Licensing is very important to open source projects. It helps ensure the
|
99
|
+
software continues to be available under the terms that the author desired.
|
100
|
+
|
101
|
+
### Developer Certificate of Origin (DCO)
|
102
|
+
|
103
|
+
This project requires that authors have permission to submit their contributions
|
104
|
+
under the MIT license. To make a good faith effort to ensure this, ruby-git
|
105
|
+
requires the [Developer Certificate of Origin (DCO)](https://elinux.org/Developer_Certificate_Of_Origin)
|
106
|
+
process be followed.
|
107
|
+
|
108
|
+
This process requires that each commit include a `Signed-off-by` line that
|
109
|
+
indicates the author accepts the DCO. Here is an example DCO sign-off line:
|
110
|
+
|
111
|
+
```
|
112
|
+
Signed-off-by: John Doe <john.doe@hisdomain.com>
|
113
|
+
```
|
114
|
+
|
115
|
+
The full text of the DCO version 1.1 is below or at <http://developercertificate.org/>.
|
116
|
+
|
117
|
+
```
|
118
|
+
Developer's Certificate of Origin 1.1
|
119
|
+
|
120
|
+
By making a contribution to this project, I certify that:
|
121
|
+
|
122
|
+
(a) The contribution was created in whole or in part by me and I
|
123
|
+
have the right to submit it under the open source license
|
124
|
+
indicated in the file; or
|
125
|
+
|
126
|
+
(b) The contribution is based upon previous work that, to the
|
127
|
+
best of my knowledge, is covered under an appropriate open
|
128
|
+
source license and I have the right under that license to
|
129
|
+
submit that work with modifications, whether created in whole
|
130
|
+
or in part by me, under the same open source license (unless
|
131
|
+
I am permitted to submit under a different license), as
|
132
|
+
Indicated in the file; or
|
133
|
+
|
134
|
+
(c) The contribution was provided directly to me by some other
|
135
|
+
person who certified (a), (b) or (c) and I have not modified
|
136
|
+
it.
|
137
|
+
|
138
|
+
(d) I understand and agree that this project and the contribution
|
139
|
+
are public and that a record of the contribution (including
|
140
|
+
all personal information I submit with it, including my
|
141
|
+
sign-off) is maintained indefinitely and may be redistributed
|
142
|
+
consistent with this project or the open source license(s)
|
143
|
+
involved.
|
144
|
+
```
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2008 Scott Chacon
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/MAINTAINERS.md
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
# Maintainers
|
2
|
+
|
3
|
+
When making changes in this repository, one of the maintainers below must review and approve your pull request.
|
4
|
+
|
5
|
+
### Maintainers
|
6
|
+
|
7
|
+
* [Per Lundberg](https://github.com/perlun)
|
8
|
+
* [Vern Burton](https://github.com/tarcinil)
|
9
|
+
* [James Couball](https://github.com/jcouball)
|
data/README.md
ADDED
@@ -0,0 +1,300 @@
|
|
1
|
+
# Git Library for Ruby
|
2
|
+
|
3
|
+
Library for using Git in Ruby.
|
4
|
+
|
5
|
+
## Homepage
|
6
|
+
|
7
|
+
Git public hosting of the project source code is at:
|
8
|
+
|
9
|
+
http://github.com/ruby-git/ruby-git
|
10
|
+
|
11
|
+
## Install
|
12
|
+
|
13
|
+
You can install Ruby/Git like this:
|
14
|
+
|
15
|
+
$ sudo gem install git
|
16
|
+
|
17
|
+
## Code Status
|
18
|
+
|
19
|
+
* [](https://travis-ci.org/ruby-git/ruby-git)
|
20
|
+
* [](https://codeclimate.com/github/ruby-git/ruby-git)
|
21
|
+
* [](https://badge.fury.io/rb/git)
|
22
|
+
|
23
|
+
## Major Objects
|
24
|
+
|
25
|
+
**Git::Base** - The object returned from a `Git.open` or `Git.clone`. Most major actions are called from this object.
|
26
|
+
|
27
|
+
**Git::Object** - The base object for your tree, blob and commit objects, returned from `@git.gtree` or `@git.object` calls. the `Git::AbstractObject` will have most of the calls in common for all those objects.
|
28
|
+
|
29
|
+
**Git::Diff** - returns from a `@git.diff` command. It is an Enumerable that returns `Git::Diff:DiffFile` objects from which you can get per file patches and insertion/deletion statistics. You can also get total statistics from the Git::Diff object directly.
|
30
|
+
|
31
|
+
**Git::Status** - returns from a `@git.status` command. It is an Enumerable that returns
|
32
|
+
`Git:Status::StatusFile` objects for each object in git, which includes files in the working
|
33
|
+
directory, in the index and in the repository. Similar to running 'git status' on the command line to determine untracked and changed files.
|
34
|
+
|
35
|
+
**Git::Branches** - Enumerable object that holds `Git::Branch objects`. You can call .local or .remote on it to filter to just your local or remote branches.
|
36
|
+
|
37
|
+
**Git::Remote**- A reference to a remote repository that is tracked by this repository.
|
38
|
+
|
39
|
+
**Git::Log** - An Enumerable object that references all the `Git::Object::Commit` objects that encompass your log query, which can be constructed through methods on the `Git::Log object`,
|
40
|
+
like:
|
41
|
+
|
42
|
+
`@git.log(20).object("some_file").since("2 weeks ago").between('v2.6', 'v2.7').each { |commit| [block] }`
|
43
|
+
|
44
|
+
## Examples
|
45
|
+
|
46
|
+
Here are a bunch of examples of how to use the Ruby/Git package.
|
47
|
+
|
48
|
+
Ruby < 1.9 will require rubygems to be loaded.
|
49
|
+
|
50
|
+
```ruby
|
51
|
+
require 'rubygems'
|
52
|
+
```
|
53
|
+
|
54
|
+
Require the 'git' gem.
|
55
|
+
```ruby
|
56
|
+
require 'git'
|
57
|
+
```
|
58
|
+
|
59
|
+
Git env config
|
60
|
+
|
61
|
+
```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
|
69
|
+
```
|
70
|
+
|
71
|
+
_NOTE: Another way to specify where is the `git` binary is through the environment variable `GIT_PATH`_
|
72
|
+
|
73
|
+
Here are the operations that need read permission only.
|
74
|
+
|
75
|
+
```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
|
+
|
161
|
+
```
|
162
|
+
|
163
|
+
And here are the operations that will need to write to your git repository.
|
164
|
+
|
165
|
+
```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
|
+
g.merge_base('branch1', 'branch2')
|
220
|
+
|
221
|
+
r = g.add_remote(name, uri) # Git::Remote
|
222
|
+
r = g.add_remote(name, Git::Base) # Git::Remote
|
223
|
+
|
224
|
+
g.remotes # array of Git::Remotes
|
225
|
+
g.remote(name).fetch
|
226
|
+
g.remote(name).remove
|
227
|
+
g.remote(name).merge
|
228
|
+
g.remote(name).merge(branch)
|
229
|
+
|
230
|
+
g.fetch
|
231
|
+
g.fetch(g.remotes.first)
|
232
|
+
g.fetch('origin', {:ref => 'some/ref/head'} )
|
233
|
+
|
234
|
+
g.pull
|
235
|
+
g.pull(Git::Repo, Git::Branch) # fetch and a merge
|
236
|
+
|
237
|
+
g.add_tag('tag_name') # returns Git::Tag
|
238
|
+
g.add_tag('tag_name', 'object_reference')
|
239
|
+
g.add_tag('tag_name', 'object_reference', {:options => 'here'})
|
240
|
+
g.add_tag('tag_name', {:options => 'here'})
|
241
|
+
|
242
|
+
Options:
|
243
|
+
:a | :annotate
|
244
|
+
:d
|
245
|
+
:f
|
246
|
+
:m | :message
|
247
|
+
:s
|
248
|
+
|
249
|
+
g.delete_tag('tag_name')
|
250
|
+
|
251
|
+
g.repack
|
252
|
+
|
253
|
+
g.push
|
254
|
+
g.push(g.remote('name'))
|
255
|
+
```
|
256
|
+
|
257
|
+
Some examples of more low-level index and tree operations
|
258
|
+
|
259
|
+
```ruby
|
260
|
+
g.with_temp_index do
|
261
|
+
|
262
|
+
g.read_tree(tree3) # calls self.index.read_tree
|
263
|
+
g.read_tree(tree1, :prefix => 'hi/')
|
264
|
+
|
265
|
+
c = g.commit_tree('message')
|
266
|
+
# or #
|
267
|
+
t = g.write_tree
|
268
|
+
c = g.commit_tree(t, :message => 'message', :parents => [sha1, sha2])
|
269
|
+
|
270
|
+
g.branch('branch_name').update_ref(c)
|
271
|
+
g.update_ref(branch, c)
|
272
|
+
|
273
|
+
g.with_temp_working do # new blank working directory
|
274
|
+
g.checkout
|
275
|
+
g.checkout(another_index)
|
276
|
+
g.commit # commits to temp_index
|
277
|
+
end
|
278
|
+
end
|
279
|
+
|
280
|
+
g.set_index('/path/to/index')
|
281
|
+
|
282
|
+
|
283
|
+
g.with_index(path) do
|
284
|
+
# calls set_index, then switches back after
|
285
|
+
end
|
286
|
+
|
287
|
+
g.with_working(dir) do
|
288
|
+
# calls set_working, then switches back after
|
289
|
+
end
|
290
|
+
|
291
|
+
g.with_temp_working(dir) do
|
292
|
+
g.checkout_index(:prefix => dir, :path_limiter => path)
|
293
|
+
# do file work
|
294
|
+
g.commit # commits to index
|
295
|
+
end
|
296
|
+
```
|
297
|
+
|
298
|
+
## License
|
299
|
+
|
300
|
+
licensed under MIT License Copyright (c) 2008 Scott Chacon. See LICENSE for further details.
|