git-ng 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: fa60b5258604a726f41e9445c84ab769b5d239bd
4
+ data.tar.gz: be0d6895795efb5993670bc18b66ba76c815c11b
5
+ SHA512:
6
+ metadata.gz: ff1886d89e7d9e35aed118005dd367e0e930ae1843bcccc736ffaa3c24589711a6489a90f9aa13e9d18af91e6f440c4981e1d7bbc924e5683f64c703ea5a5bfb
7
+ data.tar.gz: 1332b33383f2edacfcd020c4b02da2be80d5e65a56723b3ca0797461e0427396f3da105a06696bf11fda453054a7ad820edc8b2f4ecbc85674dfffbafac862c3
@@ -0,0 +1,84 @@
1
+ == 1.3.0
2
+
3
+ * Dropping Ruby 1.8.x support
4
+
5
+ == 1.2.10
6
+
7
+ * Adding Git::Diff.name_status
8
+ * Checking and fixing encoding on commands output to prevent encoding errors afterwards
9
+
10
+ == 1.2.9
11
+
12
+ * Adding Git.configure (to configure the git env)
13
+ * Adding Git.ls_remote [Git.ls_remote(repo_path_or_url='.')]
14
+ * Adding Git.describe [repo.describe(objectish, opts)]
15
+ * Adding Git.show [repo.show(objectish=nil, path=nil)]
16
+ * Fixing Git::Diff to support default references (implicit references)
17
+ * Fixing Git::Diff to support diff over git .patch files
18
+ * Fixing Git.checkout when using :new_branch opt
19
+ * Fixing Git::Object::Commit to preserve its sha after fetching metadata
20
+ * Fixing Git.is_remote_branch? to actually check against remote branches
21
+ * Improvements over how ENV variables are modified
22
+ * Improving thrade safety (using --git-dir and --work-tree git opts)
23
+ * Improving Git::Object::Tag. Adding annotated?, tagger and message
24
+ * Supporting a submodule path as a valid repo
25
+ * Git.checkout - supporting -f and -b
26
+ * Git.clone - supporting --branch
27
+ * Git.fetch - supporting --prune
28
+ * Git.tag - supporting
29
+
30
+ == 1.2.8
31
+
32
+ * Keeping the old escape format for windows users
33
+ * revparse: Supporting ref names containing SHA like substrings (40-hex strings)
34
+ * Fix warnings on Ruby 2.1.2
35
+
36
+ == 1.2.7
37
+
38
+ * Fixing mesages encoding
39
+ * Fixing -f flag in git push
40
+ * Fixing log parser for multiline messages
41
+ * Supporting object references on Git.add_tag
42
+ * Including dotfiles on Git.status
43
+ * Git.fetch - supporting --tags
44
+ * Git.clean - supporting -x
45
+ * Git.add_tag options - supporting -a, -m and -s
46
+ * Added Git.delete_tag
47
+
48
+ == 1.2.6
49
+
50
+ * Ruby 1.9.X/2.0 fully supported
51
+ * JRuby 1.8/1.9 support
52
+ * Rubinius support
53
+ * Git.clone - supporting --recursive and --config
54
+ * Git.log - supporting last and [] over the results
55
+ * Git.add_remote - supporting -f and -t
56
+ * Git.add - supporting --fore
57
+ * Git.init - supporting --bare
58
+ * Git.commit - supporting --all and --amend
59
+ * Added Git.remote_remote, Git.revert and Git.clean
60
+ * Added Bundler to the formula
61
+ * Travis configuration
62
+ * Licence included with the gem
63
+
64
+ == 1.0.4
65
+
66
+ * added camping/gitweb.rb frontend
67
+ * added a number of speed-ups
68
+
69
+ == 1.0.3
70
+
71
+ * Sped up most of the operations
72
+ * Added some predicate functions (commit?, tree?, etc)
73
+ * Added a number of lower level operations (read-tree, write-tree, checkout-index, etc)
74
+ * Fixed a bug with using bare repositories
75
+ * Updated a good amount of the documentation
76
+
77
+ == 1.0.2
78
+
79
+ * Added methods to the git objects that might be helpful
80
+
81
+ == 1.0.1
82
+
83
+ * Initial version
84
+
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.
@@ -0,0 +1,302 @@
1
+ # Git Library for Ruby
2
+
3
+ Library for using Git in Ruby.
4
+
5
+ **Note**: This gem is a fork of http://github.com/schacon/ruby-git. Upstream version is not maintained by the authors.
6
+
7
+ I'll maintain a version with necessary patches and publish them under git-ng gem. All class namespace will be kept identical to ruby-git.
8
+ If the maintainer show some activity, I'll be happy to remove this fork.
9
+
10
+ ## Homepage
11
+
12
+ Git public hosting of the project source code is at:
13
+
14
+ http://github.com/kamaradclimber/ruby-git
15
+
16
+ ## Install
17
+
18
+ You can install git-ng like this:
19
+
20
+ $ gem install git-ng
21
+
22
+ ## Code Status
23
+
24
+ * [![Build Status](https://api.travis-ci.org/kamaradclimber/ruby-git.png)](https://travis-ci.org/kamaradclimber/ruby-git)
25
+ * [![Code Climate](https://codeclimate.com/github/kamaradclimber/ruby-git.png)](https://codeclimate.com/github/kamaradclimber/ruby-git)
26
+ * [![Gem Version](https://badge.fury.io/rb/git-ng.png)](http://badge.fury.io/rb/git-ng)
27
+ * [![Dependencies](https://gemnasium.com/kamaradclimber/ruby-git.png?travis)](https://gemnasium.com/kamaradclimber/ruby-git)
28
+
29
+ ## Major Objects
30
+
31
+ **Git::Base** - The object returned from a `Git.open` or `Git.clone`. Most major actions are called from this object.
32
+
33
+ **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.
34
+
35
+ **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.
36
+
37
+ **Git::Status** - returns from a `@git.status` command. It is an Enumerable that returns
38
+ `Git:Status::StatusFile` objects for each object in git, which includes files in the working
39
+ directory, in the index and in the repository. Similar to running 'git status' on the command line to determine untracked and changed files.
40
+
41
+ **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.
42
+
43
+ **Git::Remote**- A reference to a remote repository that is tracked by this repository.
44
+
45
+ **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`,
46
+ like:
47
+
48
+ `@git.log(20).object("some_file").since("2 weeks ago").between('v2.6', 'v2.7').each { |commit| [block] }`
49
+
50
+ ## Examples
51
+
52
+ Here are a bunch of examples of how to use the Ruby/Git package.
53
+
54
+ Ruby < 1.9 will require rubygems to be loaded.
55
+
56
+ ```ruby
57
+ require 'rubygems'
58
+ ```
59
+
60
+ Require the 'git' gem.
61
+ ```ruby
62
+ require 'git'
63
+ ```
64
+
65
+ Git env config
66
+
67
+ ```ruby
68
+ Git.configure do |config|
69
+ # If you want to use a custom git binary
70
+ config.binary_path = '/git/bin/path'
71
+
72
+ # If you need to use a custom SSH script
73
+ config.git_ssh = '/path/to/ssh/script'
74
+ end
75
+
76
+ ```
77
+
78
+
79
+ Here are the operations that need read permission only.
80
+
81
+ ```ruby
82
+ g = Git.open(working_dir, :log => Logger.new(STDOUT))
83
+
84
+ g.index
85
+ g.index.readable?
86
+ g.index.writable?
87
+ g.repo
88
+ g.dir
89
+
90
+ g.log # returns array of Git::Commit objects
91
+ g.log.since('2 weeks ago')
92
+ g.log.between('v2.5', 'v2.6')
93
+ g.log.each {|l| puts l.sha }
94
+ g.gblob('v2.5:Makefile').log.since('2 weeks ago')
95
+
96
+ g.object('HEAD^').to_s # git show / git rev-parse
97
+ g.object('HEAD^').contents
98
+ g.object('v2.5:Makefile').size
99
+ g.object('v2.5:Makefile').sha
100
+
101
+ g.gtree(treeish)
102
+ g.gblob(treeish)
103
+ g.gcommit(treeish)
104
+
105
+
106
+ commit = g.gcommit('1cc8667014381')
107
+
108
+ commit.gtree
109
+ commit.parent.sha
110
+ commit.parents.size
111
+ commit.author.name
112
+ commit.author.email
113
+ commit.author.date.strftime("%m-%d-%y")
114
+ commit.committer.name
115
+ commit.date.strftime("%m-%d-%y")
116
+ commit.message
117
+
118
+ tree = g.gtree("HEAD^{tree}")
119
+
120
+ tree.blobs
121
+ tree.subtrees
122
+ tree.children # blobs and subtrees
123
+
124
+ g.revparse('v2.5:Makefile')
125
+
126
+ g.branches # returns Git::Branch objects
127
+ g.branches.local
128
+ g.branches.remote
129
+ g.branches[:master].gcommit
130
+ g.branches['origin/master'].gcommit
131
+
132
+ g.grep('hello') # implies HEAD
133
+ g.blob('v2.5:Makefile').grep('hello')
134
+ g.tag('v2.5').grep('hello', 'docs/')
135
+ g.describe()
136
+ g.describe('0djf2aa')
137
+ g.describe('HEAD', {:all => true, :tags => true})
138
+
139
+ g.diff(commit1, commit2).size
140
+ g.diff(commit1, commit2).stats
141
+ g.diff(commit1, commit2).name_status
142
+ g.gtree('v2.5').diff('v2.6').insertions
143
+ g.diff('gitsearch1', 'v2.5').path('lib/')
144
+ g.diff('gitsearch1', @git.gtree('v2.5'))
145
+ g.diff('gitsearch1', 'v2.5').path('docs/').patch
146
+ g.gtree('v2.5').diff('v2.6').patch
147
+
148
+ g.gtree('v2.5').diff('v2.6').each do |file_diff|
149
+ puts file_diff.path
150
+ puts file_diff.patch
151
+ puts file_diff.blob(:src).contents
152
+ end
153
+
154
+ g.config('user.name') # returns 'Scott Chacon'
155
+ g.config # returns whole config hash
156
+
157
+ g.tags # returns array of Git::Tag objects
158
+
159
+ g.show()
160
+ g.show('HEAD')
161
+ g.show('v2.8', 'README.md')
162
+
163
+ Git.ls_remote('https://github.com/kamaradclimber/ruby-git.git') # returns a hash containing the available references of the repo.
164
+ Git.ls_remote('/path/to/local/repo')
165
+ Git.ls_remote() # same as Git.ls_remote('.')
166
+
167
+ ```
168
+
169
+ And here are the operations that will need to write to your git repository.
170
+
171
+ ```ruby
172
+ g = Git.init
173
+ Git.init('project')
174
+ Git.init('/home/schacon/proj',
175
+ { :repository => '/opt/git/proj.git',
176
+ :index => '/tmp/index'} )
177
+
178
+ g = Git.clone(URI, NAME, :path => '/tmp/checkout')
179
+ g.config('user.name', 'Scott Chacon')
180
+ g.config('user.email', 'email@email.com')
181
+
182
+ g.add # git add -- "."
183
+ g.add(:all=>true) # git add --all -- "."
184
+ g.add('file_path') # git add -- "file_path"
185
+ g.add(['file_path_1', 'file_path_2']) # git add -- "file_path_1" "file_path_2"
186
+
187
+ g.remove() # git rm -f -- "."
188
+ g.remove('file.txt') # git rm -f -- "file.txt"
189
+ g.remove(['file.txt', 'file2.txt']) # git rm -f -- "file.txt" "file2.txt"
190
+ g.remove('file.txt', :recursive => true) # git rm -f -r -- "file.txt"
191
+ g.remove('file.txt', :cached => true) # git rm -f --cached -- "file.txt"
192
+
193
+ g.commit('message')
194
+ g.commit_all('message')
195
+
196
+ g = Git.clone(repo, 'myrepo')
197
+ g.chdir do
198
+ new_file('test-file', 'blahblahblah')
199
+ g.status.changed.each do |file|
200
+ puts file.blob(:index).contents
201
+ end
202
+ end
203
+
204
+ g.reset # defaults to HEAD
205
+ g.reset_hard(Git::Commit)
206
+
207
+ g.branch('new_branch') # creates new or fetches existing
208
+ g.branch('new_branch').checkout
209
+ g.branch('new_branch').delete
210
+ g.branch('existing_branch').checkout
211
+
212
+ g.checkout('new_branch')
213
+ g.checkout(g.branch('new_branch'))
214
+
215
+ g.branch(name).merge(branch2)
216
+ g.branch(branch2).merge # merges HEAD with branch2
217
+
218
+ g.branch(name).in_branch(message) { # add files } # auto-commits
219
+ g.merge('new_branch')
220
+ g.merge('origin/remote_branch')
221
+ g.merge(g.branch('master'))
222
+ g.merge([branch1, branch2])
223
+
224
+ r = g.add_remote(name, uri) # Git::Remote
225
+ r = g.add_remote(name, Git::Base) # Git::Remote
226
+
227
+ g.remotes # array of Git::Remotes
228
+ g.remote(name).fetch
229
+ g.remote(name).remove
230
+ g.remote(name).merge
231
+ g.remote(name).merge(branch)
232
+
233
+ g.fetch
234
+ g.fetch(g.remotes.first)
235
+
236
+ g.pull
237
+ g.pull(Git::Repo, Git::Branch) # fetch and a merge
238
+
239
+ g.add_tag('tag_name') # returns Git::Tag
240
+ g.add_tag('tag_name', 'object_reference')
241
+ g.add_tag('tag_name', 'object_reference', {:options => 'here'})
242
+ g.add_tag('tag_name', {:options => 'here'})
243
+
244
+ Options:
245
+ :a | :annotate
246
+ :d
247
+ :f
248
+ :m | :message
249
+ :s
250
+
251
+ g.delete_tag('tag_name')
252
+
253
+ g.repack
254
+
255
+ g.push
256
+ g.push(g.remote('name'))
257
+ ```
258
+
259
+ Some examples of more low-level index and tree operations
260
+
261
+ ```ruby
262
+ g.with_temp_index do
263
+
264
+ g.read_tree(tree3) # calls self.index.read_tree
265
+ g.read_tree(tree1, :prefix => 'hi/')
266
+
267
+ c = g.commit_tree('message')
268
+ # or #
269
+ t = g.write_tree
270
+ c = g.commit_tree(t, :message => 'message', :parents => [sha1, sha2])
271
+
272
+ g.branch('branch_name').update_ref(c)
273
+ g.update_ref(branch, c)
274
+
275
+ g.with_temp_working do # new blank working directory
276
+ g.checkout
277
+ g.checkout(another_index)
278
+ g.commit # commits to temp_index
279
+ end
280
+ end
281
+
282
+ g.set_index('/path/to/index')
283
+
284
+
285
+ g.with_index(path) do
286
+ # calls set_index, then switches back after
287
+ end
288
+
289
+ g.with_working(dir) do
290
+ # calls set_working, then switches back after
291
+ end
292
+
293
+ g.with_temp_working(dir) do
294
+ g.checkout_index(:prefix => dir, :path_limiter => path)
295
+ # do file work
296
+ g.commit # commits to index
297
+ end
298
+ ```
299
+
300
+ ## License
301
+
302
+ licensed under MIT License Copyright (c) 2008 Scott Chacon. See LICENSE for further details.
data/VERSION ADDED
@@ -0,0 +1,2 @@
1
+ 1.3.0
2
+
@@ -0,0 +1,166 @@
1
+ # Add the directory containing this file to the start of the load path if it
2
+ # isn't there already.
3
+ $:.unshift(File.dirname(__FILE__)) unless
4
+ $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
5
+
6
+ require 'git/author'
7
+ require 'git/base'
8
+ require 'git/branch'
9
+ require 'git/branches'
10
+ require 'git/config'
11
+ require 'git/diff'
12
+ require 'git/index'
13
+ require 'git/lib'
14
+ require 'git/log'
15
+ require 'git/object'
16
+ require 'git/path'
17
+ require 'git/remote'
18
+ require 'git/repository'
19
+ require 'git/status'
20
+ require 'git/stash'
21
+ require 'git/stashes'
22
+ require 'git/working_directory'
23
+
24
+ lib = Git::Lib.new(nil, nil)
25
+ unless lib.meets_required_version?
26
+ $stderr.puts "[WARNING] The git gem requires git #{lib.required_command_version.join('.')} or later, but only found #{lib.current_command_version.join('.')}. You should probably upgrade."
27
+ end
28
+
29
+ # Git/Ruby Library
30
+ #
31
+ # This provides bindings for working with git in complex
32
+ # interactions, including branching and merging, object
33
+ # inspection and manipulation, history, patch generation
34
+ # and more. You should be able to do most fundamental git
35
+ # operations with this library.
36
+ #
37
+ # This module provides the basic functions to open a git
38
+ # reference to work with. You can open a working directory,
39
+ # open a bare repository, initialize a new repo or clone an
40
+ # existing remote repository.
41
+ #
42
+ # Author:: Scott Chacon (mailto:schacon@gmail.com)
43
+ # License:: MIT License
44
+ module Git
45
+
46
+ #g.config('user.name', 'Scott Chacon') # sets value
47
+ #g.config('user.email', 'email@email.com') # sets value
48
+ #g.config('user.name') # returns 'Scott Chacon'
49
+ #g.config # returns whole config hash
50
+ def config(name = nil, value = nil)
51
+ lib = Git::Lib.new
52
+ if(name && value)
53
+ # set value
54
+ lib.config_set(name, value)
55
+ elsif (name)
56
+ # return value
57
+ lib.config_get(name)
58
+ else
59
+ # return hash
60
+ lib.config_list
61
+ end
62
+ end
63
+
64
+ def self.configure
65
+ yield Base.config
66
+ end
67
+
68
+ def self.config
69
+ return Base.config
70
+ end
71
+
72
+ def global_config(name = nil, value = nil)
73
+ self.class.global_config(name, value)
74
+ end
75
+
76
+ # open a bare repository
77
+ #
78
+ # this takes the path to a bare git repo
79
+ # it expects not to be able to use a working directory
80
+ # so you can't checkout stuff, commit things, etc.
81
+ # but you can do most read operations
82
+ def self.bare(git_dir, options = {})
83
+ Base.bare(git_dir, options)
84
+ end
85
+
86
+ # clones a remote repository
87
+ #
88
+ # options
89
+ # :bare => true (does a bare clone)
90
+ # :repository => '/path/to/alt_git_dir'
91
+ # :index => '/path/to/alt_index_file'
92
+ #
93
+ # example
94
+ # Git.clone('git://repo.or.cz/rubygit.git', 'clone.git', :bare => true)
95
+ #
96
+ def self.clone(repository, name, options = {})
97
+ Base.clone(repository, name, options)
98
+ end
99
+
100
+ # Export the current HEAD (or a branch, if <tt>options[:branch]</tt>
101
+ # is specified) into the +name+ directory, then remove all traces of git from the
102
+ # directory.
103
+ #
104
+ # See +clone+ for options. Does not obey the <tt>:remote</tt> option,
105
+ # since the .git info will be deleted anyway; always uses the default
106
+ # remote, 'origin.'
107
+ def self.export(repository, name, options = {})
108
+ options.delete(:remote)
109
+ repo = clone(repository, name, {:depth => 1}.merge(options))
110
+ repo.checkout("origin/#{options[:branch]}") if options[:branch]
111
+ Dir.chdir(repo.dir.to_s) { FileUtils.rm_r '.git' }
112
+ end
113
+
114
+ # Same as g.config, but forces it to be at the global level
115
+ #
116
+ #g.config('user.name', 'Scott Chacon') # sets value
117
+ #g.config('user.email', 'email@email.com') # sets value
118
+ #g.config('user.name') # returns 'Scott Chacon'
119
+ #g.config # returns whole config hash
120
+ def self.global_config(name = nil, value = nil)
121
+ lib = Git::Lib.new(nil, nil)
122
+ if(name && value)
123
+ # set value
124
+ lib.global_config_set(name, value)
125
+ elsif (name)
126
+ # return value
127
+ lib.global_config_get(name)
128
+ else
129
+ # return hash
130
+ lib.global_config_list
131
+ end
132
+ end
133
+
134
+ # initialize a new git repository, defaults to the current working directory
135
+ #
136
+ # options
137
+ # :repository => '/path/to/alt_git_dir'
138
+ # :index => '/path/to/alt_index_file'
139
+ def self.init(working_dir = '.', options = {})
140
+ Base.init(working_dir, options)
141
+ end
142
+
143
+ # returns a Hash containing information about the references
144
+ # of the target repository
145
+ #
146
+ # @param [String|NilClass] location the target repository location or nil for '.'
147
+ # @return [{String=>Hash}] the available references of the target repo.
148
+ def self.ls_remote(location=nil)
149
+ Git::Lib.new.ls_remote(location)
150
+ end
151
+
152
+ # open an existing git working directory
153
+ #
154
+ # this will most likely be the most common way to create
155
+ # a git reference, referring to a working directory.
156
+ # if not provided in the options, the library will assume
157
+ # your git_dir and index are in the default place (.git/, .git/index)
158
+ #
159
+ # options
160
+ # :repository => '/path/to/alt_git_dir'
161
+ # :index => '/path/to/alt_index_file'
162
+ def self.open(working_dir, options = {})
163
+ Base.open(working_dir, options)
164
+ end
165
+
166
+ end