grit 2.1.0 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of grit might be problematic. Click here for more details.

@@ -1,3 +1,7 @@
1
+ == HEAD
2
+ * Minor Enhancements
3
+ * Add Grit::Index#delete to allow deletions of files from the index.
4
+
1
5
  == 2.1.0 / 2010-08-04
2
6
  * Major Enhancements
3
7
  * Add support for parsing annotated tag objects.
data/Rakefile CHANGED
@@ -98,7 +98,7 @@ task :release => :build do
98
98
  sh "git commit --allow-empty -a -m 'Release #{version}'"
99
99
  sh "git tag v#{version}"
100
100
  sh "git push origin master"
101
- sh "git push v#{version}"
101
+ sh "git push origin v#{version}"
102
102
  sh "gem push pkg/#{name}-#{version}.gem"
103
103
  end
104
104
 
@@ -4,8 +4,8 @@ Gem::Specification.new do |s|
4
4
  s.rubygems_version = '1.3.5'
5
5
 
6
6
  s.name = 'grit'
7
- s.version = '2.1.0'
8
- s.date = '2010-08-04'
7
+ s.version = '2.2.0'
8
+ s.date = '2010-08-19'
9
9
  s.rubyforge_project = 'grit'
10
10
 
11
11
  s.summary = "Ruby Git bindings."
@@ -51,7 +51,7 @@ require 'grit/blame'
51
51
  require 'grit/merge'
52
52
 
53
53
  module Grit
54
- VERSION = '2.1.0'
54
+ VERSION = '2.2.0'
55
55
 
56
56
  class << self
57
57
  # Set +debug+ to true to log all git calls and responses
@@ -1,21 +1,36 @@
1
1
  module Grit
2
2
 
3
3
  class Index
4
- attr_accessor :repo, :tree, :current_tree
4
+ # Public: Gets/Sets the Grit::Repo to which this index belongs.
5
+ attr_accessor :repo
5
6
 
7
+ # Public: Gets/Sets the Hash tree map that holds the changes to be made
8
+ # in the next commit.
9
+ attr_accessor :tree
10
+
11
+ # Public: Gets/Sets the Grit::Tree object representing the tree upon
12
+ # which the next commit will be based.
13
+ attr_accessor :current_tree
14
+
15
+ # Initialize a new Index object.
16
+ #
17
+ # repo - The Grit::Repo to which the index belongs.
18
+ #
19
+ # Returns the newly initialized Grit::Index.
6
20
  def initialize(repo)
7
21
  self.repo = repo
8
22
  self.tree = {}
9
23
  self.current_tree = nil
10
24
  end
11
25
 
12
- # Add a file to the index
13
- # +path+ is the path (including filename)
14
- # +data+ is the binary contents of the file
26
+ # Public: Add a file to the index.
15
27
  #
16
- # Returns nothing
17
- def add(file_path, data)
18
- path = file_path.split('/')
28
+ # path - The String file path including filename (no slash prefix).
29
+ # data - The String binary contents of the file.
30
+ #
31
+ # Returns nothing.
32
+ def add(path, data)
33
+ path = path.split('/')
19
34
  filename = path.pop
20
35
 
21
36
  current = self.tree
@@ -29,31 +44,49 @@ module Grit
29
44
  current[filename] = data
30
45
  end
31
46
 
32
- # Sets the current tree
33
- # +tree+ the branch/tag/sha... to use - a string
47
+ # Public: Delete the given file from the index.
48
+ #
49
+ # path - The String file path including filename (no slash prefix).
50
+ #
51
+ # Returns nothing.
52
+ def delete(path)
53
+ add(path, false)
54
+ end
55
+
56
+ # Public: Read the contents of the given Tree into the index to use as a
57
+ # starting point for the index.
58
+ #
59
+ # tree - The String branch/tag/sha of the Git tree object.
34
60
  #
35
- # Returns index (self)
61
+ # Returns nothing.
36
62
  def read_tree(tree)
37
63
  self.current_tree = self.repo.tree(tree)
38
64
  end
39
65
 
40
- # Commit the contents of the index
41
- # +message+ is the commit message [nil]
42
- # +parents+ is one or more commits to attach this commit to to form a new head [nil]
43
- # +actor+ is the details of the user making the commit [nil]
44
- # +last_tree+ is a tree to compare with - to avoid making empty commits [nil]
45
- # +head+ is the branch to write this head to [master]
66
+ # Public: Commit the contents of the index
46
67
  #
47
- # Returns a String of the SHA1 of the commit
48
- def commit(message, parents = nil, actor = nil, last_tree = nil, head = 'master')
68
+ # message - The String commit message.
69
+ # parents - Array of String commit SHA1s or Grit::Commit objects to
70
+ # attach this commit to to form a new head (default: []).
71
+ # actor - The Grit::Actor details of the user making the commit
72
+ # (default: nil).
73
+ # last_tree - The String SHA1 of a tree to compare with in order to avoid
74
+ # making empty commits (default: nil).
75
+ # head - The String branch name to write this head to
76
+ # (default: "master").
77
+ #
78
+ # Returns a String of the SHA1 of the new commit.
79
+ def commit(message, parents = [], actor = nil, last_tree = nil, head = 'master')
49
80
  tree_sha1 = write_tree(self.tree, self.current_tree)
50
- return false if tree_sha1 == last_tree # don't write identical commits
81
+
82
+ # don't write identical commits
83
+ return false if tree_sha1 == last_tree
51
84
 
52
85
  contents = []
53
86
  contents << ['tree', tree_sha1].join(' ')
54
87
  parents.each do |p|
55
- contents << ['parent', p].join(' ') if p
56
- end if parents
88
+ contents << ['parent', p].join(' ')
89
+ end
57
90
 
58
91
  if actor
59
92
  name = actor.name
@@ -75,10 +108,15 @@ module Grit
75
108
  self.repo.update_ref(head, commit_sha1)
76
109
  end
77
110
 
78
- # Recursively write a tree to the index
79
- # +tree+ is the tree
111
+ # Recursively write a tree to the index.
112
+ #
113
+ # tree - The Hash tree map:
114
+ # key - The String directory or filename.
115
+ # val - The Hash submap or the String contents of the file.
116
+ # now_tree - The Grit::Tree representing the a previous tree upon which
117
+ # this tree will be based (default: nil).
80
118
  #
81
- # Returns the SHA1 String of the tree
119
+ # Returns the String SHA1 String of the tree.
82
120
  def write_tree(tree, now_tree = nil)
83
121
  tree_contents = {}
84
122
 
@@ -104,16 +142,20 @@ module Grit
104
142
  sha = [sha].pack("H*")
105
143
  str = "%s %s\0%s" % ['40000', k, sha]
106
144
  tree_contents[k + '/'] = str
145
+ when false
146
+ tree_contents.delete(k)
107
147
  end
108
148
  end
149
+
109
150
  tr = tree_contents.sort.map { |k, v| v }.join('')
110
151
  self.repo.git.put_raw_object(tr, 'tree')
111
152
  end
112
153
 
113
- # Write the blob to the index
114
- # +data+ is the data to write
154
+ # Write a blob to the index.
155
+ #
156
+ # data - The String data to write.
115
157
  #
116
- # Returns the SHA1 String of the blob
158
+ # Returns the String SHA1 of the new blob.
117
159
  def write_blob(data)
118
160
  self.repo.git.put_raw_object(data, 'blob')
119
161
  end
@@ -3,6 +3,8 @@ module Grit
3
3
  class Status
4
4
  include Enumerable
5
5
 
6
+ attr_reader :files
7
+
6
8
  @base = nil
7
9
  @files = nil
8
10
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grit
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Preston-Werner
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2010-08-04 00:00:00 -06:00
13
+ date: 2010-08-19 00:00:00 -07:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency