git 1.17.1 → 1.18.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6c893cd566fdfc36e3f6ea4fc742d7665b5daf14c299ff1acd19c40de49e3eb2
4
- data.tar.gz: cc08038a56beb1ba3195600e80a666d66a7d58dd1abb16d4e5282718cd067bcd
3
+ metadata.gz: b3c801f928c5b75999c02cecd054c0007a8e2f0460c27bc2b983741824d7b194
4
+ data.tar.gz: 861bf03f14ed76dcf43acefcc8fe33787e202a9af52e7789d6d1660f84b4fc51
5
5
  SHA512:
6
- metadata.gz: 82e6441de9ff798080bddc79ca411386a7c20b5d4208d584fa12925777bb66de1ddc3532d512087eb815c083184d30cf445ef097a47cc8a8089027b1498820c1
7
- data.tar.gz: f0657f1ee3f3142612fdd904bc8649207e6bc1a115cbb3a969105c99a0fff15c0d1851b755c527351f06b462e6ff22b98e85ed4139acdcdcf949c434417becb2
6
+ metadata.gz: 4a4bf752eb3332572f968ea23a5cc4a4e4547279f60ce2341d6d6d815f5d9f4cbd17237b266c9cd2850c77c2c9a189ff98034af5385333632f557e765cb7b64a
7
+ data.tar.gz: e678b9da94ccd8295347688d3dd3e400764da4af3f850ceaa0038e4ddb34804fd2cc3942119a9f66968b4c014fb07a040352c7b6494556298cebd826bc765fd8
data/CHANGELOG.md CHANGED
@@ -5,6 +5,26 @@
5
5
 
6
6
  # Change Log
7
7
 
8
+ ## v1.18.0 (2023-03-19)
9
+
10
+ [Full Changelog](https://github.com/ruby-git/ruby-git/compare/v1.17.2..v1.18.0)
11
+
12
+ Changes since v1.17.2:
13
+
14
+ * 3c70 Add support for `--update-head-ok` to `fetch` (#660)
15
+ * b53d Do not generate yard documentation when building in TruffleRuby (#659)
16
+ * 5af1 Correctly report command output when there is an error (#658)
17
+ * b27a Add test to ensure that `Git.open` works to open a submodule (#655)
18
+ * 5b0e Update Git.clone to set multiple config variables (#653)
19
+
20
+ ## v1.17.2 (2023-03-07)
21
+
22
+ [Full Changelog](https://github.com/ruby-git/ruby-git/compare/v1.17.1..v1.17.2)
23
+
24
+ Changes since v1.17.1:
25
+
26
+ * f43d6 Fix branch name parsing to handle names that include slashes (#651)
27
+
8
28
  ## v1.17.1 (2023-03-06)
9
29
 
10
30
  [Full Changelog](https://github.com/ruby-git/ruby-git/compare/v1.17.0..v1.17.1)
data/README.md CHANGED
@@ -188,6 +188,18 @@ end
188
188
  g.config('user.name') # returns 'Scott Chacon'
189
189
  g.config # returns whole config hash
190
190
 
191
+ # Configuration can be set when cloning using the :config option.
192
+ # This option can be an single configuration String or an Array
193
+ # if multiple config items need to be set.
194
+ #
195
+ g = Git.clone(
196
+ git_uri, destination_path,
197
+ :config => [
198
+ 'core.sshCommand=ssh -i /home/user/.ssh/id_rsa',
199
+ 'submodule.recurse=true'
200
+ ]
201
+ )
202
+
191
203
  g.tags # returns array of Git::Tag objects
192
204
 
193
205
  g.show()
@@ -299,6 +311,7 @@ g.fetch
299
311
  g.fetch(g.remotes.first)
300
312
  g.fetch('origin', {:ref => 'some/ref/head'} )
301
313
  g.fetch(all: true, force: true, depth: 2)
314
+ g.fetch('origin', {:'update-head-ok' => true})
302
315
 
303
316
  g.pull
304
317
  g.pull(Git::Repo, Git::Branch) # fetch and a merge
data/Rakefile CHANGED
@@ -18,7 +18,7 @@ task :test do
18
18
  end
19
19
  default_tasks << :test
20
20
 
21
- unless RUBY_PLATFORM == 'java'
21
+ unless RUBY_PLATFORM == 'java' || RUBY_ENGINE == 'truffleruby'
22
22
  #
23
23
  # YARD documentation for this project can NOT be built with JRuby.
24
24
  # This project uses the redcarpet gem which can not be installed on JRuby.
data/lib/git/branch.rb CHANGED
@@ -1,11 +1,9 @@
1
1
  require 'git/path'
2
2
 
3
3
  module Git
4
-
5
4
  class Branch < Path
6
-
7
5
  attr_accessor :full, :remote, :name
8
-
6
+
9
7
  def initialize(base, name)
10
8
  @full = name
11
9
  @base = base
@@ -13,25 +11,25 @@ module Git
13
11
  @stashes = nil
14
12
  @remote, @name = parse_name(name)
15
13
  end
16
-
14
+
17
15
  def gcommit
18
16
  @gcommit ||= @base.gcommit(@full)
19
17
  @gcommit
20
18
  end
21
-
19
+
22
20
  def stashes
23
21
  @stashes ||= Git::Stashes.new(@base)
24
22
  end
25
-
23
+
26
24
  def checkout
27
25
  check_if_create
28
26
  @base.checkout(@full)
29
27
  end
30
-
28
+
31
29
  def archive(file, opts = {})
32
30
  @base.lib.archive(@full, file, opts)
33
31
  end
34
-
32
+
35
33
  # g.branch('new_branch').in_branch do
36
34
  # # create new file
37
35
  # # do other stuff
@@ -47,26 +45,26 @@ module Git
47
45
  end
48
46
  @base.checkout(old_current)
49
47
  end
50
-
48
+
51
49
  def create
52
50
  check_if_create
53
51
  end
54
-
52
+
55
53
  def delete
56
54
  @base.lib.branch_delete(@name)
57
55
  end
58
-
56
+
59
57
  def current
60
58
  determine_current
61
59
  end
62
-
60
+
63
61
  def contains?(commit)
64
62
  !@base.lib.branch_contains(commit, self.name).empty?
65
63
  end
66
-
64
+
67
65
  def merge(branch = nil, message = nil)
68
66
  if branch
69
- in_branch do
67
+ in_branch do
70
68
  @base.merge(branch, message)
71
69
  false
72
70
  end
@@ -76,7 +74,7 @@ module Git
76
74
  @base.merge(@name)
77
75
  end
78
76
  end
79
-
77
+
80
78
  def update_ref(commit)
81
79
  if @remote
82
80
  @base.lib.update_ref("refs/remotes/#{@remote.name}/#{@name}", commit)
@@ -84,47 +82,62 @@ module Git
84
82
  @base.lib.update_ref("refs/heads/#{@name}", commit)
85
83
  end
86
84
  end
87
-
85
+
88
86
  def to_a
89
87
  [@full]
90
88
  end
91
-
89
+
92
90
  def to_s
93
91
  @full
94
92
  end
95
-
96
- private
97
93
 
98
- def check_if_create
99
- @base.lib.branch_new(@name) rescue nil
100
- end
101
-
102
- def determine_current
103
- @base.lib.branch_current == @name
104
- end
105
-
106
- # Given a full branch name return an Array containing the remote and branch names.
107
- #
108
- # Removes 'remotes' from the beggining of the name (if present).
109
- # Takes the second part (splittign by '/') as the remote name.
110
- # Takes the rest as the repo name (can also hold one or more '/').
111
- #
112
- # Example:
113
- # parse_name('master') #=> [nil, 'master']
114
- # parse_name('origin/master') #=> ['origin', 'master']
115
- # parse_name('remotes/origin/master') #=> ['origin', 'master']
116
- # parse_name('origin/master/v2') #=> ['origin', 'master/v2']
117
- #
118
- # param [String] name branch full name.
119
- # return [<Git::Remote,NilClass,String>] an Array containing the remote and branch names.
120
- def parse_name(name)
121
- if name.match(/^(?:remotes\/)?([^\/]+)\/(.+)/)
122
- return [Git::Remote.new(@base, $1), $2]
123
- end
94
+ private
124
95
 
125
- return [nil, name]
126
- end
127
-
96
+ def check_if_create
97
+ @base.lib.branch_new(@name) rescue nil
98
+ end
99
+
100
+ def determine_current
101
+ @base.lib.branch_current == @name
102
+ end
103
+
104
+ BRANCH_NAME_REGEXP = %r{
105
+ ^
106
+ # Optional 'refs/remotes/' at the beggining to specify a remote tracking branch
107
+ # with a <remote_name>. <remote_name> is nil if not present.
108
+ (?:
109
+ (?:(?:refs/)?remotes/)(?<remote_name>[^/]+)/
110
+ )?
111
+ (?<branch_name>.*)
112
+ $
113
+ }x
114
+
115
+ # Given a full branch name return an Array containing the remote and branch names.
116
+ #
117
+ # Removes 'remotes' from the beggining of the name (if present).
118
+ # Takes the second part (splittign by '/') as the remote name.
119
+ # Takes the rest as the repo name (can also hold one or more '/').
120
+ #
121
+ # Example:
122
+ # # local branches
123
+ # parse_name('master') #=> [nil, 'master']
124
+ # parse_name('origin/master') #=> [nil, 'origin/master']
125
+ # parse_name('origin/master/v2') #=> [nil, 'origin/master']
126
+ #
127
+ # # remote branches
128
+ # parse_name('remotes/origin/master') #=> ['origin', 'master']
129
+ # parse_name('remotes/origin/master/v2') #=> ['origin', 'master/v2']
130
+ # parse_name('refs/remotes/origin/master') #=> ['origin', 'master']
131
+ # parse_name('refs/remotes/origin/master/v2') #=> ['origin', 'master/v2']
132
+ #
133
+ # param [String] name branch full name.
134
+ # return [<Git::Remote,NilClass,String>] an Array containing the remote and branch names.
135
+ def parse_name(name)
136
+ # Expect this will always match
137
+ match = name.match(BRANCH_NAME_REGEXP)
138
+ remote = match[:remote_name] ? Git::Remote.new(@base, match[:remote_name]) : nil
139
+ branch_name = match[:branch_name]
140
+ [ remote, branch_name ]
141
+ end
128
142
  end
129
-
130
143
  end
@@ -14,18 +14,20 @@ module Git
14
14
  class FailedError < Git::GitExecuteError
15
15
  # Create a FailedError object
16
16
  #
17
+ # Since this gem redirects stderr to stdout, the stdout of the process is used.
18
+ #
17
19
  # @example
18
20
  # `exit 1` # set $? appropriately for this example
19
- # result = Git::CommandLineResult.new(%w[git status], $?, '', "failed")
21
+ # result = Git::CommandLineResult.new(%w[git status], $?, 'stdout', 'stderr')
20
22
  # error = Git::FailedError.new(result)
21
23
  # error.message #=>
22
- # "[\"git\", \"status\"]\nstatus: pid 89784 exit 1\nstderr: \"failed\""
24
+ # "[\"git\", \"status\"]\nstatus: pid 89784 exit 1\noutput: \"stdout\""
23
25
  #
24
26
  # @param result [Git::CommandLineResult] the result of the git command including
25
27
  # the git command, status, stdout, and stderr
26
28
  #
27
29
  def initialize(result)
28
- super("#{result.git_cmd}\nstatus: #{result.status}\nstderr: #{result.stderr.inspect}")
30
+ super("#{result.git_cmd}\nstatus: #{result.status}\noutput: #{result.stdout.inspect}")
29
31
  @result = result
30
32
  end
31
33
 
@@ -35,14 +37,14 @@ module Git
35
37
  #
36
38
  # @example
37
39
  # `exit 1` # set $? appropriately for this example
38
- # result = Git::CommandLineResult.new(%w[git status], $?, '', "failed")
40
+ # result = Git::CommandLineResult.new(%w[git status], $?, 'stdout', 'stderr')
39
41
  # error = Git::FailedError.new(result)
40
42
  # error.result #=>
41
43
  # #<Git::CommandLineResult:0x00000001046bd488
42
44
  # @git_cmd=["git", "status"],
43
45
  # @status=#<Process::Status: pid 89784 exit 1>,
44
- # @stderr="failed",
45
- # @stdout="">
46
+ # @stderr="stderr",
47
+ # @stdout="stdout">
46
48
  #
47
49
  # @return [Git::CommandLineResult]
48
50
  #
data/lib/git/lib.rb CHANGED
@@ -101,7 +101,7 @@ module Git
101
101
  arr_opts << '--bare' if opts[:bare]
102
102
  arr_opts << '--branch' << opts[:branch] if opts[:branch]
103
103
  arr_opts << '--depth' << opts[:depth].to_i if opts[:depth] && opts[:depth].to_i > 0
104
- arr_opts << '--config' << opts[:config] if opts[:config]
104
+ Array(opts[:config]).each { |c| arr_opts << '--config' << c }
105
105
  arr_opts << '--origin' << opts[:remote] || opts[:origin] if opts[:remote] || opts[:origin]
106
106
  arr_opts << '--recursive' if opts[:recursive]
107
107
  arr_opts << '--mirror' if opts[:mirror]
@@ -951,6 +951,7 @@ module Git
951
951
  arr_opts << '--prune' if opts[:p] || opts[:prune]
952
952
  arr_opts << '--prune-tags' if opts[:P] || opts[:'prune-tags']
953
953
  arr_opts << '--force' if opts[:f] || opts[:force]
954
+ arr_opts << '--update-head-ok' if opts[:u] || opts[:'update-head-ok']
954
955
  arr_opts << '--unshallow' if opts[:unshallow]
955
956
  arr_opts << '--depth' << opts[:depth] if opts[:depth]
956
957
  arr_opts << '--' if remote || opts[:ref]
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.17.1'
4
+ VERSION='1.18.0'
5
5
  end
data/lib/git.rb CHANGED
@@ -133,6 +133,9 @@ module Git
133
133
  # @option options [String] :branch The name of a branch or tag to checkout
134
134
  # instead of the default branch.
135
135
  #
136
+ # @option options [Array, String] :config A list of configuration options to
137
+ # set on the newly created repository.
138
+ #
136
139
  # @option options [Integer] :depth Create a shallow clone with a history
137
140
  # truncated to the specified number of commits.
138
141
  #
@@ -166,6 +169,18 @@ module Git
166
169
  # @example Create a bare repository in the directory `ruby-git.git`
167
170
  # git = Git.clone('https://github.com/ruby-git/ruby-git.git', bare: true)
168
171
  #
172
+ # @example Clone a repository and set a single config option
173
+ # git = Git.clone(
174
+ # 'https://github.com/ruby-git/ruby-git.git',
175
+ # config: 'submodule.recurse=true'
176
+ # )
177
+ #
178
+ # @example Clone a repository and set multiple config options
179
+ # git = Git.clone(
180
+ # 'https://github.com/ruby-git/ruby-git.git',
181
+ # config: ['user.name=John Doe', 'user.email=john@doe.com']
182
+ # )
183
+ #
169
184
  # @return [Git::Base] an object that can execute git commands in the context
170
185
  # of the cloned local working copy or cloned repository.
171
186
  #
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.17.1
4
+ version: 1.18.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-03-06 00:00:00.000000000 Z
11
+ date: 2023-03-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable