gitlab_git 1.2.1 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/gitlab_git.rb +2 -0
- data/lib/gitlab_git/commit.rb +14 -16
- data/lib/gitlab_git/git_stats.rb +24 -0
- data/lib/gitlab_git/log_parser.rb +36 -0
- data/lib/gitlab_git/repository.rb +2 -2
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e1c33717978708a9c7bfd0e2f85847cb558d94f0
|
4
|
+
data.tar.gz: 2604d9e922980d00bcc6b9dfae9a7def3493f0dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ac05b8e0f12b2d1591e753d1b0587c2d5da95593c67e16a1afda31c8f00ddc9e07dc42c41607fb5248eaa75e35b5f9f7a3d7d0e147272a0c99e81a0323ac613d
|
7
|
+
data.tar.gz: 8a73a2d71cce28ccca47274a4c8a3d5aaa3c28ec3b52efa4daa78029d2abf1b27fca6a3b8f2ab1dea00d8febd810b19ca1f48fd86095ae31d2bd885259ca1d76
|
data/lib/gitlab_git.rb
CHANGED
data/lib/gitlab_git/commit.rb
CHANGED
@@ -4,10 +4,14 @@
|
|
4
4
|
module Gitlab
|
5
5
|
module Git
|
6
6
|
class Commit
|
7
|
-
attr_accessor :raw_commit, :head, :refs
|
8
|
-
|
9
|
-
|
10
|
-
:
|
7
|
+
attr_accessor :raw_commit, :head, :refs
|
8
|
+
|
9
|
+
SERIALIZE_KEYS = [
|
10
|
+
:id, :message, :parent_ids,
|
11
|
+
:authored_date, :author_name, :author_email,
|
12
|
+
:committed_date, :committer_name, :committer_email
|
13
|
+
]
|
14
|
+
attr_accessor *SERIALIZE_KEYS
|
11
15
|
|
12
16
|
def initialize(raw_commit, head = nil)
|
13
17
|
raise "Nil as raw commit passed" unless raw_commit
|
@@ -21,10 +25,6 @@ module Gitlab
|
|
21
25
|
@head = head
|
22
26
|
end
|
23
27
|
|
24
|
-
def serialize_keys
|
25
|
-
@serialize_keys ||= %w(id authored_date committed_date author_name author_email committer_name committer_email message parent_ids).map(&:to_sym)
|
26
|
-
end
|
27
|
-
|
28
28
|
def sha
|
29
29
|
id
|
30
30
|
end
|
@@ -78,15 +78,9 @@ module Gitlab
|
|
78
78
|
end
|
79
79
|
|
80
80
|
def to_hash
|
81
|
-
|
82
|
-
|
83
|
-
keys = serialize_keys
|
84
|
-
|
85
|
-
keys.each do |key|
|
81
|
+
serialize_keys.map.with_object({}) do |key, hash|
|
86
82
|
hash[key] = send(key)
|
87
83
|
end
|
88
|
-
|
89
|
-
hash
|
90
84
|
end
|
91
85
|
|
92
86
|
def date
|
@@ -132,9 +126,13 @@ module Gitlab
|
|
132
126
|
raw_commit = hash.symbolize_keys
|
133
127
|
|
134
128
|
serialize_keys.each do |key|
|
135
|
-
send(
|
129
|
+
send("#{key}=", raw_commit[key])
|
136
130
|
end
|
137
131
|
end
|
132
|
+
|
133
|
+
def serialize_keys
|
134
|
+
SERIALIZE_KEYS
|
135
|
+
end
|
138
136
|
end
|
139
137
|
end
|
140
138
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require_relative 'log_parser'
|
2
|
+
|
3
|
+
module Gitlab
|
4
|
+
module Git
|
5
|
+
class GitStats
|
6
|
+
attr_accessor :repo, :ref
|
7
|
+
|
8
|
+
def initialize repo, ref
|
9
|
+
@repo, @ref = repo, ref
|
10
|
+
end
|
11
|
+
|
12
|
+
def log
|
13
|
+
args = ['--format=%aN%x0a%ad', '--date=short', '--shortstat', '--no-merges']
|
14
|
+
repo.git.run(nil, 'log', nil, {}, args)
|
15
|
+
rescue Grit::Git::GitTimeout
|
16
|
+
nil
|
17
|
+
end
|
18
|
+
|
19
|
+
def parsed_log
|
20
|
+
LogParser.parse_log(log)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Gitlab
|
2
|
+
module Git
|
3
|
+
class LogParser
|
4
|
+
# Parses the log file into a collection of commits
|
5
|
+
# Data model: {author, date, additions, deletions}
|
6
|
+
def self.parse_log log_from_git
|
7
|
+
log = log_from_git.split("\n")
|
8
|
+
|
9
|
+
i = 0
|
10
|
+
collection = []
|
11
|
+
entry = {}
|
12
|
+
|
13
|
+
while i <= log.size do
|
14
|
+
pos = i % 4
|
15
|
+
case pos
|
16
|
+
when 0
|
17
|
+
unless i == 0
|
18
|
+
collection.push(entry)
|
19
|
+
entry = {}
|
20
|
+
end
|
21
|
+
entry[:author] = log[i].to_s
|
22
|
+
when 1
|
23
|
+
entry[:date] = log[i].to_s
|
24
|
+
when 3
|
25
|
+
changes = log[i].split(",")
|
26
|
+
entry[:additions] = changes[1].to_i unless changes[1].nil?
|
27
|
+
entry[:deletions] = changes[2].to_i unless changes[2].nil?
|
28
|
+
end
|
29
|
+
i += 1
|
30
|
+
end
|
31
|
+
|
32
|
+
collection
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -111,7 +111,7 @@ module Gitlab
|
|
111
111
|
|
112
112
|
# Returns an Array of tag names
|
113
113
|
def tag_names
|
114
|
-
|
114
|
+
tags.map(&:name)
|
115
115
|
end
|
116
116
|
|
117
117
|
# Returns an Array of Tags
|
@@ -121,7 +121,7 @@ module Gitlab
|
|
121
121
|
|
122
122
|
# Returns an Array of branch and tag names
|
123
123
|
def ref_names
|
124
|
-
|
124
|
+
branch_names + tag_names
|
125
125
|
end
|
126
126
|
|
127
127
|
def heads
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gitlab_git
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dmitriy Zaporozhets
|
@@ -65,6 +65,8 @@ files:
|
|
65
65
|
- lib/gitlab_git/commit.rb
|
66
66
|
- lib/gitlab_git/compare.rb
|
67
67
|
- lib/gitlab_git/diff.rb
|
68
|
+
- lib/gitlab_git/git_stats.rb
|
69
|
+
- lib/gitlab_git/log_parser.rb
|
68
70
|
- lib/gitlab_git/popen.rb
|
69
71
|
- lib/gitlab_git/repository.rb
|
70
72
|
- lib/gitlab_git/stats.rb
|