peterwald-git 1.1.2 → 1.1.3
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.
- data/lib/git.rb +2 -0
- data/lib/git/author.rb +8 -1
- data/lib/git/base.rb +8 -0
- data/lib/git/lib.rb +11 -0
- metadata +1 -1
data/lib/git.rb
CHANGED
data/lib/git/author.rb
CHANGED
@@ -2,7 +2,7 @@ module Git
|
|
2
2
|
class Author
|
3
3
|
attr_accessor :name, :email, :date
|
4
4
|
|
5
|
-
def initialize(author_string)
|
5
|
+
def initialize(author_string = nil)
|
6
6
|
if m = /(.*?) <(.*?)> (\d+) (.*)/.match(author_string)
|
7
7
|
@name = m[1]
|
8
8
|
@email = m[2]
|
@@ -10,5 +10,12 @@ module Git
|
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
|
+
def self.from_parts(name, email, date = Time.now)
|
14
|
+
a = Author.new
|
15
|
+
a.name = name
|
16
|
+
a.email = email
|
17
|
+
a.date = date
|
18
|
+
return a
|
19
|
+
end
|
13
20
|
end
|
14
21
|
end
|
data/lib/git/base.rb
CHANGED
@@ -364,6 +364,14 @@ module Git
|
|
364
364
|
self.object(treeish).archive(file, opts)
|
365
365
|
end
|
366
366
|
|
367
|
+
# use a stream to import into the repository
|
368
|
+
def import_stream
|
369
|
+
stream = Git::Stream.new
|
370
|
+
yield stream
|
371
|
+
|
372
|
+
self.lib.fast_import(stream)
|
373
|
+
end
|
374
|
+
|
367
375
|
# repacks the repository
|
368
376
|
def repack
|
369
377
|
self.lib.repack
|
data/lib/git/lib.rb
CHANGED
@@ -581,6 +581,17 @@ module Git
|
|
581
581
|
command('checkout-index', arr_opts)
|
582
582
|
end
|
583
583
|
|
584
|
+
def fast_import(stream)
|
585
|
+
tmp = Tempfile.new("stream-file")
|
586
|
+
tmp.write(stream.to_s)
|
587
|
+
tmp.flush
|
588
|
+
begin
|
589
|
+
command('fast-import',"--date-format=rfc2822",true,"< #{escape tmp.path}")
|
590
|
+
ensure
|
591
|
+
tmp.close(true)
|
592
|
+
end
|
593
|
+
end
|
594
|
+
|
584
595
|
# creates an archive file
|
585
596
|
#
|
586
597
|
# options
|