git 2.0.0.pre3 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/lib/git/object.rb CHANGED
@@ -1,16 +1,18 @@
1
+ require 'git/author'
2
+ require 'git/diff'
3
+ require 'git/errors'
4
+ require 'git/log'
5
+
1
6
  module Git
2
-
3
- class GitTagNameDoesNotExist< StandardError
4
- end
5
-
7
+
6
8
  # represents a git object
7
9
  class Object
8
-
10
+
9
11
  class AbstractObject
10
12
  attr_accessor :objectish, :type, :mode
11
13
 
12
14
  attr_writer :size
13
-
15
+
14
16
  def initialize(base, objectish)
15
17
  @base = base
16
18
  @objectish = objectish.to_s
@@ -23,11 +25,11 @@ module Git
23
25
  def sha
24
26
  @sha ||= @base.lib.revparse(@objectish)
25
27
  end
26
-
28
+
27
29
  def size
28
30
  @size ||= @base.lib.object_size(@objectish)
29
31
  end
30
-
32
+
31
33
  # Get the object's contents.
32
34
  # If no block is given, the contents are cached in memory and returned as a string.
33
35
  # If a block is given, it yields an IO object (via IO::popen) which could be used to
@@ -41,108 +43,108 @@ module Git
41
43
  @contents ||= @base.lib.object_contents(@objectish)
42
44
  end
43
45
  end
44
-
46
+
45
47
  def contents_array
46
48
  self.contents.split("\n")
47
49
  end
48
-
50
+
49
51
  def to_s
50
52
  @objectish
51
53
  end
52
-
54
+
53
55
  def grep(string, path_limiter = nil, opts = {})
54
56
  opts = {:object => sha, :path_limiter => path_limiter}.merge(opts)
55
57
  @base.lib.grep(string, opts)
56
58
  end
57
-
59
+
58
60
  def diff(objectish)
59
61
  Git::Diff.new(@base, @objectish, objectish)
60
62
  end
61
-
63
+
62
64
  def log(count = 30)
63
65
  Git::Log.new(@base, count).object(@objectish)
64
66
  end
65
-
67
+
66
68
  # creates an archive of this object (tree)
67
69
  def archive(file = nil, opts = {})
68
70
  @base.lib.archive(@objectish, file, opts)
69
71
  end
70
-
72
+
71
73
  def tree?; false; end
72
-
74
+
73
75
  def blob?; false; end
74
-
76
+
75
77
  def commit?; false; end
76
78
 
77
79
  def tag?; false; end
78
-
80
+
79
81
  end
80
-
81
-
82
+
83
+
82
84
  class Blob < AbstractObject
83
-
85
+
84
86
  def initialize(base, sha, mode = nil)
85
87
  super(base, sha)
86
88
  @mode = mode
87
89
  end
88
-
90
+
89
91
  def blob?
90
92
  true
91
93
  end
92
94
 
93
95
  end
94
-
96
+
95
97
  class Tree < AbstractObject
96
-
98
+
97
99
  def initialize(base, sha, mode = nil)
98
100
  super(base, sha)
99
101
  @mode = mode
100
102
  @trees = nil
101
103
  @blobs = nil
102
104
  end
103
-
105
+
104
106
  def children
105
107
  blobs.merge(subtrees)
106
108
  end
107
-
109
+
108
110
  def blobs
109
111
  @blobs ||= check_tree[:blobs]
110
112
  end
111
113
  alias_method :files, :blobs
112
-
114
+
113
115
  def trees
114
116
  @trees ||= check_tree[:trees]
115
117
  end
116
118
  alias_method :subtrees, :trees
117
119
  alias_method :subdirectories, :trees
118
-
120
+
119
121
  def full_tree
120
122
  @base.lib.full_tree(@objectish)
121
123
  end
122
-
124
+
123
125
  def depth
124
126
  @base.lib.tree_depth(@objectish)
125
127
  end
126
-
128
+
127
129
  def tree?
128
130
  true
129
131
  end
130
-
132
+
131
133
  private
132
134
 
133
135
  # actually run the git command
134
136
  def check_tree
135
137
  @trees = {}
136
138
  @blobs = {}
137
-
139
+
138
140
  data = @base.lib.ls_tree(@objectish)
139
141
 
140
- data['tree'].each do |key, tree|
141
- @trees[key] = Git::Object::Tree.new(@base, tree[:sha], tree[:mode])
142
+ data['tree'].each do |key, tree|
143
+ @trees[key] = Git::Object::Tree.new(@base, tree[:sha], tree[:mode])
142
144
  end
143
-
144
- data['blob'].each do |key, blob|
145
- @blobs[key] = Git::Object::Blob.new(@base, blob[:sha], blob[:mode])
145
+
146
+ data['blob'].each do |key, blob|
147
+ @blobs[key] = Git::Object::Blob.new(@base, blob[:sha], blob[:mode])
146
148
  end
147
149
 
148
150
  {
@@ -150,11 +152,11 @@ module Git
150
152
  :blobs => @blobs
151
153
  }
152
154
  end
153
-
155
+
154
156
  end
155
-
157
+
156
158
  class Commit < AbstractObject
157
-
159
+
158
160
  def initialize(base, sha, init = nil)
159
161
  super(base, sha)
160
162
  @tree = nil
@@ -166,48 +168,48 @@ module Git
166
168
  set_commit(init)
167
169
  end
168
170
  end
169
-
171
+
170
172
  def message
171
173
  check_commit
172
174
  @message
173
175
  end
174
-
176
+
175
177
  def name
176
178
  @base.lib.namerev(sha)
177
179
  end
178
-
180
+
179
181
  def gtree
180
182
  check_commit
181
183
  Tree.new(@base, @tree)
182
184
  end
183
-
185
+
184
186
  def parent
185
187
  parents.first
186
188
  end
187
-
189
+
188
190
  # array of all parent commits
189
191
  def parents
190
192
  check_commit
191
- @parents
193
+ @parents
192
194
  end
193
-
195
+
194
196
  # git author
195
- def author
197
+ def author
196
198
  check_commit
197
199
  @author
198
200
  end
199
-
201
+
200
202
  def author_date
201
203
  author.date
202
204
  end
203
-
205
+
204
206
  # git author
205
207
  def committer
206
208
  check_commit
207
209
  @committer
208
210
  end
209
-
210
- def committer_date
211
+
212
+ def committer_date
211
213
  committer.date
212
214
  end
213
215
  alias_method :date, :committer_date
@@ -215,7 +217,7 @@ module Git
215
217
  def diff_parent
216
218
  diff(parent)
217
219
  end
218
-
220
+
219
221
  def set_commit(data)
220
222
  @sha ||= data['sha']
221
223
  @committer = Git::Author.new(data['committer'])
@@ -224,26 +226,26 @@ module Git
224
226
  @parents = data['parent'].map{ |sha| Git::Object::Commit.new(@base, sha) }
225
227
  @message = data['message'].chomp
226
228
  end
227
-
229
+
228
230
  def commit?
229
231
  true
230
232
  end
231
233
 
232
234
  private
233
-
235
+
234
236
  # see if this object has been initialized and do so if not
235
237
  def check_commit
236
238
  return if @tree
237
-
239
+
238
240
  data = @base.lib.commit_data(@objectish)
239
241
  set_commit(data)
240
242
  end
241
-
243
+
242
244
  end
243
-
245
+
244
246
  class Tag < AbstractObject
245
247
  attr_accessor :name
246
-
248
+
247
249
  def initialize(base, sha, name)
248
250
  super(base, sha)
249
251
  @name = name
@@ -259,7 +261,7 @@ module Git
259
261
  check_tag()
260
262
  return @message
261
263
  end
262
-
264
+
263
265
  def tag?
264
266
  true
265
267
  end
@@ -274,7 +276,7 @@ module Git
274
276
  def check_tag
275
277
  return if @loaded
276
278
 
277
- if !self.annotated?
279
+ if !self.annotated?
278
280
  @message = @tagger = nil
279
281
  else
280
282
  tdata = @base.lib.tag_data(@name)
@@ -284,29 +286,29 @@ module Git
284
286
 
285
287
  @loaded = true
286
288
  end
287
-
289
+
288
290
  end
289
-
291
+
290
292
  # if we're calling this, we don't know what type it is yet
291
293
  # so this is our little factory method
292
294
  def self.new(base, objectish, type = nil, is_tag = false)
293
295
  if is_tag
294
296
  sha = base.lib.tag_sha(objectish)
295
297
  if sha == ''
296
- raise Git::GitTagNameDoesNotExist.new(objectish)
298
+ raise Git::UnexpectedResultError.new("Tag '#{objectish}' does not exist.")
297
299
  end
298
300
  return Git::Object::Tag.new(base, sha, objectish)
299
301
  end
300
-
302
+
301
303
  type ||= base.lib.object_type(objectish)
302
304
  klass =
303
305
  case type
304
- when /blob/ then Blob
306
+ when /blob/ then Blob
305
307
  when /commit/ then Commit
306
308
  when /tree/ then Tree
307
309
  end
308
310
  klass.new(base, objectish)
309
311
  end
310
-
312
+
311
313
  end
312
314
  end
data/lib/git/status.rb CHANGED
@@ -1,6 +1,12 @@
1
1
  module Git
2
+ # The status class gets the status of a git repository
2
3
  #
3
- # A class for git status
4
+ # This identifies which files have been modified, added, or deleted from the
5
+ # worktree. Untracked files are also identified.
6
+ #
7
+ # The Status object is an Enumerable that contains StatusFile objects.
8
+ #
9
+ # @api public
4
10
  #
5
11
  class Status
6
12
  include Enumerable
@@ -31,7 +37,6 @@ module Git
31
37
  changed.member?(file)
32
38
  end
33
39
 
34
- #
35
40
  # Returns an Enumerable containing files that have been added.
36
41
  # File path starts at git base directory
37
42
  #
@@ -40,8 +45,8 @@ module Git
40
45
  @files.select { |_k, f| f.type == 'A' }
41
46
  end
42
47
 
43
- #
44
48
  # Determines whether the given file has been added to the repository
49
+ #
45
50
  # File path starts at git base directory
46
51
  #
47
52
  # @param file [String] The name of the file.
@@ -126,9 +131,63 @@ module Git
126
131
 
127
132
  # subclass that does heavy lifting
128
133
  class StatusFile
129
- attr_accessor :path, :type, :stage, :untracked
130
- attr_accessor :mode_index, :mode_repo
131
- attr_accessor :sha_index, :sha_repo
134
+ # @!attribute [r] path
135
+ # The path of the file relative to the project root directory
136
+ # @return [String]
137
+ attr_accessor :path
138
+
139
+ # @!attribute [r] type
140
+ # The type of change
141
+ #
142
+ # * 'M': modified
143
+ # * 'A': added
144
+ # * 'D': deleted
145
+ # * nil: ???
146
+ #
147
+ # @return [String]
148
+ attr_accessor :type
149
+
150
+ # @!attribute [r] mode_index
151
+ # The mode of the file in the index
152
+ # @return [String]
153
+ # @example 100644
154
+ #
155
+ attr_accessor :mode_index
156
+
157
+ # @!attribute [r] mode_repo
158
+ # The mode of the file in the repo
159
+ # @return [String]
160
+ # @example 100644
161
+ #
162
+ attr_accessor :mode_repo
163
+
164
+ # @!attribute [r] sha_index
165
+ # The sha of the file in the index
166
+ # @return [String]
167
+ # @example 123456
168
+ #
169
+ attr_accessor :sha_index
170
+
171
+ # @!attribute [r] sha_repo
172
+ # The sha of the file in the repo
173
+ # @return [String]
174
+ # @example 123456
175
+ attr_accessor :sha_repo
176
+
177
+ # @!attribute [r] untracked
178
+ # Whether the file is untracked
179
+ # @return [Boolean]
180
+ attr_accessor :untracked
181
+
182
+ # @!attribute [r] stage
183
+ # The stage of the file
184
+ #
185
+ # * '0': the unmerged state
186
+ # * '1': the common ancestor (or original) version
187
+ # * '2': "our version" from the current branch head
188
+ # * '3': "their version" from the other branch head
189
+ # @return [String]
190
+ attr_accessor :stage
132
191
 
133
192
  def initialize(base, hash)
134
193
  @base = base
@@ -158,10 +217,19 @@ module Git
158
217
  private
159
218
 
160
219
  def construct_status
220
+ # Lists all files in the index and the worktree
221
+ # git ls-files --stage
222
+ # { file => { path: file, mode_index: '100644', sha_index: 'dd4fc23', stage: '0' } }
161
223
  @files = @base.lib.ls_files
162
224
 
225
+ # Lists files in the worktree that are not in the index
226
+ # Add untracked files to @files
163
227
  fetch_untracked
228
+
229
+ # Lists files that are different between the index vs. the worktree
164
230
  fetch_modified
231
+
232
+ # Lists files that are different between the repo HEAD vs. the worktree
165
233
  fetch_added
166
234
 
167
235
  @files.each do |k, file_hash|
@@ -170,28 +238,30 @@ module Git
170
238
  end
171
239
 
172
240
  def fetch_untracked
173
- ignore = @base.lib.ignored_files
174
-
175
- root_dir = @base.dir.path
176
- Dir.glob('**/*', File::FNM_DOTMATCH, base: root_dir) do |file|
177
- next if @files[file] || File.directory?(File.join(root_dir, file)) ||
178
- ignore.include?(file) || file =~ %r{^.git\/.+}
179
-
241
+ # git ls-files --others --exclude-standard, chdir: @git_work_dir)
242
+ # { file => { path: file, untracked: true } }
243
+ @base.lib.untracked_files.each do |file|
180
244
  @files[file] = { path: file, untracked: true }
181
245
  end
182
246
  end
183
247
 
184
248
  def fetch_modified
185
- # find modified in tree
249
+ # Files changed between the index vs. the worktree
250
+ # git diff-files
251
+ # { file => { path: file, type: 'M', mode_index: '100644', mode_repo: '100644', sha_index: '0000000', :sha_repo: '52c6c4e' } }
186
252
  @base.lib.diff_files.each do |path, data|
187
253
  @files[path] ? @files[path].merge!(data) : @files[path] = data
188
254
  end
189
255
  end
190
256
 
191
257
  def fetch_added
192
- # find added but not committed - new files
258
+ unless @base.lib.empty?
259
+ # Files changed between the repo HEAD vs. the worktree
260
+ # git diff-index HEAD
261
+ # { file => { path: file, type: 'M', mode_index: '100644', mode_repo: '100644', sha_index: '0000000', :sha_repo: '52c6c4e' } }
193
262
  @base.lib.diff_index('HEAD').each do |path, data|
194
- @files[path] ? @files[path].merge!(data) : @files[path] = data
263
+ @files[path] ? @files[path].merge!(data) : @files[path] = data
264
+ end
195
265
  end
196
266
  end
197
267
  end
data/lib/git/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Git
2
2
  # The current gem version
3
3
  # @return [String] the current gem version.
4
- VERSION='2.0.0.pre3'
4
+ VERSION='2.0.1'
5
5
  end
data/lib/git.rb CHANGED
@@ -1,22 +1,21 @@
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__)))
1
+ require 'active_support'
2
+ require 'active_support/deprecation'
3
+
4
+ module Git
5
+ Deprecation = ActiveSupport::Deprecation.new('3.0', 'Git')
6
+ end
5
7
 
6
8
  require 'git/author'
7
9
  require 'git/base'
8
10
  require 'git/branch'
9
11
  require 'git/branches'
10
- require 'git/command_line_error'
11
12
  require 'git/command_line_result'
12
13
  require 'git/command_line'
13
14
  require 'git/config'
14
15
  require 'git/diff'
15
16
  require 'git/encoding_utils'
16
- require 'git/error'
17
+ require 'git/errors'
17
18
  require 'git/escaped_path'
18
- require 'git/failed_error'
19
- require 'git/git_execute_error'
20
19
  require 'git/index'
21
20
  require 'git/lib'
22
21
  require 'git/log'
@@ -24,11 +23,9 @@ require 'git/object'
24
23
  require 'git/path'
25
24
  require 'git/remote'
26
25
  require 'git/repository'
27
- require 'git/signaled_error'
28
26
  require 'git/status'
29
27
  require 'git/stash'
30
28
  require 'git/stashes'
31
- require 'git/timeout_error'
32
29
  require 'git/url'
33
30
  require 'git/version'
34
31
  require 'git/working_directory'
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.pre3
4
+ version: 2.0.1
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: 2024-03-15 00:00:00.000000000 Z
11
+ date: 2024-05-21 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '5.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '5.0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: addressable
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -52,6 +66,20 @@ dependencies:
52
66
  - - "~>"
53
67
  - !ruby/object:Gem::Version
54
68
  version: '1.8'
69
+ - !ruby/object:Gem::Dependency
70
+ name: create_github_release
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.4'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.4'
55
83
  - !ruby/object:Gem::Dependency
56
84
  name: minitar
57
85
  requirement: !ruby/object:Gem::Requirement
@@ -167,18 +195,17 @@ executables: []
167
195
  extensions: []
168
196
  extra_rdoc_files: []
169
197
  files:
170
- - ".github/stale.yml"
198
+ - ".github/issue_template.md"
199
+ - ".github/pull_request_template.md"
171
200
  - ".github/workflows/continuous_integration.yml"
201
+ - ".github/workflows/experimental_continuous_integration.yml"
172
202
  - ".gitignore"
173
203
  - ".yardopts"
174
204
  - CHANGELOG.md
175
205
  - CONTRIBUTING.md
176
- - Dockerfile.changelog-rs
177
206
  - Gemfile
178
- - ISSUE_TEMPLATE.md
179
207
  - LICENSE
180
208
  - MAINTAINERS.md
181
- - PULL_REQUEST_TEMPLATE.md
182
209
  - README.md
183
210
  - RELEASING.md
184
211
  - Rakefile
@@ -186,19 +213,15 @@ files:
186
213
  - lib/git.rb
187
214
  - lib/git/author.rb
188
215
  - lib/git/base.rb
189
- - lib/git/base/factory.rb
190
216
  - lib/git/branch.rb
191
217
  - lib/git/branches.rb
192
218
  - lib/git/command_line.rb
193
- - lib/git/command_line_error.rb
194
219
  - lib/git/command_line_result.rb
195
220
  - lib/git/config.rb
196
221
  - lib/git/diff.rb
197
222
  - lib/git/encoding_utils.rb
198
- - lib/git/error.rb
223
+ - lib/git/errors.rb
199
224
  - lib/git/escaped_path.rb
200
- - lib/git/failed_error.rb
201
- - lib/git/git_execute_error.rb
202
225
  - lib/git/index.rb
203
226
  - lib/git/lib.rb
204
227
  - lib/git/log.rb
@@ -206,11 +229,9 @@ files:
206
229
  - lib/git/path.rb
207
230
  - lib/git/remote.rb
208
231
  - lib/git/repository.rb
209
- - lib/git/signaled_error.rb
210
232
  - lib/git/stash.rb
211
233
  - lib/git/stashes.rb
212
234
  - lib/git/status.rb
213
- - lib/git/timeout_error.rb
214
235
  - lib/git/url.rb
215
236
  - lib/git/version.rb
216
237
  - lib/git/working_directory.rb
@@ -222,8 +243,8 @@ licenses:
222
243
  metadata:
223
244
  homepage_uri: http://github.com/ruby-git/ruby-git
224
245
  source_code_uri: http://github.com/ruby-git/ruby-git
225
- changelog_uri: https://rubydoc.info/gems/git/2.0.0.pre3/file/CHANGELOG.md
226
- documentation_uri: https://rubydoc.info/gems/git/2.0.0.pre3
246
+ changelog_uri: https://rubydoc.info/gems/git/2.0.1/file/CHANGELOG.md
247
+ documentation_uri: https://rubydoc.info/gems/git/2.0.1
227
248
  post_install_message:
228
249
  rdoc_options: []
229
250
  require_paths:
@@ -240,7 +261,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
240
261
  version: '0'
241
262
  requirements:
242
263
  - git 2.28.0 or greater
243
- rubygems_version: 3.5.3
264
+ rubygems_version: 3.5.9
244
265
  signing_key:
245
266
  specification_version: 4
246
267
  summary: An API to create, read, and manipulate Git repositories
data/.github/stale.yml DELETED
@@ -1,25 +0,0 @@
1
- # Probot: Stale
2
- # https://github.com/probot/stale
3
-
4
- # Number of days of inactivity before an issue becomes stale
5
- daysUntilStale: 60
6
-
7
- # Number of days of inactivity before a stale issue is closed
8
- # Set to false to disable. If disabled, issues still need to be closed
9
- # manually, but will remain marked as stale.
10
- daysUntilClose: false
11
-
12
- # Issues with these labels will never be considered stale
13
- exemptLabels:
14
- - pinned
15
- - security
16
-
17
- # Label to use when marking an issue as stale
18
- staleLabel: stale
19
-
20
- # Comment to post when marking an issue as stale. Set to `false` to disable
21
- markComment: >
22
- A friendly reminder that this issue had no activity for 60 days.
23
-
24
- # Comment to post when closing a stale issue. Set to `false` to disable
25
- closeComment: false