git 1.17.1 → 1.17.2
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 +8 -0
- data/lib/git/branch.rb +62 -49
- data/lib/git/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cebf2eab3cc2c8cc605b1e3b9aeafa2f2c82ef0a50be725fc211fdb55a7980c0
|
4
|
+
data.tar.gz: 9df1a5d2f067aa183a65cea1cd21e7260b72213f92c50b60bda26f261b2e7d23
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 57019fb39b7476d7ee5d97fd1c21f1bffa3b1fbd59413e5bb602794c106f38c2bc528c1a86b98b89bc835976671ea836a1bdf911aa9a281b81b97d221c12b80d
|
7
|
+
data.tar.gz: d2f2927fbdf6b13b66d931183d6effb5fbb651e10c77a393e6b035ccc88e5b6ffd60dbed859fa6c400cd4551df253be89074e20aaa0f40379b609e79bd3553fa
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,14 @@
|
|
5
5
|
|
6
6
|
# Change Log
|
7
7
|
|
8
|
+
## v1.17.2 (2023-03-07)
|
9
|
+
|
10
|
+
[Full Changelog](https://github.com/ruby-git/ruby-git/compare/v1.17.1..v1.17.2)
|
11
|
+
|
12
|
+
Changes since v1.17.1:
|
13
|
+
|
14
|
+
* f43d6 Fix branch name parsing to handle names that include slashes (#651)
|
15
|
+
|
8
16
|
## v1.17.1 (2023-03-06)
|
9
17
|
|
10
18
|
[Full Changelog](https://github.com/ruby-git/ruby-git/compare/v1.17.0..v1.17.1)
|
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
|
-
|
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
|
-
|
126
|
-
|
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
|
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: 1.17.
|
4
|
+
version: 1.17.2
|
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-
|
11
|
+
date: 2023-03-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|