git 1.2.5 → 1.2.6
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 +7 -0
- data/LICENSE +21 -0
- data/README.md +255 -0
- data/lib/git.rb +54 -62
- data/lib/git/base.rb +82 -21
- data/lib/git/branch.rb +27 -9
- data/lib/git/branches.rb +25 -2
- data/lib/git/lib.rb +149 -77
- data/lib/git/log.rb +11 -0
- data/lib/git/object.rb +3 -1
- data/lib/git/path.rb +12 -8
- data/lib/git/remote.rb +0 -4
- data/lib/git/repository.rb +2 -0
- data/lib/git/version.rb +7 -0
- metadata +76 -38
- data/README +0 -240
data/lib/git/log.rb
CHANGED
data/lib/git/object.rb
CHANGED
data/lib/git/path.rb
CHANGED
@@ -1,14 +1,17 @@
|
|
1
1
|
module Git
|
2
|
-
|
2
|
+
|
3
|
+
class Path
|
3
4
|
|
4
5
|
attr_accessor :path
|
5
6
|
|
6
|
-
def initialize(path, check_path
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
raise ArgumentError,
|
7
|
+
def initialize(path, check_path=true)
|
8
|
+
path = File.expand_path(path)
|
9
|
+
|
10
|
+
if check_path && !File.exists?(path)
|
11
|
+
raise ArgumentError, 'path does not exist', [path]
|
11
12
|
end
|
13
|
+
|
14
|
+
@path = path
|
12
15
|
end
|
13
16
|
|
14
17
|
def readable?
|
@@ -23,5 +26,6 @@ module Git
|
|
23
26
|
@path
|
24
27
|
end
|
25
28
|
|
26
|
-
|
27
|
-
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
data/lib/git/remote.rb
CHANGED
data/lib/git/repository.rb
CHANGED
data/lib/git/version.rb
ADDED
metadata
CHANGED
@@ -1,27 +1,65 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: git
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.2.6
|
5
5
|
platform: ruby
|
6
|
-
authors:
|
6
|
+
authors:
|
7
7
|
- Scott Chacon
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
11
|
+
date: 2013-08-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rake
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rdoc
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: test-unit
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
16
55
|
description:
|
17
56
|
email: schacon@gmail.com
|
18
57
|
executables: []
|
19
|
-
|
20
58
|
extensions: []
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
59
|
+
extra_rdoc_files:
|
60
|
+
- README.md
|
61
|
+
files:
|
62
|
+
- LICENSE
|
25
63
|
- lib/git.rb
|
26
64
|
- lib/git/author.rb
|
27
65
|
- lib/git/base.rb
|
@@ -38,35 +76,35 @@ files:
|
|
38
76
|
- lib/git/stash.rb
|
39
77
|
- lib/git/stashes.rb
|
40
78
|
- lib/git/status.rb
|
79
|
+
- lib/git/version.rb
|
41
80
|
- lib/git/working_directory.rb
|
42
|
-
- README
|
43
|
-
has_rdoc: true
|
81
|
+
- README.md
|
44
82
|
homepage: http://github.com/schacon/ruby-git
|
45
|
-
licenses:
|
46
|
-
|
83
|
+
licenses:
|
84
|
+
- MIT
|
85
|
+
metadata: {}
|
47
86
|
post_install_message:
|
48
|
-
rdoc_options:
|
87
|
+
rdoc_options:
|
49
88
|
- --charset=UTF-8
|
50
|
-
require_paths:
|
89
|
+
require_paths:
|
51
90
|
- lib
|
52
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
53
|
-
requirements:
|
54
|
-
- -
|
55
|
-
- !ruby/object:Gem::Version
|
56
|
-
version:
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
version:
|
64
|
-
requirements:
|
91
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - '>='
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - '>='
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
requirements:
|
65
102
|
- git 1.6.0.0, or greater
|
66
|
-
rubyforge_project:
|
67
|
-
rubygems_version:
|
103
|
+
rubyforge_project:
|
104
|
+
rubygems_version: 2.0.6
|
68
105
|
signing_key:
|
69
|
-
specification_version:
|
70
|
-
summary: Ruby/Git is a Ruby library that can be used to create, read and manipulate
|
106
|
+
specification_version: 4
|
107
|
+
summary: Ruby/Git is a Ruby library that can be used to create, read and manipulate
|
108
|
+
Git repositories by wrapping system calls to the git binary.
|
71
109
|
test_files: []
|
72
|
-
|
110
|
+
has_rdoc:
|
data/README
DELETED
@@ -1,240 +0,0 @@
|
|
1
|
-
== Git Library for Ruby
|
2
|
-
|
3
|
-
Library for using Git in Ruby. Test.
|
4
|
-
|
5
|
-
= Homepage
|
6
|
-
|
7
|
-
Git public hosting of the project source code is at:
|
8
|
-
|
9
|
-
http://github.com/schacon/ruby-git
|
10
|
-
|
11
|
-
= Install
|
12
|
-
|
13
|
-
You can install Ruby/Git like this:
|
14
|
-
|
15
|
-
$ sudo gem install git
|
16
|
-
|
17
|
-
= Major Objects
|
18
|
-
|
19
|
-
Git::Base - this is the object returned from a Git.open or Git.clone.
|
20
|
-
Most major actions are called from this object.
|
21
|
-
|
22
|
-
Git::Object - this is the base object for your tree, blob and commit objects,
|
23
|
-
returned from @git.gtree or @git.object calls. the Git::AbstractObject will
|
24
|
-
have most of the calls in common for all those objects.
|
25
|
-
|
26
|
-
Git::Diff - returns from a @git.diff command. It is an Enumerable that returns
|
27
|
-
Git::Diff:DiffFile objects from which you can get per file patches and insertion/deletion
|
28
|
-
statistics. You can also get total statistics from the Git::Diff object directly.
|
29
|
-
|
30
|
-
Git::Status - returns from a @git.status command. It is an Enumerable that returns
|
31
|
-
Git:Status::StatusFile objects for each object in git, which includes files in the working
|
32
|
-
directory, in the index and in the repository. Similar to running 'git status' on the command
|
33
|
-
line to determine untracked and changed files.
|
34
|
-
|
35
|
-
Git::Branches - Enumerable object that holds Git::Branch objects. You can call .local or .remote
|
36
|
-
on it to filter to just your local or remote branches.
|
37
|
-
|
38
|
-
Git::Remote - A reference to a remote repository that is tracked by this repository.
|
39
|
-
|
40
|
-
Git::Log - An Enumerable object that references all the Git::Object::Commit objects that encompass
|
41
|
-
your log query, which can be constructed through methods on the Git::Log object, like:
|
42
|
-
|
43
|
-
@git.log(20).object("some_file").since("2 weeks ago").between('v2.6', 'v2.7').each { |commit| [block] }
|
44
|
-
|
45
|
-
= Examples
|
46
|
-
|
47
|
-
Here are a bunch of examples of how to use the Ruby/Git package.
|
48
|
-
|
49
|
-
First you have to remember to require rubygems if it's not. Then include the 'git' gem.
|
50
|
-
|
51
|
-
require 'rubygems'
|
52
|
-
require 'git'
|
53
|
-
|
54
|
-
Here are the operations that need read permission only.
|
55
|
-
|
56
|
-
g = Git.open (working_dir, :log => Logger.new(STDOUT))
|
57
|
-
|
58
|
-
g.index
|
59
|
-
g.index.readable?
|
60
|
-
g.index.writable?
|
61
|
-
g.repo
|
62
|
-
g.dir
|
63
|
-
|
64
|
-
g.log # returns array of Git::Commit objects
|
65
|
-
g.log.since('2 weeks ago')
|
66
|
-
g.log.between('v2.5', 'v2.6')
|
67
|
-
g.log.each {|l| puts l.sha }
|
68
|
-
g.gblob('v2.5:Makefile').log.since('2 weeks ago')
|
69
|
-
|
70
|
-
g.object('HEAD^').to_s # git show / git rev-parse
|
71
|
-
g.object('HEAD^').contents
|
72
|
-
g.object('v2.5:Makefile').size
|
73
|
-
g.object('v2.5:Makefile').sha
|
74
|
-
|
75
|
-
g.gtree(treeish)
|
76
|
-
g.gblob(treeish)
|
77
|
-
g.gcommit(treeish)
|
78
|
-
|
79
|
-
|
80
|
-
commit = g.gcommit('1cc8667014381')
|
81
|
-
commit.gtree
|
82
|
-
commit.parent.sha
|
83
|
-
commit.parents.size
|
84
|
-
commit.author.name
|
85
|
-
commit.author.email
|
86
|
-
commit.author.date.strftime("%m-%d-%y")
|
87
|
-
commit.committer.name
|
88
|
-
commit.date.strftime("%m-%d-%y")
|
89
|
-
commit.message
|
90
|
-
|
91
|
-
tree = g.gtree("HEAD^{tree}")
|
92
|
-
tree.blobs
|
93
|
-
tree.subtrees
|
94
|
-
tree.children # blobs and subtrees
|
95
|
-
|
96
|
-
g.revparse('v2.5:Makefile')
|
97
|
-
|
98
|
-
g.branches # returns Git::Branch objects
|
99
|
-
g.branches.local
|
100
|
-
g.branches.remote
|
101
|
-
g.branches[:master].gcommit
|
102
|
-
g.branches['origin/master'].gcommit
|
103
|
-
|
104
|
-
g.grep('hello') # implies HEAD
|
105
|
-
g.blob('v2.5:Makefile').grep('hello')
|
106
|
-
g.tag('v2.5').grep('hello', 'docs/')
|
107
|
-
|
108
|
-
g.diff(commit1, commit2).size
|
109
|
-
g.diff(commit1, commit2).stats
|
110
|
-
g.gtree('v2.5').diff('v2.6').insertions
|
111
|
-
g.diff('gitsearch1', 'v2.5').path('lib/')
|
112
|
-
g.diff('gitsearch1', @git.gtree('v2.5'))
|
113
|
-
g.diff('gitsearch1', 'v2.5').path('docs/').patch
|
114
|
-
g.gtree('v2.5').diff('v2.6').patch
|
115
|
-
|
116
|
-
g.gtree('v2.5').diff('v2.6').each do |file_diff|
|
117
|
-
puts file_diff.path
|
118
|
-
puts file_diff.patch
|
119
|
-
puts file_diff.blob(:src).contents
|
120
|
-
end
|
121
|
-
|
122
|
-
g.config('user.name') # returns 'Scott Chacon'
|
123
|
-
g.config # returns whole config hash
|
124
|
-
|
125
|
-
g.tag # returns array of Git::Tag objects
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
And here are the operations that will need to write to your git repository.
|
130
|
-
|
131
|
-
|
132
|
-
g = Git.init
|
133
|
-
Git.init('project')
|
134
|
-
Git.init('/home/schacon/proj',
|
135
|
-
{ :git_dir => '/opt/git/proj.git',
|
136
|
-
:index_file => '/tmp/index'} )
|
137
|
-
|
138
|
-
g = Git.clone(URI, :name => 'name', :path => '/tmp/checkout')
|
139
|
-
g.config('user.name', 'Scott Chacon')
|
140
|
-
g.config('user.email', 'email@email.com')
|
141
|
-
|
142
|
-
g.add('.')
|
143
|
-
g.add([file1, file2])
|
144
|
-
|
145
|
-
g.remove('file.txt')
|
146
|
-
g.remove(['file.txt', 'file2.txt'])
|
147
|
-
|
148
|
-
g.commit('message')
|
149
|
-
g.commit_all('message')
|
150
|
-
|
151
|
-
g = Git.clone(repo, 'myrepo')
|
152
|
-
g.chdir do
|
153
|
-
new_file('test-file', 'blahblahblah')
|
154
|
-
g.status.changed.each do |file|
|
155
|
-
puts file.blob(:index).contents
|
156
|
-
end
|
157
|
-
end
|
158
|
-
|
159
|
-
g.reset # defaults to HEAD
|
160
|
-
g.reset_hard(Git::Commit)
|
161
|
-
|
162
|
-
g.branch('new_branch') # creates new or fetches existing
|
163
|
-
g.branch('new_branch').checkout
|
164
|
-
g.branch('new_branch').delete
|
165
|
-
g.branch('existing_branch').checkout
|
166
|
-
|
167
|
-
g.checkout('new_branch')
|
168
|
-
g.checkout(g.branch('new_branch'))
|
169
|
-
|
170
|
-
g.branch(name).merge(branch2)
|
171
|
-
g.branch(branch2).merge # merges HEAD with branch2
|
172
|
-
|
173
|
-
g.branch(name).in_branch(message) { # add files } # auto-commits
|
174
|
-
g.merge('new_branch')
|
175
|
-
g.merge('origin/remote_branch')
|
176
|
-
g.merge(b.branch('master'))
|
177
|
-
g.merge([branch1, branch2])
|
178
|
-
|
179
|
-
r = g.add_remote(name, uri) # Git::Remote
|
180
|
-
r = g.add_remote(name, Git::Base) # Git::Remote
|
181
|
-
|
182
|
-
g.remotes # array of Git::Remotes
|
183
|
-
g.remote(name).fetch
|
184
|
-
g.remote(name).remove
|
185
|
-
g.remote(name).merge
|
186
|
-
g.remote(name).merge(branch)
|
187
|
-
|
188
|
-
g.fetch
|
189
|
-
g.fetch(g.remotes.first)
|
190
|
-
|
191
|
-
g.pull
|
192
|
-
g.pull(Git::Repo, Git::Branch) # fetch and a merge
|
193
|
-
|
194
|
-
g.add_tag('tag_name') # returns Git::Tag
|
195
|
-
|
196
|
-
g.repack
|
197
|
-
|
198
|
-
g.push
|
199
|
-
g.push(g.remote('name'))
|
200
|
-
|
201
|
-
|
202
|
-
Some examples of more low-level index and tree operations
|
203
|
-
|
204
|
-
g.with_temp_index do
|
205
|
-
|
206
|
-
g.read_tree(tree3) # calls self.index.read_tree
|
207
|
-
g.read_tree(tree1, :prefix => 'hi/')
|
208
|
-
|
209
|
-
c = g.commit_tree('message')
|
210
|
-
# or #
|
211
|
-
t = g.write_tree
|
212
|
-
c = g.commit_tree(t, :message => 'message', :parents => [sha1, sha2])
|
213
|
-
|
214
|
-
g.branch('branch_name').update_ref(c)
|
215
|
-
g.update_ref(branch, c)
|
216
|
-
|
217
|
-
g.with_temp_working do # new blank working directory
|
218
|
-
g.checkout
|
219
|
-
g.checkout(another_index)
|
220
|
-
g.commit # commits to temp_index
|
221
|
-
end
|
222
|
-
end
|
223
|
-
|
224
|
-
g.set_index('/path/to/index')
|
225
|
-
|
226
|
-
|
227
|
-
g.with_index(path) do
|
228
|
-
# calls set_index, then switches back after
|
229
|
-
end
|
230
|
-
|
231
|
-
g.with_working(dir) do
|
232
|
-
# calls set_working, then switches back after
|
233
|
-
end
|
234
|
-
|
235
|
-
g.with_temp_working(dir) do
|
236
|
-
g.checkout_index(:prefix => dir, :path_limiter => path)
|
237
|
-
# do file work
|
238
|
-
g.commit # commits to index
|
239
|
-
end
|
240
|
-
|