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 CHANGED
@@ -26,6 +26,8 @@ require 'git/author'
26
26
  require 'git/stashes'
27
27
  require 'git/stash'
28
28
 
29
+ require 'git/stream'
30
+
29
31
 
30
32
  # Git/Ruby Library
31
33
  #
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: peterwald-git
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott Chacon