gitall 1.1.14 → 1.1.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -1
- data/lib/gitall.rb +24 -1
- data/lib/gitall/parsers/github.rb +1 -0
- data/lib/gitall/parsers/gitlab.rb +1 -0
- data/lib/gitall/parsers/gogs.rb +103 -0
- data/lib/gitall/plugins/git.rb +5 -3
- data/lib/gitall/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f4fcb2bd7529f17844eda9c2cd6258e5085b8aab55a127e24a146a2f67057dc7
|
4
|
+
data.tar.gz: f53265464f613a0c120bc5e889be7cb85c065a298111e2a7743d4af43c2299ad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1a40e56b96b4c1e3c7108aae6b21779020d84f2b86682b94eefe823c191680b7efd6ea866a370eacdbd67740f8872fd5e33d4eb90817ee94297cfc9383f6716f
|
7
|
+
data.tar.gz: 0f5a67ed0f517707ba738ee3b7d6369ddff23df25235e69110782dd6bc24d9c423cf30755fade6c283ed608e93a631b32670e23e269f9d5cf2c73c8e55f13952
|
data/.gitignore
CHANGED
data/lib/gitall.rb
CHANGED
@@ -218,7 +218,30 @@ module GitAll
|
|
218
218
|
end
|
219
219
|
|
220
220
|
elsif request.env.key?('HTTP_X_GOGS_EVENT')
|
221
|
-
|
221
|
+
if !j.repository.full_name.nil?
|
222
|
+
repo = j.repository.full_name
|
223
|
+
elsif !j.organization.login.nil?
|
224
|
+
repo = j.organization.login
|
225
|
+
else
|
226
|
+
end
|
227
|
+
# phash includes orgs and repos
|
228
|
+
phash = PROJECTS[repo.to_sym]
|
229
|
+
token = phash['token']
|
230
|
+
sent_token = request.env['HTTP_X_HUB_SIGNATURE']
|
231
|
+
signature = "sha1=#{OpenSSL::HMAC.hexdigest('sha1', token, payload.strip).chomp}"
|
232
|
+
resp = GitHubParser.parse json, request.env['HTTP_X_GITHUB_EVENT']
|
233
|
+
if signature.to_s == sent_token.to_s
|
234
|
+
channels = phash['channels'.to_sym]
|
235
|
+
channels.each {
|
236
|
+
|channet|
|
237
|
+
channel = channet.split(',')[0]
|
238
|
+
network = channet.split(',')[1]
|
239
|
+
resp.each {
|
240
|
+
|n|
|
241
|
+
GitAll::Bot::Bots.bots[network].Channel(channel).send("#{n}")
|
242
|
+
}
|
243
|
+
}
|
244
|
+
end
|
222
245
|
elsif request.env.key?('HTTP_X_EVENT_KEY')
|
223
246
|
# BitBucket's Webhooks
|
224
247
|
# Requires HTTPS and does not
|
@@ -0,0 +1,103 @@
|
|
1
|
+
# lib/gitlab.rb
|
2
|
+
# Ken Spencer <ken@electrocode.net>
|
3
|
+
#
|
4
|
+
# This module is part of GitAll and is released under the
|
5
|
+
# MIT license: http://opensource.org/licenses/MIT
|
6
|
+
|
7
|
+
# GitLab Event Parsing
|
8
|
+
class GogsParser
|
9
|
+
def GogsParser.parse(json)
|
10
|
+
j = RecursiveOpenStruct.new(json)
|
11
|
+
response = []
|
12
|
+
kind = j.object_kind
|
13
|
+
case kind
|
14
|
+
when 'note'
|
15
|
+
repo = j.project.path_with_namespace
|
16
|
+
ntype = j.object_attributes.noteable_type
|
17
|
+
case ntype
|
18
|
+
when 'MergeRequest'
|
19
|
+
mr_note = j.object_attributes.note
|
20
|
+
mr_url = j.object_attributes.url
|
21
|
+
mr_title = j.merge_request.title
|
22
|
+
mr_id = j.merge_request.iid
|
23
|
+
mr_user = j.user.name
|
24
|
+
response << "[#{repo}] #{mr_user} commented on Merge Request ##{mr_id} \u2014 #{mr_note}"
|
25
|
+
response << "'#{mr_title}' => #{mr_url}"
|
26
|
+
when 'Commit'
|
27
|
+
c_note = j.object_attributes.note
|
28
|
+
c_sha = j.commit.id[0...7]
|
29
|
+
c_url = j.object_attributes.url
|
30
|
+
c_user = j.user.name
|
31
|
+
response << "[#{repo}] #{c_user} commented on commit (#{c_sha}) \u2014 #{c_note} <#{c_url}>"
|
32
|
+
when 'Issue'
|
33
|
+
i_id = j.issue.iid
|
34
|
+
i_url = j.object_attributes.url
|
35
|
+
i_msg = j.object_attributes.note
|
36
|
+
i_title = j.issue.title
|
37
|
+
i_user = j.user.name
|
38
|
+
response << "[#{repo}] #{i_user} commented on Issue ##{i_id} (#{i_title}) \u2014 #{i_msg} <#{i_url}>"
|
39
|
+
else
|
40
|
+
# type code here
|
41
|
+
end
|
42
|
+
when 'issue'
|
43
|
+
i_repo = j.project.path_with_namespace
|
44
|
+
i_user = j.user.name
|
45
|
+
i_un = j.user.username
|
46
|
+
i_id = j.object_attributes.iid
|
47
|
+
i_title = j.object_attributes.title
|
48
|
+
i_action = j.object_attributes.action
|
49
|
+
i_url = j.object_attributes.url
|
50
|
+
response << "[#{i_repo}] #{i_user}(#{i_un}) #{i_action} issue ##{i_id} - #{i_title} <#{i_url}>"
|
51
|
+
when 'merge_request'
|
52
|
+
mr_name = j.user.name
|
53
|
+
mr_user = j.user.username
|
54
|
+
mr_url = j.url
|
55
|
+
mr_spath = j.object_attributes.source.path_with_namespace
|
56
|
+
mr_sbranch = j.object_attributes.source_branch
|
57
|
+
mr_tpath = j.object_attributes.target.path_with_namespace
|
58
|
+
mr_tbranch = j.object_attributes.target_branch
|
59
|
+
mr_lcmessage = j.object_attributes.last_commit.message
|
60
|
+
mr_lcsha = j.object_attributes.last_commit.id[0...7]
|
61
|
+
response << "#{mr_name}(#{mr_user}) opened a merge request. #{mr_spath}[#{mr_sbranch}] ~> #{mr_tpath}[#{mr_tbranch}]"
|
62
|
+
response << "[#{mr_lcsha}] \u2014 #{mr_lcmessage} <#{mr_url}>"
|
63
|
+
when 'push' # comes to
|
64
|
+
# shove
|
65
|
+
branch = j.ref.split('/')[-1]
|
66
|
+
commits = j.commits
|
67
|
+
added = 0
|
68
|
+
removed = 0
|
69
|
+
modified = 0
|
70
|
+
commits.each do |h|
|
71
|
+
added += h['added'].length
|
72
|
+
removed += h['removed'].length
|
73
|
+
modified += h['modified'].length
|
74
|
+
end
|
75
|
+
owner = j.project.namespace
|
76
|
+
project = j.project.name
|
77
|
+
pusher = j.user_name
|
78
|
+
commit_count = j.total_commits_count
|
79
|
+
repo_url = j.project.web_url
|
80
|
+
response << "[#{owner}/#{project}] #{pusher} pushed #{commit_count} commit(s) [+#{added}/-#{removed}/±#{modified}] to [#{branch}] at <#{repo_url}>"
|
81
|
+
if commits.length > 3
|
82
|
+
coms = commits[0..2]
|
83
|
+
coms.each do |n|
|
84
|
+
id = n['id']
|
85
|
+
msg = n['message'].lines[0]
|
86
|
+
author = n['author']['name']
|
87
|
+
response << "#{author} — #{msg.chomp!} [#{id[0...7]}]"
|
88
|
+
end
|
89
|
+
response << "and #{commits.from(3).length} commits..."
|
90
|
+
else
|
91
|
+
commits.each do |n|
|
92
|
+
id = n['id'][0...7]
|
93
|
+
msg = n['message'].lines[0]
|
94
|
+
author = n['author']['name']
|
95
|
+
response << "#{author} — #{msg.chomp!} [#{id}]"
|
96
|
+
end
|
97
|
+
end
|
98
|
+
else
|
99
|
+
# type code here
|
100
|
+
end
|
101
|
+
return response
|
102
|
+
end
|
103
|
+
end
|
data/lib/gitall/plugins/git.rb
CHANGED
@@ -15,12 +15,14 @@ class ChanControl
|
|
15
15
|
|
16
16
|
def getIssue(m, host, user, repo, issue)
|
17
17
|
case host
|
18
|
-
when 'gl'
|
18
|
+
when 'gl', 'gitlab'
|
19
19
|
m.reply("https://gitlab.com/#{user}/#{repo}/issues/#{issue}")
|
20
|
-
when 'gh'
|
20
|
+
when 'gh', 'github'
|
21
21
|
m.reply("https://github.com/#{user}/#{repo}/issue/#{issue}")
|
22
|
-
when 'bb'
|
22
|
+
when 'bb', 'bitbucket'
|
23
23
|
m.reply("https://bitbucket.org/#{user}/#{repo}/issue/#{issue}")
|
24
|
+
when 'gg', 'gogs'
|
25
|
+
m.reply('Gogs Issues are unsupported at this time.')
|
24
26
|
else
|
25
27
|
m.user.notice("I don't know that git-service host")
|
26
28
|
end
|
data/lib/gitall/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gitall
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ken Spencer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-06-
|
11
|
+
date: 2018-06-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cinch
|
@@ -296,6 +296,7 @@ files:
|
|
296
296
|
- lib/gitall/parsers/bitbucket.rb
|
297
297
|
- lib/gitall/parsers/github.rb
|
298
298
|
- lib/gitall/parsers/gitlab.rb
|
299
|
+
- lib/gitall/parsers/gogs.rb
|
299
300
|
- lib/gitall/plugins/admin.rb
|
300
301
|
- lib/gitall/plugins/chancontrol.rb
|
301
302
|
- lib/gitall/plugins/eval.rb
|