git 1.9.1 → 1.10.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1c98b8817ceb2d65efcf09cd2461023a5fb514fb738524332dbd98daae2b8cf0
4
- data.tar.gz: 7fa575c50ed9f3c85bbd9aadd6e1d0a74d4421f9b3d612d43f761a1d77f7b1e2
3
+ metadata.gz: f7d02f0f135a2a2f9e4f8d661bc4c5d4323af8b46a527581c0f47ff17df88019
4
+ data.tar.gz: c45684c1b8f6af0c5a44a90c0e8918860653a6abb4a6464d11faff90278ef7c7
5
5
  SHA512:
6
- metadata.gz: ecec9d8d598576983f48b9193ebadb4dc0a53745df0b0c27466ee075947945ea793dbb112107d4e5eaf70cca2cb93c3b0f83489af12d4b42d6336051261124ee
7
- data.tar.gz: c164e57a0f9006672826c993719c85a8997e08b2272da7e48e17e945bffb9917d74cb3957ce09c9cb3b8cb4cec03f236b88f0334c5322a948e1f12021ffad5b7
6
+ metadata.gz: 5bd13aa06dcdb48d0f47ac72d82608120a73b9fb83db278070715d9ce98023e18e75f61c5c42ea13fc24a8f125bde989e8afbc0460c94e1a6eb5c4cd658f7639
7
+ data.tar.gz: 5c9a4e9d8734a23162e9c858246ac705ac3413db73f8e728845b7ae62aec7b6096f2b06ddcdc195c57efe052058e26c5b9340f1d9dbdc972bf8f68f303c7eba9
data/CHANGELOG.md CHANGED
@@ -5,6 +5,10 @@
5
5
 
6
6
  # Change Log
7
7
 
8
+ ## 1.10.0
9
+
10
+ See https://github.com/ruby-git/ruby-git/releases/tag/v1.10.0
11
+
8
12
  ## 1.9.1
9
13
 
10
14
  See https://github.com/ruby-git/ruby-git/releases/tag/v1.9.1
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
- self.new({:repository => git_dir}.merge(options))
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
- self.new(Git::Lib.new(nil, options[:log]).clone(repository, name, options))
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
- return @@config ||= Config.new
30
+ @@config ||= Config.new
28
31
  end
29
32
 
30
33
  # (see Git.init)
31
- def self.init(directory, options = {})
32
- options[:working_directory] ||= directory
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 = { :bare => options[:bare] }
37
+ init_options = {
38
+ :bare => options[:bare],
39
+ :initial_branch => options[:initial_branch],
40
+ }
38
41
 
39
- options.delete(:working_directory) if options[:bare]
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
- # TODO: move this to Git.open?
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
- end
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/lib.rb CHANGED
@@ -71,10 +71,12 @@ module Git
71
71
  # options:
72
72
  # :bare
73
73
  # :working_directory
74
+ # :initial_branch
74
75
  #
75
76
  def init(opts={})
76
77
  arr_opts = []
77
78
  arr_opts << '--bare' if opts[:bare]
79
+ arr_opts << "--initial-branch=#{opts[:initial_branch]}" if opts[:initial_branch]
78
80
 
79
81
  command('init', arr_opts)
80
82
  end
@@ -682,6 +684,7 @@ module Git
682
684
  def clean(opts = {})
683
685
  arr_opts = []
684
686
  arr_opts << '--force' if opts[:force]
687
+ arr_opts << '-ff' if opts[:ff]
685
688
  arr_opts << '-d' if opts[:d]
686
689
  arr_opts << '-x' if opts[:x]
687
690
 
@@ -772,6 +775,7 @@ module Git
772
775
 
773
776
  def merge(branch, message = nil, opts = {})
774
777
  arr_opts = []
778
+ arr_opts << '--no-commit' if opts[:no_commit]
775
779
  arr_opts << '--no-ff' if opts[:no_ff]
776
780
  arr_opts << '-m' << message if message
777
781
  arr_opts += [branch]
@@ -879,6 +883,7 @@ module Git
879
883
  arr_opts << '--tags' if opts[:t] || opts[:tags]
880
884
  arr_opts << '--prune' if opts[:p] || opts[:prune]
881
885
  arr_opts << '--unshallow' if opts[:unshallow]
886
+ arr_opts << '--depth' << opts[:depth] if opts[:depth]
882
887
 
883
888
  command('fetch', arr_opts)
884
889
  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.9.1'
4
+ VERSION='1.10.0'
5
5
  end
data/lib/git.rb CHANGED
@@ -212,6 +212,9 @@ module Git
212
212
  # `"#{directory}/.git"`, create a bare repository at `"#{directory}"`.
213
213
  # See [what is a bare repository?](https://git-scm.com/docs/gitglossary#Documentation/gitglossary.txt-aiddefbarerepositoryabarerepository).
214
214
  #
215
+ # @option options [String] :initial_branch Use the specified name for the
216
+ # initial branch in the newly created repository.
217
+ #
215
218
  # @option options [Pathname] :repository the path to put the newly initialized
216
219
  # Git repository. The default for non-bare repository is `"#{directory}/.git"`.
217
220
  #
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.9.1
4
+ version: 1.10.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: 2021-07-07 00:00:00.000000000 Z
11
+ date: 2021-12-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rchardet
@@ -179,7 +179,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
179
179
  version: '0'
180
180
  requirements:
181
181
  - git 1.6.0.0, or greater
182
- rubygems_version: 3.2.15
182
+ rubygems_version: 3.1.6
183
183
  signing_key:
184
184
  specification_version: 4
185
185
  summary: An API to create, read, and manipulate Git repositories