gitlab_git 7.0.0.rc10 → 7.0.0.rc11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 47fb0500cc9f11693684d6b9f27574948da9ef92
4
- data.tar.gz: 19dffe313f146a53f799ab8c6de3ce5a1cbed734
3
+ metadata.gz: 01d35bccb72fd1412692b9c65341610f78616595
4
+ data.tar.gz: 636bf49e47997552e56cd1af4858632621701283
5
5
  SHA512:
6
- metadata.gz: 77646b0c9cc5b1d6f4d218928c9ef143b0caae0eef394c17fe893f032f986efaebc0639c3d94ee9c4faeb39a5fa627b7a10f0db161ccfba2cda658a88bd1ed4b
7
- data.tar.gz: fc6fccda0442a3acb885d92d6b924e4f5344bee8cac725c048541d0f296f9acb03f2bfdd04ec26529e4c72f96519b8b31b4ac90842b12b1fbfcda6d63a674331
6
+ metadata.gz: 5a03878e04c0906780ea36d4852f1e030388c60862ffbbcef6395a8e66f41f0e534be34d8f0079aa938aadbcff909d5d4df50593d8603aad11b70d0d514dc8f7
7
+ data.tar.gz: 2636e356c09f723637d585236c58fb50c52e154482a9aebf1d725d397e755fc4a63fbb8aed92d33205c322949f3ca2bf33f61fbc250c0abd6113643f89a304e4
data/VERSION CHANGED
@@ -1 +1 @@
1
- 7.0.0.rc10
1
+ 7.0.0.rc11
@@ -15,18 +15,22 @@ module Gitlab
15
15
 
16
16
  return nil unless blob_entry
17
17
 
18
- blob = repository.lookup(blob_entry[:oid])
19
-
20
- if blob
21
- Blob.new(
22
- id: blob.oid,
23
- name: blob_entry[:name],
24
- size: blob.size,
25
- data: blob.content,
26
- mode: blob_entry[:mode],
27
- path: path,
28
- commit_id: sha,
29
- )
18
+ if blob_entry[:type] == :commit
19
+ submodule_blob(blob_entry, path, sha)
20
+ else
21
+ blob = repository.lookup(blob_entry[:oid])
22
+
23
+ if blob
24
+ Blob.new(
25
+ id: blob.oid,
26
+ name: blob_entry[:name],
27
+ size: blob.size,
28
+ data: blob.content,
29
+ mode: blob_entry[:mode],
30
+ path: path,
31
+ commit_id: sha,
32
+ )
33
+ end
30
34
  end
31
35
  end
32
36
 
@@ -63,17 +67,22 @@ module Gitlab
63
67
 
64
68
  if path_arr.size > 1
65
69
  return nil unless entry[:type] == :tree
66
- else
67
- return nil unless entry[:type] == :blob
68
- end
69
-
70
- if path_arr.size > 1
71
70
  path_arr.shift
72
71
  find_entry_by_path(repository, entry[:oid], path_arr.join('/'))
73
72
  else
74
- entry
73
+ [:blob, :commit].include?(entry[:type]) ? entry : nil
75
74
  end
76
75
  end
76
+
77
+ def submodule_blob(blob_entry, path, sha)
78
+ Blob.new(
79
+ id: blob_entry[:oid],
80
+ name: blob_entry[:name],
81
+ data: '',
82
+ path: path,
83
+ commit_id: sha,
84
+ )
85
+ end
77
86
  end
78
87
 
79
88
  def initialize(options)
@@ -5,8 +5,6 @@ module Gitlab
5
5
  class TimeoutError < StandardError; end
6
6
  include EncodingHelper
7
7
 
8
- attr_accessor :raw_diff
9
-
10
8
  # Diff properties
11
9
  attr_accessor :old_path, :new_path, :a_mode, :b_mode, :diff
12
10
 
@@ -52,11 +50,13 @@ module Gitlab
52
50
  hash
53
51
  end
54
52
 
53
+ def submodule?
54
+ a_mode == '160000' || b_mode == '160000'
55
+ end
56
+
55
57
  private
56
58
 
57
59
  def init_from_rugged(rugged)
58
- @raw_diff = rugged
59
-
60
60
  @diff = encode!(strip_diff_headers(rugged.to_s))
61
61
 
62
62
  d = rugged.delta
@@ -80,9 +80,20 @@ module Gitlab
80
80
  # Strip out the information at the beginning of the patch's text to match
81
81
  # Grit's output
82
82
  def strip_diff_headers(diff_text)
83
- lines = diff_text.split("\n")
84
- lines.shift until lines.empty? || lines.first.match("^(---|Binary)")
85
- lines.join("\n")
83
+ # Delete everything up to the first line that starts with '---' or
84
+ # 'Binary'
85
+ diff_text.sub!(/\A.*?^(---|Binary)/m, '\1')
86
+ # Remove trailing newline because the tests ask for it
87
+ diff_text.chomp!
88
+
89
+ if diff_text.start_with?('---') or diff_text.start_with?('Binary')
90
+ diff_text
91
+ else
92
+ # If the diff_text did not contain a line starting with '---' or
93
+ # 'Binary', return the empty string. No idea why; we are just
94
+ # preserving behavior from before the refactor.
95
+ ''
96
+ end
86
97
  end
87
98
  end
88
99
  end
@@ -265,7 +265,7 @@ module Gitlab
265
265
  # Return an array of Diff objects that represent the diff
266
266
  # between +from+ and +to+.
267
267
  def diff(from, to, *paths)
268
- rugged.diff(from, to, paths: paths).patches.map do |p|
268
+ rugged.diff(from, to, paths: paths).each_patch.map do |p|
269
269
  Gitlab::Git::Diff.new(p)
270
270
  end
271
271
  end
@@ -275,7 +275,7 @@ module Gitlab
275
275
  # NOTE: It would be simpler to use the Rugged::Diff#patch method, but
276
276
  # that formats the diff text differently than Rugged::Patch#to_s for
277
277
  # changes to binary files.
278
- rugged.diff(from, to, paths: paths).patches.map do |p|
278
+ rugged.diff(from, to, paths: paths).each_patch.map do |p|
279
279
  p.to_s
280
280
  end.join("\n")
281
281
  end
@@ -736,11 +736,11 @@ module Gitlab
736
736
 
737
737
  current = ""
738
738
  content.split("\n").each do |txt|
739
- if txt.match(/^\[/)
739
+ if txt.match(/^\s*\[/)
740
740
  current = txt.match(/(?<=").*(?=")/)[0]
741
741
  results[current] = {}
742
742
  else
743
- match_data = txt.match(/(\w+) = (.*)/)
743
+ match_data = txt.match(/(\w+)\s*=\s*(.*)/)
744
744
  results[current][match_data[1]] = match_data[2]
745
745
 
746
746
  if match_data[1] == "path"
@@ -778,7 +778,7 @@ module Gitlab
778
778
  end
779
779
 
780
780
  if !current_path ||
781
- commit_touches_path?(c, current_path, options[:follow])
781
+ commit_touches_path?(c, current_path, options[:follow], walker)
782
782
 
783
783
  # This is a commit we care about, unless we haven't skipped enough
784
784
  # yet
@@ -792,36 +792,43 @@ module Gitlab
792
792
  commits
793
793
  end
794
794
 
795
- # Returns true if the given commit affects the given path. If the
796
- # +follow+ option is true and the file specified by +path+ was renamed,
797
- # then the path value is set to the old path.
798
- def commit_touches_path?(commit, path, follow)
799
- if follow
800
- touches_path_diff?(commit, path)
801
- else
802
- touches_path_tree?(commit, path)
803
- end
804
- end
805
-
806
795
  # Returns true if +commit+ introduced changes to +path+, using commit
807
- # trees to make that determination.
808
- def touches_path_tree?(commit, path)
809
- parent = commit.parents[0]
796
+ # trees to make that determination. Uses the history simplification
797
+ # rules that `git log` uses by default, where a commit is omitted if it
798
+ # is TREESAME to any parent.
799
+ #
800
+ # If the +follow+ option is true and the file specified by +path+ was
801
+ # renamed, then the path value is set to the old path.
802
+ def commit_touches_path?(commit, path, follow, walker)
810
803
  entry = tree_entry(commit, path)
811
804
 
812
- if parent.nil?
805
+ if commit.parents.empty?
813
806
  # This is the root commit, return true if it has +path+ in its tree
814
807
  return entry != nil
815
808
  end
816
809
 
817
- parent_entry = tree_entry(parent, path)
810
+ num_treesame = 0
811
+ commit.parents.each do |parent|
812
+ parent_entry = tree_entry(parent, path)
813
+
814
+ # Only follow the first TREESAME parent for merge commits
815
+ if num_treesame > 0
816
+ walker.hide(parent)
817
+ next
818
+ end
818
819
 
819
- if entry.nil? && parent_entry.nil?
820
- false
821
- elsif entry.nil? || parent_entry.nil?
820
+ if entry.nil? && parent_entry.nil?
821
+ num_treesame += 1
822
+ elsif entry && parent_entry && entry[:oid] == parent_entry[:oid]
823
+ num_treesame += 1
824
+ end
825
+ end
826
+
827
+ case num_treesame
828
+ when 0
829
+ detect_rename(commit, commit.parents.first, path) if follow
822
830
  true
823
- else
824
- entry[:oid] != parent_entry[:oid]
831
+ else false
825
832
  end
826
833
  end
827
834
 
@@ -841,24 +848,18 @@ module Gitlab
841
848
  tmp_entry
842
849
  end
843
850
 
844
- # Returns true if +commit+ introduced changes to +path+, using
845
- # Rugged::Diff objects to make that determination. This is slower than
846
- # comparing commit trees, but lets us use Rugged::Diff#find_similar to
847
- # detect file renames.
848
- def touches_path_diff?(commit, path)
849
- diff = commit.diff(reverse: true, paths: [path],
850
- disable_pathspec_match: true)
851
-
852
- return false if diff.deltas.empty?
851
+ # Compare +commit+ and +parent+ for +path+. If +path+ is a file and was
852
+ # renamed in +commit+, then set +path+ to the old filename.
853
+ def detect_rename(commit, parent, path)
854
+ diff = parent.diff(commit, paths: [path], disable_pathspec_match: true)
853
855
 
854
856
  # If +path+ is a filename, not a directory, then we should only have
855
857
  # one delta. We don't need to follow renames for directories.
856
- return true if diff.deltas.length > 1
858
+ return nil if diff.each_delta.count > 1
857
859
 
858
- # Detect renames
859
- delta = diff.deltas.first
860
+ delta = diff.each_delta.first
860
861
  if delta.added?
861
- full_diff = commit.diff(reverse: true)
862
+ full_diff = parent.diff(commit)
862
863
  full_diff.find_similar!
863
864
 
864
865
  full_diff.each_delta do |full_delta|
@@ -868,8 +869,6 @@ module Gitlab
868
869
  end
869
870
  end
870
871
  end
871
-
872
- true
873
872
  end
874
873
 
875
874
  def archive_to_file(treeish = 'master', prefix = nil, filename = 'archive.tar.gz', format = nil, compress_cmd = %W(gzip))
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitlab_git
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.0.0.rc10
4
+ version: 7.0.0.rc11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitriy Zaporozhets
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-24 00:00:00.000000000 Z
11
+ date: 2014-11-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gitlab-linguist