git 2.0.1 → 2.1.1
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +23 -0
- data/README.md +18 -6
- data/lib/git/base.rb +64 -38
- data/lib/git/escaped_path.rb +1 -1
- data/lib/git/lib.rb +77 -24
- data/lib/git/log.rb +65 -4
- data/lib/git/status.rb +46 -8
- data/lib/git/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b171ab737c87e925d5752b52f2f05bdd2361592624d88b8db8db380dde051019
|
4
|
+
data.tar.gz: d7b3b7cdaba4996288c4c0e8fffe7819da6c0933ade68ca810d9fb3519d5cda0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '08dd5a4ea7b07230642e2dd87fca85ea634890f4700b77a996b3ff4443fc62d3c11a230c082c4d5b2c45c6c7d6916d9b98ce7362676e72d1a4bdd6f0fe2043e6'
|
7
|
+
data.tar.gz: 568111f5579b6b1728974dbfa12dc4d742f3715e951645dbed9a54d91399492157b77659b2e956ee995c142c8dbb01f3ee07357fb4db2a9c2bd0e1870e83dc79
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,29 @@
|
|
5
5
|
|
6
6
|
# Change Log
|
7
7
|
|
8
|
+
## v2.1.1 (2024-06-01)
|
9
|
+
|
10
|
+
[Full Changelog](https://github.com/ruby-git/ruby-git/compare/v2.1.0..v2.1.1)
|
11
|
+
|
12
|
+
Changes since v2.1.0:
|
13
|
+
|
14
|
+
* 6ce3d4d Handle ignored files with quoted (non-ASCII) filenames
|
15
|
+
* dd8e8d4 Supply all of the _specific_ color options too
|
16
|
+
* 749a72d Memoize all of the significant calls in Git::Status
|
17
|
+
* 2bacccc When core.ignoreCase, check for untracked files case-insensitively
|
18
|
+
* 7758ee4 When core.ignoreCase, check for deleted files case-insensitively
|
19
|
+
* 993eb78 When core.ignoreCase, check for added files case-insensitively
|
20
|
+
* d943bf4 When core.ignoreCase, check for changed files case-insensitively
|
21
|
+
|
22
|
+
## v2.1.0 (2024-05-31)
|
23
|
+
|
24
|
+
[Full Changelog](https://github.com/ruby-git/ruby-git/compare/v2.0.1..v2.1.0)
|
25
|
+
|
26
|
+
Changes since v2.0.1:
|
27
|
+
|
28
|
+
* 93c8210 Add Git::Log#max_count
|
29
|
+
* d84097b Update YARDoc for a few a few method
|
30
|
+
|
8
31
|
## v2.0.1 (2024-05-21)
|
9
32
|
|
10
33
|
[Full Changelog](https://github.com/ruby-git/ruby-git/compare/v2.0.0..v2.0.1)
|
data/README.md
CHANGED
@@ -101,16 +101,28 @@ directory, in the index and in the repository. Similar to running 'git status'
|
|
101
101
|
|
102
102
|
**Git::Remote**- A reference to a remote repository that is tracked by this repository.
|
103
103
|
|
104
|
-
**Git::Log** - An Enumerable object that references all the `Git::Object::Commit`
|
105
|
-
|
104
|
+
**Git::Log** - An Enumerable object that references all the `Git::Object::Commit`
|
105
|
+
objects that encompass your log query, which can be constructed through methods on
|
106
|
+
the `Git::Log object`, like:
|
106
107
|
|
107
|
-
|
108
|
+
```ruby
|
109
|
+
git.log
|
110
|
+
.max_count(:all)
|
111
|
+
.object('README.md')
|
112
|
+
.since('10 years ago')
|
113
|
+
.between('v1.0.7', 'HEAD')
|
114
|
+
.map { |commit| commit.sha }
|
115
|
+
```
|
108
116
|
|
109
|
-
|
117
|
+
A maximum of 30 commits are returned if `max_count` is not called. To get all commits
|
118
|
+
that match the log query, call `max_count(:all)`.
|
110
119
|
|
111
|
-
|
120
|
+
Note that `git.log.all` adds the `--all` option to the underlying `git log` command.
|
121
|
+
This asks for the logs of all refs (basically all commits reachable by HEAD,
|
122
|
+
branches, and tags). This does not control the maximum number of commits returned. To
|
123
|
+
control how many commits are returned, you should call `max_count`.
|
112
124
|
|
113
|
-
|
125
|
+
**Git::Worktrees** - Enumerable object that holds `Git::Worktree objects`.
|
114
126
|
|
115
127
|
## Errors Raised By This Gem
|
116
128
|
|
data/lib/git/base.rb
CHANGED
@@ -2,12 +2,14 @@ require 'logger'
|
|
2
2
|
require 'open3'
|
3
3
|
|
4
4
|
module Git
|
5
|
-
#
|
5
|
+
# The main public interface for interacting with Git commands
|
6
6
|
#
|
7
7
|
# Instead of creating a Git::Base directly, obtain a Git::Base instance by
|
8
8
|
# calling one of the follow {Git} class methods: {Git.open}, {Git.init},
|
9
9
|
# {Git.clone}, or {Git.bare}.
|
10
10
|
#
|
11
|
+
# @api public
|
12
|
+
#
|
11
13
|
class Base
|
12
14
|
# (see Git.bare)
|
13
15
|
def self.bare(git_dir, options = {})
|
@@ -119,6 +121,62 @@ module Git
|
|
119
121
|
@index = options[:index] ? Git::Index.new(options[:index], false) : nil
|
120
122
|
end
|
121
123
|
|
124
|
+
# Update the index from the current worktree to prepare the for the next commit
|
125
|
+
#
|
126
|
+
# @example
|
127
|
+
# lib.add('path/to/file')
|
128
|
+
# lib.add(['path/to/file1','path/to/file2'])
|
129
|
+
# lib.add(all: true)
|
130
|
+
#
|
131
|
+
# @param [String, Array<String>] paths a file or files to be added to the repository (relative to the worktree root)
|
132
|
+
# @param [Hash] options
|
133
|
+
#
|
134
|
+
# @option options [Boolean] :all Add, modify, and remove index entries to match the worktree
|
135
|
+
# @option options [Boolean] :force Allow adding otherwise ignored files
|
136
|
+
#
|
137
|
+
def add(paths = '.', **options)
|
138
|
+
self.lib.add(paths, options)
|
139
|
+
end
|
140
|
+
|
141
|
+
# adds a new remote to this repository
|
142
|
+
# url can be a git url or a Git::Base object if it's a local reference
|
143
|
+
#
|
144
|
+
# @git.add_remote('scotts_git', 'git://repo.or.cz/rubygit.git')
|
145
|
+
# @git.fetch('scotts_git')
|
146
|
+
# @git.merge('scotts_git/master')
|
147
|
+
#
|
148
|
+
# Options:
|
149
|
+
# :fetch => true
|
150
|
+
# :track => <branch_name>
|
151
|
+
def add_remote(name, url, opts = {})
|
152
|
+
url = url.repo.path if url.is_a?(Git::Base)
|
153
|
+
self.lib.remote_add(name, url, opts)
|
154
|
+
Git::Remote.new(self, name)
|
155
|
+
end
|
156
|
+
|
157
|
+
# Create a new git tag
|
158
|
+
#
|
159
|
+
# @example
|
160
|
+
# repo.add_tag('tag_name', object_reference)
|
161
|
+
# repo.add_tag('tag_name', object_reference, {:options => 'here'})
|
162
|
+
# repo.add_tag('tag_name', {:options => 'here'})
|
163
|
+
#
|
164
|
+
# @param [String] name The name of the tag to add
|
165
|
+
# @param [Hash] options Opstions to pass to `git tag`.
|
166
|
+
# See [git-tag](https://git-scm.com/docs/git-tag) for more details.
|
167
|
+
# @option options [boolean] :annotate Make an unsigned, annotated tag object
|
168
|
+
# @option options [boolean] :a An alias for the `:annotate` option
|
169
|
+
# @option options [boolean] :d Delete existing tag with the given names.
|
170
|
+
# @option options [boolean] :f Replace an existing tag with the given name (instead of failing)
|
171
|
+
# @option options [String] :message Use the given tag message
|
172
|
+
# @option options [String] :m An alias for the `:message` option
|
173
|
+
# @option options [boolean] :s Make a GPG-signed tag.
|
174
|
+
#
|
175
|
+
def add_tag(name, *options)
|
176
|
+
self.lib.tag(name, *options)
|
177
|
+
self.tag(name)
|
178
|
+
end
|
179
|
+
|
122
180
|
# changes current working directory for a block
|
123
181
|
# to the git working directory
|
124
182
|
#
|
@@ -251,27 +309,11 @@ module Git
|
|
251
309
|
self.object('HEAD').grep(string, path_limiter, opts)
|
252
310
|
end
|
253
311
|
|
254
|
-
#
|
255
|
-
#
|
256
|
-
# @example
|
257
|
-
# git.add
|
258
|
-
# git.add('path/to/file')
|
259
|
-
# git.add(['path/to/file1','path/to/file2'])
|
260
|
-
# git.add(:all => true)
|
261
|
-
#
|
262
|
-
# options:
|
263
|
-
# :all => true
|
264
|
-
#
|
265
|
-
# @param [String,Array] paths files paths to be added (optional, default='.')
|
266
|
-
# @param [Hash] options
|
267
|
-
# @option options [boolean] :all
|
268
|
-
# Update the index not only where the working tree has a file matching
|
269
|
-
# <pathspec> but also where the index already has an entry.
|
270
|
-
# See [the --all option to git-add](https://git-scm.com/docs/git-add#Documentation/git-add.txt--A)
|
271
|
-
# for more details.
|
312
|
+
# List the files in the worktree that are ignored by git
|
313
|
+
# @return [Array<String>] the list of ignored files relative to teh root of the worktree
|
272
314
|
#
|
273
|
-
def
|
274
|
-
self.lib.
|
315
|
+
def ignored_files
|
316
|
+
self.lib.ignored_files
|
275
317
|
end
|
276
318
|
|
277
319
|
# removes file(s) from the git repository
|
@@ -434,22 +476,6 @@ module Git
|
|
434
476
|
self.lib.remotes.map { |r| Git::Remote.new(self, r) }
|
435
477
|
end
|
436
478
|
|
437
|
-
# adds a new remote to this repository
|
438
|
-
# url can be a git url or a Git::Base object if it's a local reference
|
439
|
-
#
|
440
|
-
# @git.add_remote('scotts_git', 'git://repo.or.cz/rubygit.git')
|
441
|
-
# @git.fetch('scotts_git')
|
442
|
-
# @git.merge('scotts_git/master')
|
443
|
-
#
|
444
|
-
# Options:
|
445
|
-
# :fetch => true
|
446
|
-
# :track => <branch_name>
|
447
|
-
def add_remote(name, url, opts = {})
|
448
|
-
url = url.repo.path if url.is_a?(Git::Base)
|
449
|
-
self.lib.remote_add(name, url, opts)
|
450
|
-
Git::Remote.new(self, name)
|
451
|
-
end
|
452
|
-
|
453
479
|
# sets the url for a remote
|
454
480
|
# url can be a git url or a Git::Base object if it's a local reference
|
455
481
|
#
|
@@ -473,7 +499,7 @@ module Git
|
|
473
499
|
self.lib.tags.map { |r| tag(r) }
|
474
500
|
end
|
475
501
|
|
476
|
-
#
|
502
|
+
# Create a new git tag
|
477
503
|
#
|
478
504
|
# @example
|
479
505
|
# repo.add_tag('tag_name', object_reference)
|
data/lib/git/escaped_path.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
module Git
|
4
4
|
# Represents an escaped Git path string
|
5
5
|
#
|
6
|
-
# Git commands that output paths (e.g. ls-files, diff), will escape
|
6
|
+
# Git commands that output paths (e.g. ls-files, diff), will escape unusual
|
7
7
|
# characters in the path with backslashes in the same way C escapes control
|
8
8
|
# characters (e.g. \t for TAB, \n for LF, \\ for backslash) or bytes with values
|
9
9
|
# larger than 0x80 (e.g. octal \302\265 for "micro" in UTF-8).
|
data/lib/git/lib.rb
CHANGED
@@ -38,14 +38,23 @@ module Git
|
|
38
38
|
|
39
39
|
# Create a new Git::Lib object
|
40
40
|
#
|
41
|
-
# @
|
42
|
-
# @git_work_dir, @git_dir, and @git_index_file
|
41
|
+
# @overload initialize(base, logger)
|
43
42
|
#
|
44
|
-
#
|
43
|
+
# @param base [Hash] the hash containing paths to the Git working copy,
|
44
|
+
# the Git repository directory, and the Git index file.
|
45
45
|
#
|
46
|
-
#
|
47
|
-
#
|
48
|
-
#
|
46
|
+
# @option base [Pathname] :working_directory
|
47
|
+
# @option base [Pathname] :repository
|
48
|
+
# @option base [Pathname] :index
|
49
|
+
#
|
50
|
+
# @param [Logger] logger
|
51
|
+
#
|
52
|
+
# @overload initialize(base, logger)
|
53
|
+
#
|
54
|
+
# @param base [#dir, #repo, #index] an object with methods to get the Git worktree (#dir),
|
55
|
+
# the Git repository directory (#repo), and the Git index file (#index).
|
56
|
+
#
|
57
|
+
# @param [Logger] logger
|
49
58
|
#
|
50
59
|
def initialize(base = nil, logger = nil)
|
51
60
|
@git_dir = nil
|
@@ -565,18 +574,52 @@ module Git
|
|
565
574
|
diff_as_hash('diff-index', treeish)
|
566
575
|
end
|
567
576
|
|
577
|
+
# List all files that are in the index
|
578
|
+
#
|
579
|
+
# @param location [String] the location to list the files from
|
580
|
+
#
|
581
|
+
# @return [Hash<String, Hash>] a hash of files in the index
|
582
|
+
# * key: file [String] the file path
|
583
|
+
# * value: file_info [Hash] the file information containing the following keys:
|
584
|
+
# * :path [String] the file path
|
585
|
+
# * :mode_index [String] the file mode
|
586
|
+
# * :sha_index [String] the file sha
|
587
|
+
# * :stage [String] the file stage
|
588
|
+
#
|
568
589
|
def ls_files(location=nil)
|
569
590
|
location ||= '.'
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
591
|
+
{}.tap do |files|
|
592
|
+
command_lines('ls-files', '--stage', location).each do |line|
|
593
|
+
(info, file) = line.split("\t")
|
594
|
+
(mode, sha, stage) = info.split
|
595
|
+
files[unescape_quoted_path(file)] = {
|
596
|
+
:path => file, :mode_index => mode, :sha_index => sha, :stage => stage
|
597
|
+
}
|
576
598
|
end
|
577
|
-
hsh[file] = {:path => file, :mode_index => mode, :sha_index => sha, :stage => stage}
|
578
599
|
end
|
579
|
-
|
600
|
+
end
|
601
|
+
|
602
|
+
# Unescape a path if it is quoted
|
603
|
+
#
|
604
|
+
# Git commands that output paths (e.g. ls-files, diff), will escape unusual
|
605
|
+
# characters.
|
606
|
+
#
|
607
|
+
# @example
|
608
|
+
# lib.unescape_if_quoted('"quoted_file_\\342\\230\\240"') # => 'quoted_file_☠'
|
609
|
+
# lib.unescape_if_quoted('unquoted_file') # => 'unquoted_file'
|
610
|
+
#
|
611
|
+
# @param path [String] the path to unescape if quoted
|
612
|
+
#
|
613
|
+
# @return [String] the unescaped path if quoted otherwise the original path
|
614
|
+
#
|
615
|
+
# @api private
|
616
|
+
#
|
617
|
+
def unescape_quoted_path(path)
|
618
|
+
if path.start_with?('"') && path.end_with?('"')
|
619
|
+
Git::EscapedPath.new(path[1..-2]).unescape
|
620
|
+
else
|
621
|
+
path
|
622
|
+
end
|
580
623
|
end
|
581
624
|
|
582
625
|
def ls_remote(location=nil, opts={})
|
@@ -597,7 +640,7 @@ module Git
|
|
597
640
|
end
|
598
641
|
|
599
642
|
def ignored_files
|
600
|
-
command_lines('ls-files', '--others', '-i', '--exclude-standard')
|
643
|
+
command_lines('ls-files', '--others', '-i', '--exclude-standard').map { |f| unescape_quoted_path(f) }
|
601
644
|
end
|
602
645
|
|
603
646
|
def untracked_files
|
@@ -670,18 +713,20 @@ module Git
|
|
670
713
|
command('config', '--global', name, value)
|
671
714
|
end
|
672
715
|
|
673
|
-
|
674
|
-
#
|
675
|
-
# lib.add('path/to/file')
|
676
|
-
# lib.add(['path/to/file1','path/to/file2'])
|
677
|
-
# lib.add(:all => true)
|
716
|
+
|
717
|
+
# Update the index from the current worktree to prepare the for the next commit
|
678
718
|
#
|
679
|
-
#
|
680
|
-
#
|
681
|
-
#
|
719
|
+
# @example
|
720
|
+
# lib.add('path/to/file')
|
721
|
+
# lib.add(['path/to/file1','path/to/file2'])
|
722
|
+
# lib.add(:all => true)
|
682
723
|
#
|
683
|
-
# @param [String,Array] paths files
|
724
|
+
# @param [String, Array<String>] paths files to be added to the repository (relative to the worktree root)
|
684
725
|
# @param [Hash] options
|
726
|
+
#
|
727
|
+
# @option options [Boolean] :all Add, modify, and remove index entries to match the worktree
|
728
|
+
# @option options [Boolean] :force Allow adding otherwise ignored files
|
729
|
+
#
|
685
730
|
def add(paths='.',options={})
|
686
731
|
arr_opts = []
|
687
732
|
|
@@ -1212,6 +1257,14 @@ module Git
|
|
1212
1257
|
global_opts << "--work-tree=#{@git_work_dir}" if !@git_work_dir.nil?
|
1213
1258
|
global_opts << '-c' << 'core.quotePath=true'
|
1214
1259
|
global_opts << '-c' << 'color.ui=false'
|
1260
|
+
global_opts << '-c' << 'color.advice=false'
|
1261
|
+
global_opts << '-c' << 'color.diff=false'
|
1262
|
+
global_opts << '-c' << 'color.grep=false'
|
1263
|
+
global_opts << '-c' << 'color.push=false'
|
1264
|
+
global_opts << '-c' << 'color.remote=false'
|
1265
|
+
global_opts << '-c' << 'color.showBranch=false'
|
1266
|
+
global_opts << '-c' << 'color.status=false'
|
1267
|
+
global_opts << '-c' << 'color.transport=false'
|
1215
1268
|
end
|
1216
1269
|
end
|
1217
1270
|
|
data/lib/git/log.rb
CHANGED
@@ -1,15 +1,76 @@
|
|
1
1
|
module Git
|
2
2
|
|
3
|
-
#
|
3
|
+
# Return the last n commits that match the specified criteria
|
4
|
+
#
|
5
|
+
# @example The last (default number) of commits
|
6
|
+
# git = Git.open('.')
|
7
|
+
# Git::Log.new(git) #=> Enumerable of the last 30 commits
|
8
|
+
#
|
9
|
+
# @example The last n commits
|
10
|
+
# Git::Log.new(git).max_commits(50) #=> Enumerable of last 50 commits
|
11
|
+
#
|
12
|
+
# @example All commits returned by `git log`
|
13
|
+
# Git::Log.new(git).max_count(:all) #=> Enumerable of all commits
|
14
|
+
#
|
15
|
+
# @example All commits that match complex criteria
|
16
|
+
# Git::Log.new(git)
|
17
|
+
# .max_count(:all)
|
18
|
+
# .object('README.md')
|
19
|
+
# .since('10 years ago')
|
20
|
+
# .between('v1.0.7', 'HEAD')
|
21
|
+
#
|
22
|
+
# @api public
|
23
|
+
#
|
4
24
|
class Log
|
5
25
|
include Enumerable
|
6
26
|
|
7
|
-
|
27
|
+
# Create a new Git::Log object
|
28
|
+
#
|
29
|
+
# @example
|
30
|
+
# git = Git.open('.')
|
31
|
+
# Git::Log.new(git)
|
32
|
+
#
|
33
|
+
# @param base [Git::Base] the git repository object
|
34
|
+
# @param max_count [Integer, Symbol, nil] the number of commits to return, or
|
35
|
+
# `:all` or `nil` to return all
|
36
|
+
#
|
37
|
+
# Passing max_count to {#initialize} is equivalent to calling {#max_count} on the object.
|
38
|
+
#
|
39
|
+
def initialize(base, max_count = 30)
|
8
40
|
dirty_log
|
9
41
|
@base = base
|
10
|
-
|
42
|
+
max_count(max_count)
|
43
|
+
end
|
44
|
+
|
45
|
+
# The maximum number of commits to return
|
46
|
+
#
|
47
|
+
# @example All commits returned by `git log`
|
48
|
+
# git = Git.open('.')
|
49
|
+
# Git::Log.new(git).max_count(:all)
|
50
|
+
#
|
51
|
+
# @param num_or_all [Integer, Symbol, nil] the number of commits to return, or
|
52
|
+
# `:all` or `nil` to return all
|
53
|
+
#
|
54
|
+
# @return [self]
|
55
|
+
#
|
56
|
+
def max_count(num_or_all)
|
57
|
+
dirty_log
|
58
|
+
@max_count = (num_or_all == :all) ? nil : num_or_all
|
59
|
+
self
|
11
60
|
end
|
12
61
|
|
62
|
+
# Adds the --all flag to the git log command
|
63
|
+
#
|
64
|
+
# This asks for the logs of all refs (basically all commits reachable by HEAD,
|
65
|
+
# branches, and tags). This does not control the maximum number of commits
|
66
|
+
# returned. To control how many commits are returned, call {#max_count}.
|
67
|
+
#
|
68
|
+
# @example Return the last 50 commits reachable by all refs
|
69
|
+
# git = Git.open('.')
|
70
|
+
# Git::Log.new(git).max_count(50).all
|
71
|
+
#
|
72
|
+
# @return [self]
|
73
|
+
#
|
13
74
|
def all
|
14
75
|
dirty_log
|
15
76
|
@all = true
|
@@ -119,7 +180,7 @@ module Git
|
|
119
180
|
# actually run the 'git log' command
|
120
181
|
def run_log
|
121
182
|
log = @base.lib.full_log_commits(
|
122
|
-
count: @
|
183
|
+
count: @max_count, all: @all, object: @object, path_limiter: @path, since: @since,
|
123
184
|
author: @author, grep: @grep, skip: @skip, until: @until, between: @between,
|
124
185
|
cherry: @cherry
|
125
186
|
)
|
data/lib/git/status.rb
CHANGED
@@ -22,7 +22,7 @@ module Git
|
|
22
22
|
#
|
23
23
|
# @return [Enumerable]
|
24
24
|
def changed
|
25
|
-
@files.select { |_k, f| f.type == 'M' }
|
25
|
+
@_changed ||= @files.select { |_k, f| f.type == 'M' }
|
26
26
|
end
|
27
27
|
|
28
28
|
#
|
@@ -34,7 +34,7 @@ module Git
|
|
34
34
|
# changed?('lib/git.rb')
|
35
35
|
# @return [Boolean]
|
36
36
|
def changed?(file)
|
37
|
-
|
37
|
+
case_aware_include?(:changed, :lc_changed, file)
|
38
38
|
end
|
39
39
|
|
40
40
|
# Returns an Enumerable containing files that have been added.
|
@@ -42,7 +42,7 @@ module Git
|
|
42
42
|
#
|
43
43
|
# @return [Enumerable]
|
44
44
|
def added
|
45
|
-
@files.select { |_k, f| f.type == 'A' }
|
45
|
+
@_added ||= @files.select { |_k, f| f.type == 'A' }
|
46
46
|
end
|
47
47
|
|
48
48
|
# Determines whether the given file has been added to the repository
|
@@ -54,7 +54,7 @@ module Git
|
|
54
54
|
# added?('lib/git.rb')
|
55
55
|
# @return [Boolean]
|
56
56
|
def added?(file)
|
57
|
-
|
57
|
+
case_aware_include?(:added, :lc_added, file)
|
58
58
|
end
|
59
59
|
|
60
60
|
#
|
@@ -63,7 +63,7 @@ module Git
|
|
63
63
|
#
|
64
64
|
# @return [Enumerable]
|
65
65
|
def deleted
|
66
|
-
@files.select { |_k, f| f.type == 'D' }
|
66
|
+
@_deleted ||= @files.select { |_k, f| f.type == 'D' }
|
67
67
|
end
|
68
68
|
|
69
69
|
#
|
@@ -75,7 +75,7 @@ module Git
|
|
75
75
|
# deleted?('lib/git.rb')
|
76
76
|
# @return [Boolean]
|
77
77
|
def deleted?(file)
|
78
|
-
|
78
|
+
case_aware_include?(:deleted, :lc_deleted, file)
|
79
79
|
end
|
80
80
|
|
81
81
|
#
|
@@ -84,7 +84,7 @@ module Git
|
|
84
84
|
#
|
85
85
|
# @return [Enumerable]
|
86
86
|
def untracked
|
87
|
-
@files.select { |_k, f| f.untracked }
|
87
|
+
@_untracked ||= @files.select { |_k, f| f.untracked }
|
88
88
|
end
|
89
89
|
|
90
90
|
#
|
@@ -96,7 +96,7 @@ module Git
|
|
96
96
|
# untracked?('lib/git.rb')
|
97
97
|
# @return [Boolean]
|
98
98
|
def untracked?(file)
|
99
|
-
|
99
|
+
case_aware_include?(:untracked, :lc_untracked, file)
|
100
100
|
end
|
101
101
|
|
102
102
|
def pretty
|
@@ -264,5 +264,43 @@ module Git
|
|
264
264
|
end
|
265
265
|
end
|
266
266
|
end
|
267
|
+
|
268
|
+
# It's worth noting that (like git itself) this gem will not behave well if
|
269
|
+
# ignoreCase is set inconsistently with the file-system itself. For details:
|
270
|
+
# https://git-scm.com/docs/git-config#Documentation/git-config.txt-coreignoreCase
|
271
|
+
def ignore_case?
|
272
|
+
return @_ignore_case if defined?(@_ignore_case)
|
273
|
+
@_ignore_case = @base.config('core.ignoreCase') == 'true'
|
274
|
+
rescue Git::FailedError
|
275
|
+
@_ignore_case = false
|
276
|
+
end
|
277
|
+
|
278
|
+
def downcase_keys(hash)
|
279
|
+
hash.map { |k, v| [k.downcase, v] }.to_h
|
280
|
+
end
|
281
|
+
|
282
|
+
def lc_changed
|
283
|
+
@_lc_changed ||= changed.transform_keys(&:downcase)
|
284
|
+
end
|
285
|
+
|
286
|
+
def lc_added
|
287
|
+
@_lc_added ||= added.transform_keys(&:downcase)
|
288
|
+
end
|
289
|
+
|
290
|
+
def lc_deleted
|
291
|
+
@_lc_deleted ||= deleted.transform_keys(&:downcase)
|
292
|
+
end
|
293
|
+
|
294
|
+
def lc_untracked
|
295
|
+
@_lc_untracked ||= untracked.transform_keys(&:downcase)
|
296
|
+
end
|
297
|
+
|
298
|
+
def case_aware_include?(cased_hash, downcased_hash, file)
|
299
|
+
if ignore_case?
|
300
|
+
send(downcased_hash).include?(file.downcase)
|
301
|
+
else
|
302
|
+
send(cased_hash).include?(file)
|
303
|
+
end
|
304
|
+
end
|
267
305
|
end
|
268
306
|
end
|
data/lib/git/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: git
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.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-
|
11
|
+
date: 2024-06-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -243,8 +243,8 @@ licenses:
|
|
243
243
|
metadata:
|
244
244
|
homepage_uri: http://github.com/ruby-git/ruby-git
|
245
245
|
source_code_uri: http://github.com/ruby-git/ruby-git
|
246
|
-
changelog_uri: https://rubydoc.info/gems/git/2.
|
247
|
-
documentation_uri: https://rubydoc.info/gems/git/2.
|
246
|
+
changelog_uri: https://rubydoc.info/gems/git/2.1.1/file/CHANGELOG.md
|
247
|
+
documentation_uri: https://rubydoc.info/gems/git/2.1.1
|
248
248
|
post_install_message:
|
249
249
|
rdoc_options: []
|
250
250
|
require_paths:
|