git 1.9.0 → 1.10.2
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 +16 -0
- data/Dockerfile.changelog-rs +12 -0
- data/README.md +8 -0
- data/RELEASING.md +36 -30
- data/git.gemspec +2 -1
- data/lib/git/base.rb +105 -36
- 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 +19 -32
- data/lib/git/version.rb +1 -1
- data/lib/git.rb +5 -0
- metadata +20 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 96afd3adb091a3428a45ad172cfc980f64af32d5a809fc0f26e45a275811e04f
|
4
|
+
data.tar.gz: be9cc2d9f88513c178f064f2374d7c28ba47eeffa5d93486edacf39df5d26b63
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 21fb082ab5d96163049b27983f2a923573166088876300f85a34e8b5476559b5ec12d9c4a84a4afaff9ec0afdd2054f75099fda98b9913305a2dac18a2f6a776
|
7
|
+
data.tar.gz: 0ee7d7a9ac8665b3ac94fd6471de876f0e9cade17e3e58b4918c6de397d7c4a1d4c35b5695d0040cbbc0b739a9318550f4e08e5b16c51c7f9d3d6f6c7ef587a6
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,22 @@
|
|
5
5
|
|
6
6
|
# Change Log
|
7
7
|
|
8
|
+
## v1.10.2
|
9
|
+
|
10
|
+
See https://github.com/ruby-git/ruby-git/releases/tag/v1.10.2
|
11
|
+
|
12
|
+
## 1.10.1
|
13
|
+
|
14
|
+
See https://github.com/ruby-git/ruby-git/releases/tag/v1.10.1
|
15
|
+
|
16
|
+
## 1.10.0
|
17
|
+
|
18
|
+
See https://github.com/ruby-git/ruby-git/releases/tag/v1.10.0
|
19
|
+
|
20
|
+
## 1.9.1
|
21
|
+
|
22
|
+
See https://github.com/ruby-git/ruby-git/releases/tag/v1.9.1
|
23
|
+
|
8
24
|
## 1.9.0
|
9
25
|
|
10
26
|
See https://github.com/ruby-git/ruby-git/releases/tag/v1.9.0
|
@@ -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/README.md
CHANGED
@@ -226,6 +226,14 @@ g.remove('file.txt', :cached => true) # git rm -f --cached -- "file.txt"
|
|
226
226
|
g.commit('message')
|
227
227
|
g.commit_all('message')
|
228
228
|
|
229
|
+
# Sign a commit using the gpg key configured in the user.signingkey config setting
|
230
|
+
g.config('user.signingkey', '0A46826A')
|
231
|
+
g.commit('message', gpg_sign: true)
|
232
|
+
|
233
|
+
# Sign a commit using a specified gpg key
|
234
|
+
key_id = '0A46826A'
|
235
|
+
g.commit('message', gpg_sign: key_id)
|
236
|
+
|
229
237
|
g = Git.clone(repo, 'myrepo')
|
230
238
|
g.chdir do
|
231
239
|
new_file('test-file', 'blahblahblah')
|
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/git.gemspec
CHANGED
@@ -28,6 +28,7 @@ Gem::Specification.new do |s|
|
|
28
28
|
|
29
29
|
s.add_runtime_dependency 'rchardet', '~> 1.8'
|
30
30
|
|
31
|
+
s.add_development_dependency 'bump', '~> 0.10'
|
31
32
|
s.add_development_dependency 'minitar', '~> 0.9'
|
32
33
|
s.add_development_dependency 'rake', '~> 13.0'
|
33
34
|
s.add_development_dependency 'test-unit', '~> 3.3'
|
@@ -41,6 +42,6 @@ Gem::Specification.new do |s|
|
|
41
42
|
# Specify which files should be added to the gem when it is released.
|
42
43
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
43
44
|
s.files = Dir.chdir(File.expand_path(__dir__)) do
|
44
|
-
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(tests|spec|features)/}) }
|
45
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(tests|spec|features|bin)/}) }
|
45
46
|
end
|
46
47
|
end
|
data/lib/git/base.rb
CHANGED
@@ -12,40 +12,35 @@ module Git
|
|
12
12
|
|
13
13
|
# (see Git.bare)
|
14
14
|
def self.bare(git_dir, options = {})
|
15
|
-
|
15
|
+
normalize_paths(options, default_repository: git_dir, bare: true)
|
16
|
+
self.new(options)
|
16
17
|
end
|
17
18
|
|
18
19
|
# (see Git.clone)
|
19
20
|
def self.clone(repository, name, options = {})
|
20
|
-
|
21
|
+
new_options = Git::Lib.new(nil, options[:log]).clone(repository, name, options)
|
22
|
+
normalize_paths(new_options, bare: options[:bare] || options[:mirror])
|
23
|
+
self.new(new_options)
|
21
24
|
end
|
22
25
|
|
23
26
|
# Returns (and initialize if needed) a Git::Config instance
|
24
27
|
#
|
25
28
|
# @return [Git::Config] the current config instance.
|
26
29
|
def self.config
|
27
|
-
|
30
|
+
@@config ||= Config.new
|
28
31
|
end
|
29
32
|
|
30
33
|
# (see Git.init)
|
31
|
-
def self.init(directory, options = {})
|
32
|
-
options
|
33
|
-
options[:repository] ||= File.join(options[:working_directory], '.git')
|
34
|
-
|
35
|
-
FileUtils.mkdir_p(options[:working_directory]) if options[:working_directory] && !File.directory?(options[:working_directory])
|
34
|
+
def self.init(directory = '.', options = {})
|
35
|
+
normalize_paths(options, default_working_directory: directory, default_repository: directory, bare: options[:bare])
|
36
36
|
|
37
|
-
init_options = {
|
37
|
+
init_options = {
|
38
|
+
:bare => options[:bare],
|
39
|
+
:initial_branch => options[:initial_branch]
|
40
|
+
}
|
38
41
|
|
39
|
-
options
|
40
|
-
|
41
|
-
# Submodules have a .git *file* not a .git folder.
|
42
|
-
# This file's contents point to the location of
|
43
|
-
# where the git refs are held (In the parent repo)
|
44
|
-
if options[:working_directory] && File.file?(File.join(options[:working_directory], '.git'))
|
45
|
-
git_file = File.open('.git').read[8..-1].strip
|
46
|
-
options[:repository] = git_file
|
47
|
-
options[:index] = git_file + '/index'
|
48
|
-
end
|
42
|
+
directory = options[:bare] ? options[:repository] : options[:working_directory]
|
43
|
+
FileUtils.mkdir_p(directory) unless File.exist?(directory)
|
49
44
|
|
50
45
|
# TODO: this dance seems awkward: this creates a Git::Lib so we can call
|
51
46
|
# init so we can create a new Git::Base which in turn (ultimately)
|
@@ -63,21 +58,8 @@ module Git
|
|
63
58
|
end
|
64
59
|
|
65
60
|
# (see Git.open)
|
66
|
-
def self.open(working_dir, options={})
|
67
|
-
|
68
|
-
|
69
|
-
options[:working_directory] ||= working_dir
|
70
|
-
options[:repository] ||= File.join(options[:working_directory], '.git')
|
71
|
-
|
72
|
-
# Submodules have a .git *file* not a .git folder.
|
73
|
-
# This file's contents point to the location of
|
74
|
-
# where the git refs are held (In the parent repo)
|
75
|
-
if options[:working_directory] && File.file?(File.join(options[:working_directory], '.git'))
|
76
|
-
git_file = File.open('.git').read[8..-1].strip
|
77
|
-
options[:repository] = git_file
|
78
|
-
options[:index] = git_file + '/index'
|
79
|
-
end
|
80
|
-
|
61
|
+
def self.open(working_dir, options = {})
|
62
|
+
normalize_paths(options, default_working_directory: working_dir)
|
81
63
|
self.new(options)
|
82
64
|
end
|
83
65
|
|
@@ -287,6 +269,7 @@ module Git
|
|
287
269
|
# options:
|
288
270
|
# :force
|
289
271
|
# :d
|
272
|
+
# :ff
|
290
273
|
#
|
291
274
|
def clean(opts = {})
|
292
275
|
self.lib.clean(opts)
|
@@ -567,7 +550,6 @@ module Git
|
|
567
550
|
with_working(temp_dir, &blk)
|
568
551
|
end
|
569
552
|
|
570
|
-
|
571
553
|
# runs git rev-parse to convert the objectish to a full sha
|
572
554
|
#
|
573
555
|
# @example
|
@@ -592,6 +574,93 @@ module Git
|
|
592
574
|
self.lib.branch_current
|
593
575
|
end
|
594
576
|
|
595
|
-
|
577
|
+
private
|
578
|
+
|
579
|
+
# Normalize options before they are sent to Git::Base.new
|
580
|
+
#
|
581
|
+
# Updates the options parameter by setting appropriate values for the following keys:
|
582
|
+
# * options[:working_directory]
|
583
|
+
# * options[:repository]
|
584
|
+
# * options[:index]
|
585
|
+
#
|
586
|
+
# All three values will be set to absolute paths. An exception is that
|
587
|
+
# :working_directory will be set to nil if bare is true.
|
588
|
+
#
|
589
|
+
private_class_method def self.normalize_paths(
|
590
|
+
options, default_working_directory: nil, default_repository: nil, bare: false
|
591
|
+
)
|
592
|
+
normalize_working_directory(options, default: default_working_directory, bare: bare)
|
593
|
+
normalize_repository(options, default: default_repository, bare: bare)
|
594
|
+
normalize_index(options)
|
595
|
+
end
|
596
|
+
|
597
|
+
# Normalize options[:working_directory]
|
598
|
+
#
|
599
|
+
# If working with a bare repository, set to `nil`.
|
600
|
+
# Otherwise, set to the first non-nil value of:
|
601
|
+
# 1. `options[:working_directory]`,
|
602
|
+
# 2. the `default` parameter, or
|
603
|
+
# 3. the current working directory
|
604
|
+
#
|
605
|
+
# Finally, if options[:working_directory] is a relative path, convert it to an absoluite
|
606
|
+
# path relative to the current directory.
|
607
|
+
#
|
608
|
+
private_class_method def self.normalize_working_directory(options, default:, bare: false)
|
609
|
+
working_directory =
|
610
|
+
if bare
|
611
|
+
nil
|
612
|
+
else
|
613
|
+
File.expand_path(options[:working_directory] || default || Dir.pwd)
|
614
|
+
end
|
596
615
|
|
616
|
+
options[:working_directory] = working_directory
|
617
|
+
end
|
618
|
+
|
619
|
+
# Normalize options[:repository]
|
620
|
+
#
|
621
|
+
# If working with a bare repository, set to the first non-nil value out of:
|
622
|
+
# 1. `options[:repository]`
|
623
|
+
# 2. the `default` parameter
|
624
|
+
# 3. the current working directory
|
625
|
+
#
|
626
|
+
# Otherwise, set to the first non-nil value of:
|
627
|
+
# 1. `options[:repository]`
|
628
|
+
# 2. `.git`
|
629
|
+
#
|
630
|
+
# Next, if options[:repository] refers to a *file* and not a *directory*, set
|
631
|
+
# options[:repository] to the contents of that file. This is the case when
|
632
|
+
# working with a submodule or a secondary working tree (created with git worktree
|
633
|
+
# add). In these cases the repository is actually contained/nested within the
|
634
|
+
# parent's repository directory.
|
635
|
+
#
|
636
|
+
# Finally, if options[:repository] is a relative path, convert it to an absolute
|
637
|
+
# path relative to:
|
638
|
+
# 1. the current directory if working with a bare repository or
|
639
|
+
# 2. the working directory if NOT working with a bare repository
|
640
|
+
#
|
641
|
+
private_class_method def self.normalize_repository(options, default:, bare: false)
|
642
|
+
repository =
|
643
|
+
if bare
|
644
|
+
File.expand_path(options[:repository] || default || Dir.pwd)
|
645
|
+
else
|
646
|
+
File.expand_path(options[:repository] || '.git', options[:working_directory])
|
647
|
+
end
|
648
|
+
|
649
|
+
if File.file?(repository)
|
650
|
+
repository = File.expand_path(File.open(repository).read[8..-1].strip, options[:working_directory])
|
651
|
+
end
|
652
|
+
|
653
|
+
options[:repository] = repository
|
654
|
+
end
|
655
|
+
|
656
|
+
# Normalize options[:index]
|
657
|
+
#
|
658
|
+
# If options[:index] is a relative directory, convert it to an absolute
|
659
|
+
# directory relative to the repository directory
|
660
|
+
#
|
661
|
+
private_class_method def self.normalize_index(options)
|
662
|
+
index = File.expand_path(options[:index] || 'index', options[:repository])
|
663
|
+
options[:index] = index
|
664
|
+
end
|
665
|
+
end
|
597
666
|
end
|
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
|
|
@@ -71,10 +70,12 @@ module Git
|
|
71
70
|
# options:
|
72
71
|
# :bare
|
73
72
|
# :working_directory
|
73
|
+
# :initial_branch
|
74
74
|
#
|
75
75
|
def init(opts={})
|
76
76
|
arr_opts = []
|
77
77
|
arr_opts << '--bare' if opts[:bare]
|
78
|
+
arr_opts << "--initial-branch=#{opts[:initial_branch]}" if opts[:initial_branch]
|
78
79
|
|
79
80
|
command('init', arr_opts)
|
80
81
|
end
|
@@ -660,7 +661,14 @@ module Git
|
|
660
661
|
arr_opts << "--date=#{opts[:date]}" if opts[:date].is_a? String
|
661
662
|
arr_opts << '--no-verify' if opts[:no_verify]
|
662
663
|
arr_opts << '--allow-empty-message' if opts[:allow_empty_message]
|
663
|
-
|
664
|
+
if opts[:gpg_sign]
|
665
|
+
arr_opts <<
|
666
|
+
if opts[:gpg_sign] == true
|
667
|
+
'--gpg-sign'
|
668
|
+
else
|
669
|
+
"--gpg-sign=#{opts[:gpg_sign]}"
|
670
|
+
end
|
671
|
+
end
|
664
672
|
|
665
673
|
command('commit', arr_opts)
|
666
674
|
end
|
@@ -675,6 +683,7 @@ module Git
|
|
675
683
|
def clean(opts = {})
|
676
684
|
arr_opts = []
|
677
685
|
arr_opts << '--force' if opts[:force]
|
686
|
+
arr_opts << '-ff' if opts[:ff]
|
678
687
|
arr_opts << '-d' if opts[:d]
|
679
688
|
arr_opts << '-x' if opts[:x]
|
680
689
|
|
@@ -765,6 +774,7 @@ module Git
|
|
765
774
|
|
766
775
|
def merge(branch, message = nil, opts = {})
|
767
776
|
arr_opts = []
|
777
|
+
arr_opts << '--no-commit' if opts[:no_commit]
|
768
778
|
arr_opts << '--no-ff' if opts[:no_ff]
|
769
779
|
arr_opts << '-m' << message if message
|
770
780
|
arr_opts += [branch]
|
@@ -872,6 +882,7 @@ module Git
|
|
872
882
|
arr_opts << '--tags' if opts[:t] || opts[:tags]
|
873
883
|
arr_opts << '--prune' if opts[:p] || opts[:prune]
|
874
884
|
arr_opts << '--unshallow' if opts[:unshallow]
|
885
|
+
arr_opts << '--depth' << opts[:depth] if opts[:depth]
|
875
886
|
|
876
887
|
command('fetch', arr_opts)
|
877
888
|
end
|
@@ -1073,7 +1084,8 @@ module Git
|
|
1073
1084
|
global_opts = []
|
1074
1085
|
global_opts << "--git-dir=#{@git_dir}" if !@git_dir.nil?
|
1075
1086
|
global_opts << "--work-tree=#{@git_work_dir}" if !@git_work_dir.nil?
|
1076
|
-
global_opts << [
|
1087
|
+
global_opts << %w[-c core.quotePath=true]
|
1088
|
+
global_opts << %w[-c color.ui=false]
|
1077
1089
|
|
1078
1090
|
opts = [opts].flatten.map {|s| escape(s) }.join(' ')
|
1079
1091
|
|
@@ -1164,35 +1176,10 @@ module Git
|
|
1164
1176
|
arr_opts
|
1165
1177
|
end
|
1166
1178
|
|
1167
|
-
def default_encoding
|
1168
|
-
__ENCODING__.name
|
1169
|
-
end
|
1170
|
-
|
1171
|
-
def best_guess_encoding
|
1172
|
-
# Encoding::ASCII_8BIT.name
|
1173
|
-
Encoding::UTF_8.name
|
1174
|
-
end
|
1175
|
-
|
1176
|
-
def detected_encoding(str)
|
1177
|
-
CharDet.detect(str)['encoding'] || best_guess_encoding
|
1178
|
-
end
|
1179
|
-
|
1180
|
-
def encoding_options
|
1181
|
-
{ invalid: :replace, undef: :replace }
|
1182
|
-
end
|
1183
|
-
|
1184
|
-
def normalize_encoding(str)
|
1185
|
-
return str if str.valid_encoding? && str.encoding.name == default_encoding
|
1186
|
-
|
1187
|
-
return str.encode(default_encoding, str.encoding, **encoding_options) if str.valid_encoding?
|
1188
|
-
|
1189
|
-
str.encode(default_encoding, detected_encoding(str), **encoding_options)
|
1190
|
-
end
|
1191
|
-
|
1192
1179
|
def run_command(git_cmd, &block)
|
1193
1180
|
return IO.popen(git_cmd, &block) if block_given?
|
1194
1181
|
|
1195
|
-
`#{git_cmd}`.lines.map { |l| normalize_encoding(l) }.join
|
1182
|
+
`#{git_cmd}`.lines.map { |l| Git::EncodingUtils.normalize_encoding(l) }.join
|
1196
1183
|
end
|
1197
1184
|
|
1198
1185
|
def escape(s)
|
@@ -1204,8 +1191,9 @@ module Git
|
|
1204
1191
|
end
|
1205
1192
|
|
1206
1193
|
def escape_for_windows(s)
|
1207
|
-
#
|
1208
|
-
|
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}"}
|
1209
1197
|
end
|
1210
1198
|
|
1211
1199
|
def windows_platform?
|
@@ -1213,6 +1201,5 @@ module Git
|
|
1213
1201
|
win_platform_regex = /mingw|mswin/
|
1214
1202
|
RUBY_PLATFORM =~ win_platform_regex || RUBY_DESCRIPTION =~ win_platform_regex
|
1215
1203
|
end
|
1216
|
-
|
1217
1204
|
end
|
1218
1205
|
end
|
data/lib/git/version.rb
CHANGED
data/lib/git.rb
CHANGED
@@ -9,6 +9,8 @@ require 'git/branch'
|
|
9
9
|
require 'git/branches'
|
10
10
|
require 'git/config'
|
11
11
|
require 'git/diff'
|
12
|
+
require 'git/encoding_utils'
|
13
|
+
require 'git/escaped_path'
|
12
14
|
require 'git/index'
|
13
15
|
require 'git/lib'
|
14
16
|
require 'git/log'
|
@@ -212,6 +214,9 @@ module Git
|
|
212
214
|
# `"#{directory}/.git"`, create a bare repository at `"#{directory}"`.
|
213
215
|
# See [what is a bare repository?](https://git-scm.com/docs/gitglossary#Documentation/gitglossary.txt-aiddefbarerepositoryabarerepository).
|
214
216
|
#
|
217
|
+
# @option options [String] :initial_branch Use the specified name for the
|
218
|
+
# initial branch in the newly created repository.
|
219
|
+
#
|
215
220
|
# @option options [Pathname] :repository the path to put the newly initialized
|
216
221
|
# Git repository. The default for non-bare repository is `"#{directory}/.git"`.
|
217
222
|
#
|
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.
|
4
|
+
version: 1.10.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:
|
11
|
+
date: 2022-01-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rchardet
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.8'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bump
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.10'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.10'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: minitar
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -125,6 +139,7 @@ files:
|
|
125
139
|
- ".yardopts"
|
126
140
|
- CHANGELOG.md
|
127
141
|
- CONTRIBUTING.md
|
142
|
+
- Dockerfile.changelog-rs
|
128
143
|
- Gemfile
|
129
144
|
- ISSUE_TEMPLATE.md
|
130
145
|
- LICENSE
|
@@ -142,6 +157,8 @@ files:
|
|
142
157
|
- lib/git/branches.rb
|
143
158
|
- lib/git/config.rb
|
144
159
|
- lib/git/diff.rb
|
160
|
+
- lib/git/encoding_utils.rb
|
161
|
+
- lib/git/escaped_path.rb
|
145
162
|
- lib/git/index.rb
|
146
163
|
- lib/git/lib.rb
|
147
164
|
- lib/git/log.rb
|
@@ -179,7 +196,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
179
196
|
version: '0'
|
180
197
|
requirements:
|
181
198
|
- git 1.6.0.0, or greater
|
182
|
-
rubygems_version: 3.
|
199
|
+
rubygems_version: 3.1.6
|
183
200
|
signing_key:
|
184
201
|
specification_version: 4
|
185
202
|
summary: An API to create, read, and manipulate Git repositories
|