git 1.14.0 → 1.15.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 344c98cd98670d4afa26aae12680f28ad857f1fdbca4384a10c9cf7ed7937a8a
4
- data.tar.gz: 9d857e44f2457f6c5208bebca6935991c2e88fbd82b2c482c570cd7afcca7c38
3
+ metadata.gz: 8a3877a2258c4835e6adc9ad9844f89eeaf340bf1ad7a47937178fc4abe4bfae
4
+ data.tar.gz: 4bc93c337d92610aa46c7265fb03cfff12ca62d23fcfe67488e5ffaf0dd171cb
5
5
  SHA512:
6
- metadata.gz: 6fd40652aa02ad36238522ee2210ad7c01ced240f0a1b91f2de3e6baefe93dd0a20fb22b80821ee45bf974d73a3cc346e4a5adbaa2322384b57e2bb0251d491d
7
- data.tar.gz: 0c8d86fe09a9e4f8d06c1d8bb0abf05eff45a2746450253ccf751163e4340b873df4eff2dbfb0711aad30c61303e0c692802a378bceb46a26a1e17ba08927268
6
+ metadata.gz: 89caa1ce17512244548e72fcac709390c8017601e7699d6355939d613c8cba973c5309c733d4071d5db356d93f9fe37b42e3ca48862e759c00fdbf85b55eb51f
7
+ data.tar.gz: fff185e87d3925baed674a81b3501dba49a9e9c8af1e1f99fdb27645c83a5a22e820001ab46a49a71e703b0dcb741d5a6aa8baeddf2dd4c39fa6199443a8190e
data/CHANGELOG.md CHANGED
@@ -5,6 +5,19 @@
5
5
 
6
6
  # Change Log
7
7
 
8
+ ## v1.15.0 (2023-03-01)
9
+
10
+ [Full Changelog](https://github.com/ruby-git/ruby-git/compare/v1.14.0..v1.15.0)
11
+
12
+ Changes since v1.14.0:
13
+
14
+ * b40d #pull with no options should do the same thing as `git pull` with no options (#633)
15
+ * 9c5e Fix error when calling `Git::Lib#remove` with `recursive` or `cached` options (#632)
16
+ * 806e Add Git::Log#all option (#630)
17
+ * d905 Allow a repo to be opened giving a non-root repo directory (#629)
18
+ * 1ccd Rewrite worktree tests (#628)
19
+ * 4409 Fix Git::Branch#update_ref (#626)
20
+
8
21
  ## v1.14.0 (2023-02-25)
9
22
 
10
23
  [Full Changelog](https://github.com/ruby-git/ruby-git/compare/v1.13.2..v1.14.0)
data/README.md CHANGED
@@ -66,6 +66,10 @@ like:
66
66
 
67
67
  `@git.log(20).object("some_file").since("2 weeks ago").between('v2.6', 'v2.7').each { |commit| [block] }`
68
68
 
69
+ Pass the `--all` option to `git log` as follows:
70
+
71
+ `@git.log.all.each { |commit| [block] }`
72
+
69
73
  **Git::Worktrees** - Enumerable object that holds `Git::Worktree objects`.
70
74
 
71
75
  ## Examples
data/lib/git/base.rb CHANGED
@@ -58,9 +58,26 @@ module Git
58
58
  self.new(options)
59
59
  end
60
60
 
61
+ def self.root_of_worktree(working_dir)
62
+ result = working_dir
63
+ status = nil
64
+ Dir.chdir(working_dir) do
65
+ git_cmd = "#{Git::Base.config.binary_path} -c core.quotePath=true -c color.ui=false rev-parse --show-toplevel 2>&1"
66
+ result = `#{git_cmd}`.chomp
67
+ status = $?
68
+ end
69
+ raise ArgumentError, "'#{working_dir}' is not in a git working tree" unless status.success?
70
+ result
71
+ end
72
+
61
73
  # (see Git.open)
62
74
  def self.open(working_dir, options = {})
75
+ raise ArgumentError, "'#{working_dir}' is not a directory" unless Dir.exist?(working_dir)
76
+
77
+ working_dir = root_of_worktree(working_dir) unless options[:repository]
78
+
63
79
  normalize_paths(options, default_working_directory: working_dir)
80
+
64
81
  self.new(options)
65
82
  end
66
83
 
@@ -255,10 +272,12 @@ module Git
255
272
  end
256
273
 
257
274
  # removes file(s) from the git repository
258
- def remove(path = '.', opts = {})
259
- self.lib.remove(path, opts)
275
+ def rm(path = '.', opts = {})
276
+ self.lib.rm(path, opts)
260
277
  end
261
278
 
279
+ alias remove rm
280
+
262
281
  # resets the working directory to the provided commitish
263
282
  def reset(commitish = nil, opts = {})
264
283
  self.lib.reset(commitish, opts)
@@ -380,7 +399,7 @@ module Git
380
399
  # @git.pull('upstream') # pulls from upstream/master
381
400
  # @git.pull('upstream', 'develope') # pulls from upstream/develop
382
401
  #
383
- def pull(remote='origin', branch='master')
402
+ def pull(remote = nil, branch = nil)
384
403
  self.lib.pull(remote, branch)
385
404
  end
386
405
 
data/lib/git/branch.rb CHANGED
@@ -78,7 +78,11 @@ module Git
78
78
  end
79
79
 
80
80
  def update_ref(commit)
81
- @base.lib.update_ref(@full, commit)
81
+ if @remote
82
+ @base.lib.update_ref("refs/remotes/#{@remote.name}/#{@name}", commit)
83
+ else
84
+ @base.lib.update_ref("refs/heads/#{@name}", commit)
85
+ end
82
86
  end
83
87
 
84
88
  def to_a
@@ -114,7 +118,7 @@ module Git
114
118
  # param [String] name branch full name.
115
119
  # return [<Git::Remote,NilClass,String>] an Array containing the remote and branch names.
116
120
  def parse_name(name)
117
- if name.match(/^(?:remotes)?\/([^\/]+)\/(.+)/)
121
+ if name.match(/^(?:remotes\/)?([^\/]+)\/(.+)/)
118
122
  return [Git::Remote.new(@base, $1), $2]
119
123
  end
120
124
 
data/lib/git/lib.rb CHANGED
@@ -628,16 +628,12 @@ module Git
628
628
  command('add', *arr_opts)
629
629
  end
630
630
 
631
- def remove(path = '.', opts = {})
631
+ def rm(path = '.', opts = {})
632
632
  arr_opts = ['-f'] # overrides the up-to-date check by default
633
- arr_opts << ['-r'] if opts[:recursive]
634
- arr_opts << ['--cached'] if opts[:cached]
633
+ arr_opts << '-r' if opts[:recursive]
634
+ arr_opts << '--cached' if opts[:cached]
635
635
  arr_opts << '--'
636
- if path.is_a?(Array)
637
- arr_opts += path
638
- else
639
- arr_opts << path
640
- end
636
+ arr_opts += Array(path)
641
637
 
642
638
  command('rm', *arr_opts)
643
639
  end
@@ -930,8 +926,13 @@ module Git
930
926
  end
931
927
  end
932
928
 
933
- def pull(remote='origin', branch='master')
934
- command('pull', remote, branch)
929
+ def pull(remote = nil, branch = nil)
930
+ raise ArgumentError, "You must specify a remote if a branch is specified" if remote.nil? && !branch.nil?
931
+
932
+ arr_opts = []
933
+ arr_opts << remote if remote
934
+ arr_opts << branch if branch
935
+ command('pull', *arr_opts)
935
936
  end
936
937
 
937
938
  def tag_sha(tag_name)
@@ -974,8 +975,8 @@ module Git
974
975
  command('commit-tree', *arr_opts, redirect: "< #{escape t.path}")
975
976
  end
976
977
 
977
- def update_ref(branch, commit)
978
- command('update-ref', branch, commit)
978
+ def update_ref(ref, commit)
979
+ command('update-ref', ref, commit)
979
980
  end
980
981
 
981
982
  def checkout_index(opts = {})
@@ -1182,7 +1183,12 @@ module Git
1182
1183
  def log_common_options(opts)
1183
1184
  arr_opts = []
1184
1185
 
1185
- arr_opts << "-#{opts[:count]}" if opts[:count]
1186
+ if opts[:count] && !opts[:count].is_a?(Integer)
1187
+ raise ArgumentError, "The log count option must be an Integer but was #{opts[:count].inspect}"
1188
+ end
1189
+
1190
+ arr_opts << "--max-count=#{opts[:count]}" if opts[:count]
1191
+ arr_opts << "--all" if opts[:all]
1186
1192
  arr_opts << "--no-color"
1187
1193
  arr_opts << "--cherry" if opts[:cherry]
1188
1194
  arr_opts << "--since=#{opts[:since]}" if opts[:since].is_a? String
data/lib/git/log.rb CHANGED
@@ -1,24 +1,19 @@
1
1
  module Git
2
-
2
+
3
3
  # object that holds the last X commits on given branch
4
4
  class Log
5
5
  include Enumerable
6
-
6
+
7
7
  def initialize(base, count = 30)
8
8
  dirty_log
9
9
  @base = base
10
10
  @count = count
11
-
12
- @commits = nil
13
- @author = nil
14
- @grep = nil
15
- @object = nil
16
- @path = nil
17
- @since = nil
18
- @skip = nil
19
- @until = nil
20
- @between = nil
21
- @cherry = nil
11
+ end
12
+
13
+ def all
14
+ dirty_log
15
+ @all = true
16
+ self
22
17
  end
23
18
 
24
19
  def object(objectish)
@@ -32,37 +27,37 @@ module Git
32
27
  @author = regex
33
28
  return self
34
29
  end
35
-
30
+
36
31
  def grep(regex)
37
32
  dirty_log
38
33
  @grep = regex
39
34
  return self
40
35
  end
41
-
36
+
42
37
  def path(path)
43
38
  dirty_log
44
39
  @path = path
45
40
  return self
46
41
  end
47
-
42
+
48
43
  def skip(num)
49
44
  dirty_log
50
45
  @skip = num
51
46
  return self
52
47
  end
53
-
48
+
54
49
  def since(date)
55
50
  dirty_log
56
51
  @since = date
57
52
  return self
58
53
  end
59
-
54
+
60
55
  def until(date)
61
56
  dirty_log
62
57
  @until = date
63
58
  return self
64
59
  end
65
-
60
+
66
61
  def between(sha1, sha2 = nil)
67
62
  dirty_log
68
63
  @between = [sha1, sha2]
@@ -74,24 +69,24 @@ module Git
74
69
  @cherry = true
75
70
  return self
76
71
  end
77
-
72
+
78
73
  def to_s
79
74
  self.map { |c| c.to_s }.join("\n")
80
75
  end
81
-
76
+
82
77
 
83
78
  # forces git log to run
84
-
79
+
85
80
  def size
86
81
  check_log
87
82
  @commits.size rescue nil
88
83
  end
89
-
84
+
90
85
  def each(&block)
91
86
  check_log
92
87
  @commits.each(&block)
93
88
  end
94
-
89
+
95
90
  def first
96
91
  check_log
97
92
  @commits.first rescue nil
@@ -107,29 +102,30 @@ module Git
107
102
  @commits[index] rescue nil
108
103
  end
109
104
 
110
-
111
- private
112
-
105
+
106
+ private
107
+
113
108
  def dirty_log
114
109
  @dirty_flag = true
115
110
  end
116
-
111
+
117
112
  def check_log
118
113
  if @dirty_flag
119
114
  run_log
120
115
  @dirty_flag = false
121
116
  end
122
117
  end
123
-
118
+
124
119
  # actually run the 'git log' command
125
- def run_log
126
- log = @base.lib.full_log_commits(:count => @count, :object => @object,
127
- :path_limiter => @path, :since => @since,
128
- :author => @author, :grep => @grep, :skip => @skip,
129
- :until => @until, :between => @between, :cherry => @cherry)
120
+ def run_log
121
+ log = @base.lib.full_log_commits(
122
+ count: @count, all: @all, object: @object, path_limiter: @path, since: @since,
123
+ author: @author, grep: @grep, skip: @skip, until: @until, between: @between,
124
+ cherry: @cherry
125
+ )
130
126
  @commits = log.map { |c| Git::Object::Commit.new(@base, c['sha'], c) }
131
127
  end
132
-
128
+
133
129
  end
134
-
130
+
135
131
  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='1.14.0'
4
+ VERSION='1.15.0'
5
5
  end
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: 1.14.0
4
+ version: 1.15.0
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: 2023-02-26 00:00:00.000000000 Z
11
+ date: 2023-03-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable