git 1.5.0 → 1.6.0.pre1

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: 86d44aad4d6c430e5e224d27ddfece08f6a5696c068dbe041df3bd740ae94d7a
4
- data.tar.gz: d7ac8d85b906620006cb5c1fc9206d6f406115490b88fedc7fb8aebe4a8302c9
3
+ metadata.gz: 291adaa24da09656259518cf50d18882222a6704c742f70d266378a7c4d440cc
4
+ data.tar.gz: 46639fb4a5542f2354d9713dd47adca9349fda39a8b0a6a1d739e830214a1c05
5
5
  SHA512:
6
- metadata.gz: 19d5093d80ee3a4af8c6ceb27185464378a715330de92893cd81ece19a71986e29f7631c389b7204eb2bb4a47b0dcc8ce56f3a90164a6f2a22b696d53c6e8179
7
- data.tar.gz: 29895e438fec3de810e1b3f78bf2c177b04081a72fdfad72a3e231ee3737df23e6cbebb58678a81c9883bcbb05b29058bee9c4c6189dcdac21249e8ac5bd0959
6
+ metadata.gz: 3bd0c914126e45b381671af36637e226817f7894164344c3abed242e3ba34a414290a9adceff25e7cc931be89192d17fe2510945d4391ffd35e994c79f71dab0
7
+ data.tar.gz: e249b429712dd287389f13d59e09c344e372b6d77189fa3baf1b81b63126f93e8f71c752b90c0f1227aa5d374efed4ee5aa572aca55832276c13ed1e86ddaee7
@@ -1,5 +1,9 @@
1
1
  # Change Log
2
2
 
3
+ ## 1.6.0.pre1
4
+
5
+ See https://github.com/ruby-git/ruby-git/releases/tag/v1.6.0.pre1
6
+
3
7
  ## 1.5.0
4
8
 
5
9
  See https://github.com/ruby-git/ruby-git/releases/tag/v1.5.0
data/README.md CHANGED
@@ -66,9 +66,9 @@ Git env config
66
66
  # If you need to use a custom SSH script
67
67
  config.git_ssh = '/path/to/ssh/script'
68
68
  end
69
-
70
69
  ```
71
70
 
71
+ _NOTE: Another way to specify where is the `git` binary is through the environment variable `GIT_PATH`_
72
72
 
73
73
  Here are the operations that need read permission only.
74
74
 
@@ -216,6 +216,8 @@ And here are the operations that will need to write to your git repository.
216
216
  g.merge(g.branch('master'))
217
217
  g.merge([branch1, branch2])
218
218
 
219
+ g.merge_base('branch1', 'branch2')
220
+
219
221
  r = g.add_remote(name, uri) # Git::Remote
220
222
  r = g.add_remote(name, Git::Base) # Git::Remote
221
223
 
@@ -68,6 +68,14 @@ module Git
68
68
  Git::Object.new(self, tag_name, 'tag', true)
69
69
  end
70
70
 
71
+ # Find as good common ancestors as possible for a merge
72
+ # example: g.merge_base('master', 'some_branch', 'some_sha', octopus: true)
73
+ # returns Array<Git::Object::Commit>
74
+ def merge_base(*args)
75
+ shas = self.lib.merge_base(*args)
76
+ shas.map { |sha| gcommit(sha) }
77
+ end
78
+
71
79
  end
72
80
 
73
81
  end
@@ -10,7 +10,7 @@ module Git
10
10
  end
11
11
 
12
12
  def binary_path
13
- @binary_path || 'git'
13
+ @binary_path || ENV['GIT_PATH'] && File.join(ENV['GIT_PATH'], 'git') || 'git'
14
14
  end
15
15
 
16
16
  def git_ssh
@@ -127,12 +127,7 @@ module Git
127
127
  }
128
128
  final = {}
129
129
  current_file = nil
130
- if @full_diff.encoding.name != "UTF-8"
131
- full_diff_utf8_encoded = @full_diff.encode("UTF-8", "binary", { :invalid => :replace, :undef => :replace })
132
- else
133
- full_diff_utf8_encoded = @full_diff
134
- end
135
- full_diff_utf8_encoded.split("\n").each do |line|
130
+ @full_diff.split("\n").each do |line|
136
131
  if m = /^diff --git a\/(.*?) b\/(.*?)/.match(line)
137
132
  current_file = m[1]
138
133
  final[current_file] = defaults.merge({:patch => line, :path => current_file})
@@ -1,3 +1,4 @@
1
+ require 'rchardet'
1
2
  require 'tempfile'
2
3
 
3
4
  module Git
@@ -666,6 +667,21 @@ module Git
666
667
  command('merge', arr_opts)
667
668
  end
668
669
 
670
+ def merge_base(*args)
671
+ opts = args.last.is_a?(Hash) ? args.pop : {}
672
+
673
+ arg_opts = []
674
+
675
+ arg_opts << '--octopus' if opts[:octopus]
676
+ arg_opts << '--independent' if opts[:independent]
677
+ arg_opts << '--fork-point' if opts[:fork_point]
678
+ arg_opts << '--all' if opts[:all]
679
+
680
+ arg_opts += args
681
+
682
+ command('merge-base', arg_opts).lines.map(&:strip)
683
+ end
684
+
669
685
  def unmerged
670
686
  unmerged = []
671
687
  command_lines('diff', ["--cached"]).each do |line|
@@ -747,6 +763,7 @@ module Git
747
763
  arr_opts << opts[:ref] if opts[:ref]
748
764
  arr_opts << '--tags' if opts[:t] || opts[:tags]
749
765
  arr_opts << '--prune' if opts[:p] || opts[:prune]
766
+ arr_opts << '--unshallow' if opts[:unshallow]
750
767
 
751
768
  command('fetch', arr_opts)
752
769
  end
@@ -884,16 +901,7 @@ module Git
884
901
  ENV_VARIABLE_NAMES = ['GIT_DIR', 'GIT_WORK_TREE', 'GIT_INDEX_FILE', 'GIT_SSH']
885
902
 
886
903
  def command_lines(cmd, opts = [], chdir = true, redirect = '')
887
- cmd_op = command(cmd, opts, chdir)
888
- if cmd_op.encoding.name != "UTF-8"
889
- op = cmd_op.encode("UTF-8", "binary", {
890
- :invalid => :replace,
891
- :undef => :replace
892
- })
893
- else
894
- op = cmd_op
895
- end
896
- op.split("\n")
904
+ command(cmd, opts, chdir).lines.map(&:chomp)
897
905
  end
898
906
 
899
907
  # Takes the current git's system ENV variables and store them.
@@ -1023,10 +1031,35 @@ module Git
1023
1031
  arr_opts
1024
1032
  end
1025
1033
 
1034
+ def default_encoding
1035
+ __ENCODING__.name
1036
+ end
1037
+
1038
+ def best_guess_encoding
1039
+ # Encoding::ASCII_8BIT.name
1040
+ Encoding::UTF_8.name
1041
+ end
1042
+
1043
+ def detected_encoding(str)
1044
+ CharDet.detect(str)['encoding'] || best_guess_encoding
1045
+ end
1046
+
1047
+ def encoding_options
1048
+ { invalid: :replace, undef: :replace }
1049
+ end
1050
+
1051
+ def normalize_encoding(str)
1052
+ return str if str.valid_encoding? && str.encoding == default_encoding
1053
+
1054
+ return str.encode(default_encoding, str.encoding, encoding_options) if str.valid_encoding?
1055
+
1056
+ str.encode(default_encoding, detected_encoding(str), encoding_options)
1057
+ end
1058
+
1026
1059
  def run_command(git_cmd, &block)
1027
1060
  return IO.popen(git_cmd, &block) if block_given?
1028
1061
 
1029
- `#{git_cmd}`.chomp
1062
+ `#{git_cmd}`.chomp.lines.map { |l| normalize_encoding(l) }.join
1030
1063
  end
1031
1064
 
1032
1065
  def escape(s)
@@ -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.5.0'
4
+ VERSION='1.6.0.pre1'
5
5
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 1.6.0.pre1
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: 2018-08-10 00:00:00.000000000 Z
11
+ date: 2020-01-20 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rchardet
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.8'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.8'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: rake
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -111,8 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
111
125
  version: '0'
112
126
  requirements:
113
127
  - git 1.6.0.0, or greater
114
- rubyforge_project:
115
- rubygems_version: 2.7.6
128
+ rubygems_version: 3.0.6
116
129
  signing_key:
117
130
  specification_version: 4
118
131
  summary: Ruby/Git is a Ruby library that can be used to create, read and manipulate