gitlab_git 5.3.0 → 5.4.0

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: ddb7cedb6dcc41c8e2ba624b7718fcfd76f1474a
4
- data.tar.gz: 300923b0bb6c9dd1957b186c499cf04ef22e8d9d
3
+ metadata.gz: a55120d34d9e9b2087ebb986213e27d01d1fe76b
4
+ data.tar.gz: fa165fd88b30db8cdfe33b0d9525088b0f505993
5
5
  SHA512:
6
- metadata.gz: 1bc8919844978c5070f8507a5368199717273cef573c60023caa3ea78d5ff19c0f4ce5859b2527573666d4780052436dad6f69a70c31bc80c6cfc07eef59050f
7
- data.tar.gz: 5ffa553d9dd5f5aa008da4474dae67c679cac65efcd99caa67d0e8c5792a5ca0a78ca26da77d04decf5f2e061336f1a0e7312867f24632fa712c64f24d7a567d
6
+ metadata.gz: a271874e14e54fca6437a92709b0249383983f80f2d49439f11ff12b4e195ca347f8c3de8b46523b01f3225241859eae00b8695d85d4fefb7fe839814eda9aed
7
+ data.tar.gz: e5445e97d57aaf696886791a17aba0e1e1e1dd177d8e68cc9b7aa68d4915b50f9697c7d5d9d4e504778665f1eb7111895b721a306e1739b05d06f06d2b9d250d
data/VERSION CHANGED
@@ -1 +1 @@
1
- 5.3.0
1
+ 5.4.0
@@ -4,6 +4,7 @@ require 'fileutils'
4
4
  require 'grit'
5
5
  require 'linguist'
6
6
  require 'active_support/core_ext/hash/keys'
7
+ require 'active_support/core_ext/object/try'
7
8
  require 'grit'
8
9
  require 'grit_ext'
9
10
  require 'rugged'
@@ -1,7 +1,7 @@
1
1
  module Gitlab
2
2
  module Git
3
3
  class Compare
4
- attr_accessor :commits, :commit, :diffs, :same
4
+ attr_accessor :commits, :commit, :diffs, :same, :limit, :timeout
5
5
 
6
6
  def initialize(repository, from, to, limit = 100)
7
7
  @commits, @diffs = [], []
@@ -9,6 +9,7 @@ module Gitlab
9
9
  @same = false
10
10
  @limit = limit
11
11
  @repository = repository
12
+ @timeout = false
12
13
 
13
14
  return unless from && to
14
15
 
@@ -27,10 +28,33 @@ module Gitlab
27
28
  end
28
29
 
29
30
  def diffs(paths = nil)
30
- return [] if @commits.size > @limit
31
- Gitlab::Git::Diff.between(@repository, @head.id, @base.id, *paths) rescue []
31
+ # Return empty array if amount of commits
32
+ # more than specified limit
33
+ return [] if commits_over_limit?
34
+
35
+ # Try to collect diff only if diffs is empty
36
+ # Otherwise return cached version
37
+ if @diffs.empty? && @timeout == false
38
+ begin
39
+ @diffs = Gitlab::Git::Diff.between(@repository, @head.id, @base.id, *paths)
40
+ rescue Gitlab::Git::Diff::TimeoutError => ex
41
+ @diffs = []
42
+ @timeout = true
43
+ end
44
+ end
45
+
46
+ @diffs
47
+ end
48
+
49
+ # Check if diff is empty because it is actually empty
50
+ # and not because its impossible to get it
51
+ def empty_diff?
52
+ diffs.empty? && timeout == false && commits.size < limit
53
+ end
54
+
55
+ def commits_over_limit?
56
+ commits.size > limit
32
57
  end
33
58
  end
34
59
  end
35
60
  end
36
-
@@ -4,7 +4,7 @@
4
4
  module Gitlab
5
5
  module Git
6
6
  class Diff
7
- BROKEN_DIFF = "--broken-diff"
7
+ class TimeoutError < StandardError; end
8
8
 
9
9
  attr_accessor :raw_diff
10
10
 
@@ -25,7 +25,7 @@ module Gitlab
25
25
  Gitlab::Git::Diff.new(diff)
26
26
  end
27
27
  rescue Grit::Git::GitTimeout
28
- [Gitlab::Git::Diff::BROKEN_DIFF]
28
+ raise TimeoutError.new("Diff.between exited with timeout")
29
29
  end
30
30
  end
31
31
 
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: 5.3.0
4
+ version: 5.4.0
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-02-09 00:00:00.000000000 Z
11
+ date: 2014-02-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gitlab-linguist