git-ce 1.5.0.1 → 1.5.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +1 -1
- data/lib/git.rb +11 -10
- data/lib/git/base.rb +65 -64
- data/lib/git/branch.rb +26 -26
- data/lib/git/lib.rb +18 -5
- data/lib/git/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 22d8d46c1afbc0662c29da86f253769d63f9a7225c442e4724010f6e347a462e
|
4
|
+
data.tar.gz: e8a0eab8826bd33a64cd451030616daaa02abca0b0dc2e1857ff8a8e2d270e4d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a409e982e0254a72a0e32b6e1fa737fb6772cf46a689cc44507cdb144775cbbcb4015a1ec57acd90e122b2e29dd5fef130292b49ab495d4ea8906bff52dc3851
|
7
|
+
data.tar.gz: 9b222f4523af0a13a605e4a8bf703cf59d2938bb4c532a1bc08d3989d8b28e5470e03ea6c2845f0971d8c1cca18e358f78598066e5ff87b1ac39a314aad772ea
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
data/lib/git.rb
CHANGED
@@ -34,7 +34,7 @@ end
|
|
34
34
|
# and more. You should be able to do most fundamental git
|
35
35
|
# operations with this library.
|
36
36
|
#
|
37
|
-
# This module provides the basic functions to open a git
|
37
|
+
# This module provides the basic functions to open a git
|
38
38
|
# reference to work with. You can open a working directory,
|
39
39
|
# open a bare repository, initialize a new repo or clone an
|
40
40
|
# existing remote repository.
|
@@ -42,7 +42,7 @@ end
|
|
42
42
|
# Author:: Scott Chacon (mailto:schacon@gmail.com)
|
43
43
|
# License:: MIT License
|
44
44
|
module Git
|
45
|
-
|
45
|
+
|
46
46
|
#g.config('user.name', 'Scott Chacon') # sets value
|
47
47
|
#g.config('user.email', 'email@email.com') # sets value
|
48
48
|
#g.config('user.name') # returns 'Scott Chacon'
|
@@ -82,7 +82,7 @@ module Git
|
|
82
82
|
def self.bare(git_dir, options = {})
|
83
83
|
Base.bare(git_dir, options)
|
84
84
|
end
|
85
|
-
|
85
|
+
|
86
86
|
# clones a remote repository
|
87
87
|
#
|
88
88
|
# options
|
@@ -110,7 +110,7 @@ module Git
|
|
110
110
|
repo.checkout("origin/#{options[:branch]}") if options[:branch]
|
111
111
|
Dir.chdir(repo.dir.to_s) { FileUtils.rm_r '.git' }
|
112
112
|
end
|
113
|
-
|
113
|
+
|
114
114
|
# Same as g.config, but forces it to be at the global level
|
115
115
|
#
|
116
116
|
#g.config('user.name', 'Scott Chacon') # sets value
|
@@ -139,18 +139,19 @@ module Git
|
|
139
139
|
def self.init(working_dir = '.', options = {})
|
140
140
|
Base.init(working_dir, options)
|
141
141
|
end
|
142
|
-
|
143
|
-
# returns a Hash containing information about the references
|
142
|
+
|
143
|
+
# returns a Hash containing information about the references
|
144
144
|
# of the target repository
|
145
145
|
#
|
146
146
|
# @param [String|NilClass] location the target repository location or nil for '.'
|
147
|
+
# @param [String|NilClass] ref the reference name or nil
|
147
148
|
# @return [{String=>Hash}] the available references of the target repo.
|
148
|
-
def self.ls_remote(location=nil)
|
149
|
-
Git::Lib.new.ls_remote(location)
|
149
|
+
def self.ls_remote(location = nil, ref = nil)
|
150
|
+
Git::Lib.new.ls_remote(location, ref)
|
150
151
|
end
|
151
152
|
|
152
153
|
# open an existing git working directory
|
153
|
-
#
|
154
|
+
#
|
154
155
|
# this will most likely be the most common way to create
|
155
156
|
# a git reference, referring to a working directory.
|
156
157
|
# if not provided in the options, the library will assume
|
@@ -162,5 +163,5 @@ module Git
|
|
162
163
|
def self.open(working_dir, options = {})
|
163
164
|
Base.open(working_dir, options)
|
164
165
|
end
|
165
|
-
|
166
|
+
|
166
167
|
end
|
data/lib/git/base.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'git/base/factory'
|
2
2
|
|
3
3
|
module Git
|
4
|
-
|
4
|
+
|
5
5
|
class Base
|
6
6
|
|
7
7
|
include Git::Base::Factory
|
@@ -10,7 +10,7 @@ module Git
|
|
10
10
|
def self.bare(git_dir, opts = {})
|
11
11
|
self.new({:repository => git_dir}.merge(opts))
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
14
|
# clones a git repository locally
|
15
15
|
#
|
16
16
|
# repository - http://repo.or.cz/w/sinatra.git
|
@@ -20,15 +20,15 @@ module Git
|
|
20
20
|
# :repository
|
21
21
|
#
|
22
22
|
# :bare
|
23
|
-
# or
|
23
|
+
# or
|
24
24
|
# :working_directory
|
25
25
|
# :index_file
|
26
26
|
#
|
27
27
|
def self.clone(repository, name, opts = {})
|
28
|
-
# run git-clone
|
28
|
+
# run git-clone
|
29
29
|
self.new(Git::Lib.new.clone(repository, name, opts))
|
30
30
|
end
|
31
|
-
|
31
|
+
|
32
32
|
# Returns (and initialize if needed) a Git::Config instance
|
33
33
|
#
|
34
34
|
# @return [Git::Config] the current config instance.
|
@@ -44,17 +44,17 @@ module Git
|
|
44
44
|
# :repository
|
45
45
|
#
|
46
46
|
def self.init(working_dir, opts = {})
|
47
|
-
opts[:working_directory] ||= working_dir
|
47
|
+
opts[:working_directory] ||= working_dir
|
48
48
|
opts[:repository] ||= File.join(opts[:working_directory], '.git')
|
49
|
-
|
49
|
+
|
50
50
|
FileUtils.mkdir_p(opts[:working_directory]) if opts[:working_directory] && !File.directory?(opts[:working_directory])
|
51
|
-
|
51
|
+
|
52
52
|
init_opts = {
|
53
53
|
:bare => opts[:bare]
|
54
54
|
}
|
55
55
|
|
56
56
|
opts.delete(:working_directory) if opts[:bare]
|
57
|
-
|
57
|
+
|
58
58
|
# Submodules have a .git *file* not a .git folder.
|
59
59
|
# This file's contents point to the location of
|
60
60
|
# where the git refs are held (In the parent repo)
|
@@ -65,16 +65,16 @@ module Git
|
|
65
65
|
end
|
66
66
|
|
67
67
|
Git::Lib.new(opts).init(init_opts)
|
68
|
-
|
68
|
+
|
69
69
|
self.new(opts)
|
70
70
|
end
|
71
|
-
|
71
|
+
|
72
72
|
# opens a new Git Project from a working directory
|
73
73
|
# you can specify non-standard git_dir and index file in the options
|
74
74
|
def self.open(working_dir, opts={})
|
75
75
|
self.new({:working_directory => working_dir}.merge(opts))
|
76
76
|
end
|
77
|
-
|
77
|
+
|
78
78
|
def initialize(options = {})
|
79
79
|
if working_dir = options[:working_directory]
|
80
80
|
options[:repository] ||= File.join(working_dir, '.git')
|
@@ -86,17 +86,17 @@ module Git
|
|
86
86
|
else
|
87
87
|
@logger = nil
|
88
88
|
end
|
89
|
-
|
89
|
+
|
90
90
|
@working_directory = options[:working_directory] ? Git::WorkingDirectory.new(options[:working_directory]) : nil
|
91
|
-
@repository = options[:repository] ? Git::Repository.new(options[:repository]) : nil
|
91
|
+
@repository = options[:repository] ? Git::Repository.new(options[:repository]) : nil
|
92
92
|
@index = options[:index] ? Git::Index.new(options[:index], false) : nil
|
93
93
|
end
|
94
|
-
|
94
|
+
|
95
95
|
# changes current working directory for a block
|
96
96
|
# to the git working directory
|
97
97
|
#
|
98
98
|
# example
|
99
|
-
# @git.chdir do
|
99
|
+
# @git.chdir do
|
100
100
|
# # write files
|
101
101
|
# @git.add
|
102
102
|
# @git.commit('message')
|
@@ -106,7 +106,7 @@ module Git
|
|
106
106
|
yield dir.path
|
107
107
|
end
|
108
108
|
end
|
109
|
-
|
109
|
+
|
110
110
|
#g.config('user.name', 'Scott Chacon') # sets value
|
111
111
|
#g.config('user.email', 'email@email.com') # sets value
|
112
112
|
#g.config('user.name') # returns 'Scott Chacon'
|
@@ -123,14 +123,14 @@ module Git
|
|
123
123
|
lib.config_list
|
124
124
|
end
|
125
125
|
end
|
126
|
-
|
126
|
+
|
127
127
|
# returns a reference to the working directory
|
128
128
|
# @git.dir.path
|
129
129
|
# @git.dir.writeable?
|
130
130
|
def dir
|
131
131
|
@working_directory
|
132
132
|
end
|
133
|
-
|
133
|
+
|
134
134
|
# returns reference to the git index file
|
135
135
|
def index
|
136
136
|
@index
|
@@ -141,24 +141,24 @@ module Git
|
|
141
141
|
def repo
|
142
142
|
@repository
|
143
143
|
end
|
144
|
-
|
144
|
+
|
145
145
|
# returns the repository size in bytes
|
146
146
|
def repo_size
|
147
147
|
Dir.chdir(repo.path) do
|
148
148
|
return `du -s`.chomp.split.first.to_i
|
149
149
|
end
|
150
150
|
end
|
151
|
-
|
151
|
+
|
152
152
|
def set_index(index_file, check = true)
|
153
153
|
@lib = nil
|
154
154
|
@index = Git::Index.new(index_file.to_s, check)
|
155
155
|
end
|
156
|
-
|
156
|
+
|
157
157
|
def set_working(work_dir, check = true)
|
158
158
|
@lib = nil
|
159
159
|
@working_directory = Git::WorkingDirectory.new(work_dir.to_s, check)
|
160
160
|
end
|
161
|
-
|
161
|
+
|
162
162
|
# returns +true+ if the branch exists locally
|
163
163
|
def is_local_branch?(branch)
|
164
164
|
branch_names = self.branches.local.map {|b| b.name}
|
@@ -177,15 +177,15 @@ module Git
|
|
177
177
|
branch_names.include?(branch)
|
178
178
|
end
|
179
179
|
|
180
|
-
# this is a convenience method for accessing the class that wraps all the
|
180
|
+
# this is a convenience method for accessing the class that wraps all the
|
181
181
|
# actual 'git' forked system calls. At some point I hope to replace the Git::Lib
|
182
182
|
# class with one that uses native methods or libgit C bindings
|
183
183
|
def lib
|
184
184
|
@lib ||= Git::Lib.new(self, @logger)
|
185
185
|
end
|
186
|
-
|
186
|
+
|
187
187
|
# will run a grep for 'string' on the HEAD of the git repository
|
188
|
-
#
|
188
|
+
#
|
189
189
|
# to be more surgical in your grep, you can call grep() off a specific
|
190
190
|
# git object. for example:
|
191
191
|
#
|
@@ -206,7 +206,7 @@ module Git
|
|
206
206
|
def grep(string, path_limiter = nil, opts = {})
|
207
207
|
self.object('HEAD').grep(string, path_limiter, opts)
|
208
208
|
end
|
209
|
-
|
209
|
+
|
210
210
|
# updates the repository index using the working directory content
|
211
211
|
#
|
212
212
|
# @git.add('path/to/file')
|
@@ -282,7 +282,7 @@ module Git
|
|
282
282
|
end
|
283
283
|
|
284
284
|
# commits all pending changes in the index file to the git repository
|
285
|
-
#
|
285
|
+
#
|
286
286
|
# options:
|
287
287
|
# :all
|
288
288
|
# :allow_empty
|
@@ -292,10 +292,10 @@ module Git
|
|
292
292
|
def commit(message, opts = {})
|
293
293
|
self.lib.commit(message, opts)
|
294
294
|
end
|
295
|
-
|
295
|
+
|
296
296
|
# commits all pending changes in the index file to the git repository,
|
297
297
|
# but automatically adds all modified files without having to explicitly
|
298
|
-
# calling @git.add() on them.
|
298
|
+
# calling @git.add() on them.
|
299
299
|
def commit_all(message, opts = {})
|
300
300
|
opts = {:add_all => true}.merge(opts)
|
301
301
|
self.lib.commit(message, opts)
|
@@ -305,7 +305,7 @@ module Git
|
|
305
305
|
def checkout(branch = 'master', opts = {})
|
306
306
|
self.lib.checkout(branch, opts)
|
307
307
|
end
|
308
|
-
|
308
|
+
|
309
309
|
# checks out an old version of a file
|
310
310
|
def checkout_file(version, file)
|
311
311
|
self.lib.checkout_file(version,file)
|
@@ -328,7 +328,7 @@ module Git
|
|
328
328
|
|
329
329
|
self.lib.push(remote, branch, opts)
|
330
330
|
end
|
331
|
-
|
331
|
+
|
332
332
|
# merges one or more branches into the current working branch
|
333
333
|
#
|
334
334
|
# you can specify more than one branch to merge by passing an array of branches
|
@@ -336,8 +336,9 @@ module Git
|
|
336
336
|
self.lib.merge(branch, message)
|
337
337
|
end
|
338
338
|
|
339
|
-
|
340
|
-
|
339
|
+
# rebases the current branch on top of the given branch
|
340
|
+
def rebase(branch, opts = {})
|
341
|
+
self.lib.rebase(branch, opts)
|
341
342
|
end
|
342
343
|
|
343
344
|
# iterates over the files which are unmerged
|
@@ -354,7 +355,7 @@ module Git
|
|
354
355
|
def pull(remote='origin', branch='master')
|
355
356
|
self.lib.pull(remote, branch)
|
356
357
|
end
|
357
|
-
|
358
|
+
|
358
359
|
# returns an array of Git:Remote objects
|
359
360
|
def remotes
|
360
361
|
self.lib.remotes.map { |r| Git::Remote.new(self, r) }
|
@@ -362,7 +363,7 @@ module Git
|
|
362
363
|
|
363
364
|
# adds a new remote to this repository
|
364
365
|
# url can be a git url or a Git::Base object if it's a local reference
|
365
|
-
#
|
366
|
+
#
|
366
367
|
# @git.add_remote('scotts_git', 'git://repo.or.cz/rubygit.git')
|
367
368
|
# @git.fetch('scotts_git')
|
368
369
|
# @git.merge('scotts_git/master')
|
@@ -411,37 +412,37 @@ module Git
|
|
411
412
|
# :f -> true
|
412
413
|
# :m | :message -> String
|
413
414
|
# :s -> true
|
414
|
-
#
|
415
|
+
#
|
415
416
|
def add_tag(name, *opts)
|
416
417
|
self.lib.tag(name, *opts)
|
417
418
|
self.tag(name)
|
418
419
|
end
|
419
|
-
|
420
|
-
# deletes a tag
|
421
|
-
def delete_tag(name)
|
420
|
+
|
421
|
+
# deletes a tag
|
422
|
+
def delete_tag(name)
|
422
423
|
self.lib.tag(name, {:d => true})
|
423
424
|
end
|
424
|
-
|
425
|
+
|
425
426
|
# creates an archive file of the given tree-ish
|
426
427
|
def archive(treeish, file = nil, opts = {})
|
427
428
|
self.object(treeish).archive(file, opts)
|
428
429
|
end
|
429
|
-
|
430
|
+
|
430
431
|
# repacks the repository
|
431
432
|
def repack
|
432
433
|
self.lib.repack
|
433
434
|
end
|
434
|
-
|
435
|
+
|
435
436
|
def gc
|
436
437
|
self.lib.gc
|
437
438
|
end
|
438
|
-
|
439
|
+
|
439
440
|
def apply(file)
|
440
441
|
if File.exist?(file)
|
441
442
|
self.lib.apply(file)
|
442
443
|
end
|
443
444
|
end
|
444
|
-
|
445
|
+
|
445
446
|
def apply_mail(file)
|
446
447
|
self.lib.apply_mail(file) if File.exist?(file)
|
447
448
|
end
|
@@ -454,9 +455,9 @@ module Git
|
|
454
455
|
def show(objectish=nil, path=nil)
|
455
456
|
self.lib.show(objectish, path)
|
456
457
|
end
|
457
|
-
|
458
|
+
|
458
459
|
## LOWER LEVEL INDEX OPERATIONS ##
|
459
|
-
|
460
|
+
|
460
461
|
def with_index(new_index) # :yields: new_index
|
461
462
|
old_index = @index
|
462
463
|
set_index(new_index, false)
|
@@ -464,10 +465,10 @@ module Git
|
|
464
465
|
set_index(old_index)
|
465
466
|
return_value
|
466
467
|
end
|
467
|
-
|
468
|
+
|
468
469
|
def with_temp_index &blk
|
469
470
|
# Workaround for JRUBY, since they handle the TempFile path different.
|
470
|
-
# MUST be improved to be safer and OS independent.
|
471
|
+
# MUST be improved to be safer and OS independent.
|
471
472
|
if RUBY_PLATFORM == 'java'
|
472
473
|
temp_path = "/tmp/temp-index-#{(0...15).map{ ('a'..'z').to_a[rand(26)] }.join}"
|
473
474
|
else
|
@@ -479,29 +480,29 @@ module Git
|
|
479
480
|
|
480
481
|
with_index(temp_path, &blk)
|
481
482
|
end
|
482
|
-
|
483
|
+
|
483
484
|
def checkout_index(opts = {})
|
484
485
|
self.lib.checkout_index(opts)
|
485
486
|
end
|
486
|
-
|
487
|
+
|
487
488
|
def read_tree(treeish, opts = {})
|
488
489
|
self.lib.read_tree(treeish, opts)
|
489
490
|
end
|
490
|
-
|
491
|
+
|
491
492
|
def write_tree
|
492
493
|
self.lib.write_tree
|
493
494
|
end
|
494
|
-
|
495
|
+
|
495
496
|
def write_and_commit_tree(opts = {})
|
496
497
|
tree = write_tree
|
497
498
|
commit_tree(tree, opts)
|
498
499
|
end
|
499
|
-
|
500
|
+
|
500
501
|
def update_ref(branch, commit)
|
501
502
|
branch(branch).update_ref(commit)
|
502
503
|
end
|
503
|
-
|
504
|
-
|
504
|
+
|
505
|
+
|
505
506
|
def ls_files(location=nil)
|
506
507
|
self.lib.ls_files(location)
|
507
508
|
end
|
@@ -509,14 +510,14 @@ module Git
|
|
509
510
|
def with_working(work_dir) # :yields: the Git::WorkingDirectory
|
510
511
|
return_value = false
|
511
512
|
old_working = @working_directory
|
512
|
-
set_working(work_dir)
|
513
|
+
set_working(work_dir)
|
513
514
|
Dir.chdir work_dir do
|
514
515
|
return_value = yield @working_directory
|
515
516
|
end
|
516
517
|
set_working(old_working)
|
517
518
|
return_value
|
518
519
|
end
|
519
|
-
|
520
|
+
|
520
521
|
def with_temp_working &blk
|
521
522
|
tempfile = Tempfile.new("temp-workdir")
|
522
523
|
temp_dir = tempfile.path
|
@@ -525,8 +526,8 @@ module Git
|
|
525
526
|
Dir.mkdir(temp_dir, 0700)
|
526
527
|
with_working(temp_dir, &blk)
|
527
528
|
end
|
528
|
-
|
529
|
-
|
529
|
+
|
530
|
+
|
530
531
|
# runs git rev-parse to convert the objectish to a full sha
|
531
532
|
#
|
532
533
|
# @git.revparse("HEAD^^")
|
@@ -536,11 +537,11 @@ module Git
|
|
536
537
|
def revparse(objectish)
|
537
538
|
self.lib.revparse(objectish)
|
538
539
|
end
|
539
|
-
|
540
|
+
|
540
541
|
def ls_tree(objectish)
|
541
542
|
self.lib.ls_tree(objectish)
|
542
543
|
end
|
543
|
-
|
544
|
+
|
544
545
|
def cat_file(objectish)
|
545
546
|
self.lib.object_contents(objectish)
|
546
547
|
end
|
@@ -549,7 +550,7 @@ module Git
|
|
549
550
|
def current_branch
|
550
551
|
self.lib.branch_current
|
551
552
|
end
|
552
|
-
|
553
|
+
|
553
554
|
end
|
554
|
-
|
555
|
+
|
555
556
|
end
|
data/lib/git/branch.rb
CHANGED
@@ -3,9 +3,9 @@ require 'git/path'
|
|
3
3
|
module Git
|
4
4
|
|
5
5
|
class Branch < Path
|
6
|
-
|
6
|
+
|
7
7
|
attr_accessor :full, :remote, :name
|
8
|
-
|
8
|
+
|
9
9
|
def initialize(base, name)
|
10
10
|
@full = name
|
11
11
|
@base = base
|
@@ -13,25 +13,25 @@ module Git
|
|
13
13
|
@stashes = nil
|
14
14
|
@remote, @name = parse_name(name)
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
def gcommit
|
18
18
|
@gcommit ||= @base.gcommit(@full)
|
19
19
|
@gcommit
|
20
20
|
end
|
21
|
-
|
21
|
+
|
22
22
|
def stashes
|
23
23
|
@stashes ||= Git::Stashes.new(@base)
|
24
24
|
end
|
25
|
-
|
25
|
+
|
26
26
|
def checkout
|
27
27
|
check_if_create
|
28
28
|
@base.checkout(@full)
|
29
29
|
end
|
30
|
-
|
30
|
+
|
31
31
|
def archive(file, opts = {})
|
32
32
|
@base.lib.archive(@full, file, opts)
|
33
33
|
end
|
34
|
-
|
34
|
+
|
35
35
|
# g.branch('new_branch').in_branch do
|
36
36
|
# # create new file
|
37
37
|
# # do other stuff
|
@@ -47,26 +47,26 @@ module Git
|
|
47
47
|
end
|
48
48
|
@base.checkout(old_current)
|
49
49
|
end
|
50
|
-
|
50
|
+
|
51
51
|
def create
|
52
52
|
check_if_create
|
53
53
|
end
|
54
|
-
|
54
|
+
|
55
55
|
def delete
|
56
56
|
@base.lib.branch_delete(@name)
|
57
57
|
end
|
58
|
-
|
58
|
+
|
59
59
|
def current
|
60
60
|
determine_current
|
61
61
|
end
|
62
|
-
|
62
|
+
|
63
63
|
def contains?(commit)
|
64
64
|
!@base.lib.branch_contains(commit, self.name).empty?
|
65
65
|
end
|
66
|
-
|
66
|
+
|
67
67
|
def merge(branch = nil, message = nil)
|
68
68
|
if branch
|
69
|
-
in_branch do
|
69
|
+
in_branch do
|
70
70
|
@base.merge(branch, message)
|
71
71
|
false
|
72
72
|
end
|
@@ -77,33 +77,33 @@ module Git
|
|
77
77
|
end
|
78
78
|
end
|
79
79
|
|
80
|
-
def rebase(branch)
|
81
|
-
@base.rebase(branch)
|
80
|
+
def rebase(branch, opts = {})
|
81
|
+
@base.rebase(branch, opts)
|
82
82
|
end
|
83
83
|
|
84
|
-
|
84
|
+
|
85
85
|
def update_ref(commit)
|
86
86
|
@base.lib.update_ref(@full, commit)
|
87
87
|
end
|
88
|
-
|
88
|
+
|
89
89
|
def to_a
|
90
90
|
[@full]
|
91
91
|
end
|
92
|
-
|
92
|
+
|
93
93
|
def to_s
|
94
94
|
@full
|
95
95
|
end
|
96
|
-
|
97
|
-
private
|
96
|
+
|
97
|
+
private
|
98
98
|
|
99
99
|
def check_if_create
|
100
100
|
@base.lib.branch_new(@name) rescue nil
|
101
101
|
end
|
102
|
-
|
102
|
+
|
103
103
|
def determine_current
|
104
104
|
@base.lib.branch_current == @name
|
105
105
|
end
|
106
|
-
|
106
|
+
|
107
107
|
# Given a full branch name return an Array containing the remote and branch names.
|
108
108
|
#
|
109
109
|
# Removes 'remotes' from the beggining of the name (if present).
|
@@ -114,10 +114,10 @@ module Git
|
|
114
114
|
# parse_name('master') #=> [nil, 'master']
|
115
115
|
# parse_name('origin/master') #=> ['origin', 'master']
|
116
116
|
# parse_name('remotes/origin/master') #=> ['origin', 'master']
|
117
|
-
# parse_name('origin/master/v2') #=> ['origin', 'master/v2']
|
117
|
+
# parse_name('origin/master/v2') #=> ['origin', 'master/v2']
|
118
118
|
#
|
119
119
|
# param [String] name branch full name.
|
120
|
-
# return [<Git::Remote,NilClass,String>] an Array containing the remote and branch names.
|
120
|
+
# return [<Git::Remote,NilClass,String>] an Array containing the remote and branch names.
|
121
121
|
def parse_name(name)
|
122
122
|
if name.match(/^(?:remotes)?\/([^\/]+)\/(.+)/)
|
123
123
|
return [Git::Remote.new(@base, $1), $2]
|
@@ -125,7 +125,7 @@ module Git
|
|
125
125
|
|
126
126
|
return [nil, name]
|
127
127
|
end
|
128
|
-
|
128
|
+
|
129
129
|
end
|
130
|
-
|
130
|
+
|
131
131
|
end
|
data/lib/git/lib.rb
CHANGED
@@ -76,7 +76,13 @@ module Git
|
|
76
76
|
|
77
77
|
command('clone', arr_opts)
|
78
78
|
|
79
|
-
(opts[:bare] or opts[:mirror])
|
79
|
+
return_opts = if (opts[:bare] or opts[:mirror])
|
80
|
+
{:repository => clone_dir}
|
81
|
+
else
|
82
|
+
{:working_directory => clone_dir}
|
83
|
+
end
|
84
|
+
return_opts[:log] = opts[:log] if opts.key?(:log)
|
85
|
+
return_opts
|
80
86
|
end
|
81
87
|
|
82
88
|
|
@@ -411,10 +417,10 @@ module Git
|
|
411
417
|
hsh
|
412
418
|
end
|
413
419
|
|
414
|
-
def ls_remote(location=nil)
|
420
|
+
def ls_remote(location = nil, ref = nil)
|
415
421
|
location ||= '.'
|
416
422
|
Hash.new{ |h,k| h[k] = {} }.tap do |hsh|
|
417
|
-
command_lines('ls-remote', [location], false).each do |line|
|
423
|
+
command_lines('ls-remote', [location, ref].compact, false).each do |line|
|
418
424
|
(sha, info) = line.split("\t")
|
419
425
|
(ref, type, name) = info.split('/', 3)
|
420
426
|
type ||= 'head'
|
@@ -666,8 +672,15 @@ module Git
|
|
666
672
|
command('merge', arr_opts)
|
667
673
|
end
|
668
674
|
|
669
|
-
def rebase(branch)
|
670
|
-
|
675
|
+
def rebase(branch, opts = {})
|
676
|
+
arr_opts = []
|
677
|
+
arr_opts << branch
|
678
|
+
if opts[:strategy_option]
|
679
|
+
arr_opts << '--merge'
|
680
|
+
arr_opts << '--strategy-option' << opts[:strategy_option]
|
681
|
+
end
|
682
|
+
|
683
|
+
command('rebase', arr_opts)
|
671
684
|
end
|
672
685
|
|
673
686
|
def unmerged
|
data/lib/git/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: git-ce
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.0.
|
4
|
+
version: 1.5.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Scott Chacon and others
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-09-
|
11
|
+
date: 2018-09-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|