gitlab_git 7.2.11 → 7.2.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/gitlab_git/blame.rb +57 -11
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3dfe1adc18e236f4674a8a9444280bad676a7813
|
4
|
+
data.tar.gz: 8071dc50122e79328543e6a14965141d58450914
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed619af4decb82283bd18af7842d0abd3fb6433b3999ae395cd85d99eba84f8fcbb77305676aac13d387ceadfd81dfe800c7821e3b36c31fc779c8a198fa8f65
|
7
|
+
data.tar.gz: dc1bc45f26596917a2adc26bab5e94a0ee64655ca84f407259049f8f5ec65fbf29155d8d04b92cb95cdab5f3b2378665ad5c47d65457d93f6af2093ac04ec6ac
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
7.2.
|
1
|
+
7.2.12
|
data/lib/gitlab_git/blame.rb
CHANGED
@@ -1,24 +1,70 @@
|
|
1
1
|
module Gitlab
|
2
2
|
module Git
|
3
3
|
class Blame
|
4
|
-
|
4
|
+
attr_reader :lines, :blames
|
5
5
|
|
6
6
|
def initialize(repository, sha, path)
|
7
|
-
@repo = repository
|
8
|
-
@
|
9
|
-
@
|
10
|
-
@lines =
|
7
|
+
@repo = repository
|
8
|
+
@sha = sha
|
9
|
+
@path = path
|
10
|
+
@lines = []
|
11
|
+
@blames = load_blame
|
11
12
|
end
|
12
13
|
|
13
14
|
def each
|
14
|
-
@
|
15
|
-
|
16
|
-
|
15
|
+
@blames.each do |blame|
|
16
|
+
yield(
|
17
|
+
Gitlab::Git::Commit.new(blame.commit),
|
18
|
+
blame.line
|
19
|
+
)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def load_blame
|
26
|
+
cmd = %W(git --git-dir=#{@repo.path} blame -p #{@sha} -- #{@path})
|
27
|
+
raw_output = IO.popen(cmd) {|io| io.read }
|
28
|
+
process_raw_blame raw_output
|
29
|
+
end
|
30
|
+
|
31
|
+
def process_raw_blame(output)
|
32
|
+
lines, final = [], []
|
33
|
+
info, commits = {}, {}
|
34
|
+
|
35
|
+
# process the output
|
36
|
+
output.split("\n").each do |line|
|
37
|
+
if line[0, 1] == "\t"
|
38
|
+
lines << line[1, line.size]
|
39
|
+
elsif m = /^(\w{40}) (\d+) (\d+)/.match(line)
|
40
|
+
commit_id, old_lineno, lineno = m[1], m[2].to_i, m[3].to_i
|
41
|
+
commits[commit_id] = nil if !commits.key?(commit_id)
|
42
|
+
info[lineno] = [commit_id, old_lineno]
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
# load all commits in single call
|
47
|
+
commits.keys.each do |key|
|
48
|
+
commits[key] = @repo.lookup(key)
|
49
|
+
end
|
17
50
|
|
18
|
-
|
19
|
-
|
20
|
-
|
51
|
+
# get it together
|
52
|
+
info.sort.each do |lineno, (commit_id, old_lineno)|
|
53
|
+
commit = commits[commit_id]
|
54
|
+
final << BlameLine.new(lineno, old_lineno, commit, lines[lineno - 1])
|
21
55
|
end
|
56
|
+
|
57
|
+
@lines = final
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
class BlameLine
|
62
|
+
attr_accessor :lineno, :oldlineno, :commit, :line
|
63
|
+
def initialize(lineno, oldlineno, commit, line)
|
64
|
+
@lineno = lineno
|
65
|
+
@oldlineno = oldlineno
|
66
|
+
@commit = commit
|
67
|
+
@line = line
|
22
68
|
end
|
23
69
|
end
|
24
70
|
end
|
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.2.
|
4
|
+
version: 7.2.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dmitriy Zaporozhets
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-08-
|
11
|
+
date: 2015-08-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gitlab-linguist
|
@@ -108,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
108
108
|
version: '0'
|
109
109
|
requirements: []
|
110
110
|
rubyforge_project:
|
111
|
-
rubygems_version: 2.
|
111
|
+
rubygems_version: 2.4.3
|
112
112
|
signing_key:
|
113
113
|
specification_version: 4
|
114
114
|
summary: Gitlab::Git library
|