git 1.10.0 → 1.10.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of git might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.github/workflows/continuous_integration.yml +1 -1
- data/CHANGELOG.md +4 -0
- data/Dockerfile.changelog-rs +12 -0
- data/RELEASING.md +36 -30
- data/lib/git/base.rb +1 -1
- data/lib/git/diff.rb +2 -2
- data/lib/git/encoding_utils.rb +33 -0
- data/lib/git/escaped_path.rb +77 -0
- data/lib/git/lib.rb +6 -31
- data/lib/git/version.rb +1 -1
- data/lib/git.rb +2 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6dd58567bba3a5effab0e3d3f565f5b3891dcf056ef4df11c1521037bbe9f489
|
4
|
+
data.tar.gz: a1f8f9968a3927ce99f393805c34b0ca23941c37f27607d296eaecba9dc0f872
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b1231323bde0b63677f46945800dc950a004cd854bee8c1d5a6711c8709c3dd87fb0c187f54c39c94ae07f92674f27a94b23fe3200a1799992f272c0bd84d315
|
7
|
+
data.tar.gz: 8d89a33a9cbee9357f9a4ffb568ec38506749aa81b931f9b2e862af0420c549c1738fde90e48eede6650c3202d31b9463e852eea5b358020b5561e5a60e12ef3
|
data/CHANGELOG.md
CHANGED
@@ -0,0 +1,12 @@
|
|
1
|
+
FROM rust
|
2
|
+
|
3
|
+
# Build the docker image (from this project's root directory):
|
4
|
+
# docker build --file Dockerfile.changelog-rs --tag changelog-rs .
|
5
|
+
#
|
6
|
+
# Use this image to output a changelog (from this project's root directory):
|
7
|
+
# docker run --rm --volume "$PWD:/worktree" changelog-rs v1.9.1 v1.10.0
|
8
|
+
|
9
|
+
RUN cargo install changelog-rs
|
10
|
+
WORKDIR /worktree
|
11
|
+
|
12
|
+
ENTRYPOINT ["/usr/local/cargo/bin/changelog-rs", "/worktree"]
|
data/RELEASING.md
CHANGED
@@ -6,9 +6,11 @@
|
|
6
6
|
# How to release a new git.gem
|
7
7
|
|
8
8
|
Releasing a new version of the `git` gem requires these steps:
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
|
10
|
+
- [How to release a new git.gem](#how-to-release-a-new-gitgem)
|
11
|
+
- [Prepare the release](#prepare-the-release)
|
12
|
+
- [Create a GitHub release](#create-a-github-release)
|
13
|
+
- [Build and release the gem](#build-and-release-the-gem)
|
12
14
|
|
13
15
|
These instructions use an example where the current release version is `1.5.0`
|
14
16
|
and the new release version to be created is `1.6.0.pre1`.
|
@@ -18,45 +20,49 @@ and the new release version to be created is `1.6.0.pre1`.
|
|
18
20
|
From a fork of ruby-git, create a PR containing changes to (1) bump the
|
19
21
|
version number, (2) update the CHANGELOG.md, and (3) tag the release.
|
20
22
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
23
|
+
- Bump the version number in lib/git/version.rb following [Semantic Versioning](https://semver.org)
|
24
|
+
guidelines
|
25
|
+
- Add a link in CHANGELOG.md to the release tag which will be created later
|
26
|
+
in this guide
|
27
|
+
- Create a new tag using [git-extras](https://github.com/tj/git-extras/blob/master/Commands.md#git-release)
|
28
|
+
`git release` command
|
29
|
+
- For example: `git release v1.6.0.pre1`
|
30
|
+
- These should be the only changes in the PR
|
31
|
+
- An example of these changes for `v1.6.0.pre1` can be found in [PR #435](https://github.com/ruby-git/ruby-git/pull/435)
|
32
|
+
- Get the PR reviewed, approved and merged to master.
|
31
33
|
|
32
34
|
## Create a GitHub release
|
33
35
|
|
34
36
|
On [the ruby-git releases page](https://github.com/ruby-git/ruby-git/releases),
|
35
37
|
select `Draft a new release`
|
36
38
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
39
|
+
- Select the tag corresponding to the version being released `v1.6.0.pre1`
|
40
|
+
- The Target should be `master`
|
41
|
+
- For the release description, use the output of [changelog-rs](https://github.com/perlun/changelog-rs)
|
42
|
+
- A Docker image is provided in [Dockerfile.changelog-rs](https://github.com/ruby-git/ruby-git/blob/master/Dockerfile.changelog-rs)
|
43
|
+
so you don't have to install changelog-rs or the Rust tool chain. To build the
|
44
|
+
Docker image, run this command from this project's root directory:
|
45
|
+
- `docker build --file Dockerfile.changelog-rs --tag changelog-rs .`
|
46
|
+
- To run the changelog-rs command using this image, run the following command
|
47
|
+
from this project's root directory (replace the tag names appropriate for the
|
48
|
+
current release):
|
49
|
+
- `docker run --rm --volume "$PWD:/worktree" changelog-rs v1.5.0 v1.6.0.pre1`
|
50
|
+
- Copy the output, omitting the tag header `## v1.6.0.pre1` and paste into
|
51
|
+
the release description
|
52
|
+
- The release description can be edited later if needed
|
53
|
+
- Select the appropriate value for `This is a pre-release`
|
54
|
+
- Since `v1.6.0.pre1` is a pre-release, check `This is a pre-release`
|
49
55
|
|
50
56
|
## Build and release the gem
|
51
57
|
|
52
58
|
Clone [ruby-git/ruby-git](https://github.com/ruby-git/ruby-git) directly (not a
|
53
59
|
fork) and ensure your local working copy is on the master branch
|
54
60
|
|
55
|
-
|
56
|
-
|
57
|
-
|
61
|
+
- Verify that you are not on a fork with the command `git remote -v`
|
62
|
+
- Verify that the version number is correct by running `rake -T` and inspecting
|
63
|
+
the output for the `release[remote]` task
|
58
64
|
|
59
65
|
Build the git gem and push it to rubygems.org with the command `rake release`
|
60
66
|
|
61
|
-
|
62
|
-
|
67
|
+
- Ensure that your `gem sources list` includes `https://rubygems.org` (in my
|
68
|
+
case, I usually have my work’s internal gem repository listed)
|
data/lib/git/base.rb
CHANGED
data/lib/git/diff.rb
CHANGED
@@ -129,8 +129,8 @@ module Git
|
|
129
129
|
final = {}
|
130
130
|
current_file = nil
|
131
131
|
@full_diff.split("\n").each do |line|
|
132
|
-
if m =
|
133
|
-
current_file = m[
|
132
|
+
if m = %r{\Adiff --git ("?)a/(.+?)\1 ("?)b/(.+?)\3\z}.match(line)
|
133
|
+
current_file = Git::EscapedPath.new(m[2]).unescape
|
134
134
|
final[current_file] = defaults.merge({:patch => line, :path => current_file})
|
135
135
|
else
|
136
136
|
if m = /^index ([0-9a-f]{4,40})\.\.([0-9a-f]{4,40})( ......)*/.match(line)
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rchardet'
|
4
|
+
|
5
|
+
module Git
|
6
|
+
# Method that can be used to detect and normalize string encoding
|
7
|
+
module EncodingUtils
|
8
|
+
def self.default_encoding
|
9
|
+
__ENCODING__.name
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.best_guess_encoding
|
13
|
+
# Encoding::ASCII_8BIT.name
|
14
|
+
Encoding::UTF_8.name
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.detected_encoding(str)
|
18
|
+
CharDet.detect(str)['encoding'] || best_guess_encoding
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.encoding_options
|
22
|
+
{ invalid: :replace, undef: :replace }
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.normalize_encoding(str)
|
26
|
+
return str if str.valid_encoding? && str.encoding.name == default_encoding
|
27
|
+
|
28
|
+
return str.encode(default_encoding, str.encoding, **encoding_options) if str.valid_encoding?
|
29
|
+
|
30
|
+
str.encode(default_encoding, detected_encoding(str), **encoding_options)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Git
|
4
|
+
# Represents an escaped Git path string
|
5
|
+
#
|
6
|
+
# Git commands that output paths (e.g. ls-files, diff), will escape usual
|
7
|
+
# characters in the path with backslashes in the same way C escapes control
|
8
|
+
# characters (e.g. \t for TAB, \n for LF, \\ for backslash) or bytes with values
|
9
|
+
# larger than 0x80 (e.g. octal \302\265 for "micro" in UTF-8).
|
10
|
+
#
|
11
|
+
# @example
|
12
|
+
# Git::GitPath.new('\302\265').unescape # => "µ"
|
13
|
+
#
|
14
|
+
class EscapedPath
|
15
|
+
UNESCAPES = {
|
16
|
+
'a' => 0x07,
|
17
|
+
'b' => 0x08,
|
18
|
+
't' => 0x09,
|
19
|
+
'n' => 0x0a,
|
20
|
+
'v' => 0x0b,
|
21
|
+
'f' => 0x0c,
|
22
|
+
'r' => 0x0d,
|
23
|
+
'e' => 0x1b,
|
24
|
+
'\\' => 0x5c,
|
25
|
+
'"' => 0x22,
|
26
|
+
"'" => 0x27
|
27
|
+
}.freeze
|
28
|
+
|
29
|
+
attr_reader :path
|
30
|
+
|
31
|
+
def initialize(path)
|
32
|
+
@path = path
|
33
|
+
end
|
34
|
+
|
35
|
+
# Convert an escaped path to an unescaped path
|
36
|
+
def unescape
|
37
|
+
bytes = escaped_path_to_bytes(path)
|
38
|
+
str = bytes.pack('C*')
|
39
|
+
str.force_encoding(Encoding::UTF_8)
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def extract_octal(path, index)
|
45
|
+
[path[index + 1..index + 4].to_i(8), 4]
|
46
|
+
end
|
47
|
+
|
48
|
+
def extract_escape(path, index)
|
49
|
+
[UNESCAPES[path[index + 1]], 2]
|
50
|
+
end
|
51
|
+
|
52
|
+
def extract_single_char(path, index)
|
53
|
+
[path[index].ord, 1]
|
54
|
+
end
|
55
|
+
|
56
|
+
def next_byte(path, index)
|
57
|
+
if path[index] == '\\' && path[index + 1] >= '0' && path[index + 1] <= '7'
|
58
|
+
extract_octal(path, index)
|
59
|
+
elsif path[index] == '\\' && UNESCAPES.include?(path[index + 1])
|
60
|
+
extract_escape(path, index)
|
61
|
+
else
|
62
|
+
extract_single_char(path, index)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def escaped_path_to_bytes(path)
|
67
|
+
index = 0
|
68
|
+
[].tap do |bytes|
|
69
|
+
while index < path.length
|
70
|
+
byte, chars_used = next_byte(path, index)
|
71
|
+
bytes << byte
|
72
|
+
index += chars_used
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
data/lib/git/lib.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'rchardet'
|
2
1
|
require 'tempfile'
|
3
2
|
require 'zlib'
|
4
3
|
|
@@ -1085,7 +1084,8 @@ module Git
|
|
1085
1084
|
global_opts = []
|
1086
1085
|
global_opts << "--git-dir=#{@git_dir}" if !@git_dir.nil?
|
1087
1086
|
global_opts << "--work-tree=#{@git_work_dir}" if !@git_work_dir.nil?
|
1088
|
-
global_opts << [
|
1087
|
+
global_opts << %w[-c core.quotePath=true]
|
1088
|
+
global_opts << %w[-c color.ui=false]
|
1089
1089
|
|
1090
1090
|
opts = [opts].flatten.map {|s| escape(s) }.join(' ')
|
1091
1091
|
|
@@ -1176,35 +1176,10 @@ module Git
|
|
1176
1176
|
arr_opts
|
1177
1177
|
end
|
1178
1178
|
|
1179
|
-
def default_encoding
|
1180
|
-
__ENCODING__.name
|
1181
|
-
end
|
1182
|
-
|
1183
|
-
def best_guess_encoding
|
1184
|
-
# Encoding::ASCII_8BIT.name
|
1185
|
-
Encoding::UTF_8.name
|
1186
|
-
end
|
1187
|
-
|
1188
|
-
def detected_encoding(str)
|
1189
|
-
CharDet.detect(str)['encoding'] || best_guess_encoding
|
1190
|
-
end
|
1191
|
-
|
1192
|
-
def encoding_options
|
1193
|
-
{ invalid: :replace, undef: :replace }
|
1194
|
-
end
|
1195
|
-
|
1196
|
-
def normalize_encoding(str)
|
1197
|
-
return str if str.valid_encoding? && str.encoding.name == default_encoding
|
1198
|
-
|
1199
|
-
return str.encode(default_encoding, str.encoding, **encoding_options) if str.valid_encoding?
|
1200
|
-
|
1201
|
-
str.encode(default_encoding, detected_encoding(str), **encoding_options)
|
1202
|
-
end
|
1203
|
-
|
1204
1179
|
def run_command(git_cmd, &block)
|
1205
1180
|
return IO.popen(git_cmd, &block) if block_given?
|
1206
1181
|
|
1207
|
-
`#{git_cmd}`.lines.map { |l| normalize_encoding(l) }.join
|
1182
|
+
`#{git_cmd}`.lines.map { |l| Git::EncodingUtils.normalize_encoding(l) }.join
|
1208
1183
|
end
|
1209
1184
|
|
1210
1185
|
def escape(s)
|
@@ -1216,8 +1191,9 @@ module Git
|
|
1216
1191
|
end
|
1217
1192
|
|
1218
1193
|
def escape_for_windows(s)
|
1219
|
-
#
|
1220
|
-
|
1194
|
+
# Escape existing double quotes in s and then wrap the result with double quotes
|
1195
|
+
escaped_string = s.to_s.gsub('"','\\"')
|
1196
|
+
%Q{"#{escaped_string}"}
|
1221
1197
|
end
|
1222
1198
|
|
1223
1199
|
def windows_platform?
|
@@ -1225,6 +1201,5 @@ module Git
|
|
1225
1201
|
win_platform_regex = /mingw|mswin/
|
1226
1202
|
RUBY_PLATFORM =~ win_platform_regex || RUBY_DESCRIPTION =~ win_platform_regex
|
1227
1203
|
end
|
1228
|
-
|
1229
1204
|
end
|
1230
1205
|
end
|
data/lib/git/version.rb
CHANGED
data/lib/git.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.10.
|
4
|
+
version: 1.10.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:
|
11
|
+
date: 2022-01-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rchardet
|
@@ -125,6 +125,7 @@ files:
|
|
125
125
|
- ".yardopts"
|
126
126
|
- CHANGELOG.md
|
127
127
|
- CONTRIBUTING.md
|
128
|
+
- Dockerfile.changelog-rs
|
128
129
|
- Gemfile
|
129
130
|
- ISSUE_TEMPLATE.md
|
130
131
|
- LICENSE
|
@@ -142,6 +143,8 @@ files:
|
|
142
143
|
- lib/git/branches.rb
|
143
144
|
- lib/git/config.rb
|
144
145
|
- lib/git/diff.rb
|
146
|
+
- lib/git/encoding_utils.rb
|
147
|
+
- lib/git/escaped_path.rb
|
145
148
|
- lib/git/index.rb
|
146
149
|
- lib/git/lib.rb
|
147
150
|
- lib/git/log.rb
|