gitall 1.1.14 → 1.1.15

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2125bfb18847ddc7a66a079a485b498edae5cb755feebc821955ef03c0f02da3
4
- data.tar.gz: f1f8b823f7d332f80d59838e8cc68445dbc0e0edb9045e1050137b20bcd0991e
3
+ metadata.gz: f4fcb2bd7529f17844eda9c2cd6258e5085b8aab55a127e24a146a2f67057dc7
4
+ data.tar.gz: f53265464f613a0c120bc5e889be7cb85c065a298111e2a7743d4af43c2299ad
5
5
  SHA512:
6
- metadata.gz: b0ee568d332eb358c248af960ba1cbedad5cbf6a23ebc53ab36aa960995fc3b155e2c990d79a460eafb62f47d0b06e0a9cbee7eaea27ac48c58c1ee5903b0f60
7
- data.tar.gz: e4ba4a8c042f40cfe490e763ad6019bd199b503f80238a42dad791c33e8a3a86f954cb862daeab789c8345c4bde3b913a908a809a64ff294d0ea19a1ee73fdf3
6
+ metadata.gz: 1a40e56b96b4c1e3c7108aae6b21779020d84f2b86682b94eefe823c191680b7efd6ea866a370eacdbd67740f8872fd5e33d4eb90817ee94297cfc9383f6716f
7
+ data.tar.gz: 0f5a67ed0f517707ba738ee3b7d6369ddff23df25235e69110782dd6bc24d9c423cf30755fade6c283ed608e93a631b32670e23e269f9d5cf2c73c8e55f13952
data/.gitignore CHANGED
@@ -6,4 +6,6 @@ log/
6
6
  doc/
7
7
  vendor/
8
8
  .bundle
9
- Gemfile.lock
9
+ Gemfile.lock
10
+ /.project
11
+ /gitall-*.gem
@@ -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
@@ -1,3 +1,4 @@
1
+
1
2
  # lib/github.rb
2
3
  # Ken Spencer <ken@electrocode.net>
3
4
  #
@@ -92,6 +92,7 @@ class GitLabParser
92
92
  id = n['id'][0...7]
93
93
  msg = n['message'].lines[0]
94
94
  author = n['author']['name']
95
+ puts msg
95
96
  response << "#{author} — #{msg.chomp!} [#{id}]"
96
97
  end
97
98
  end
@@ -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
@@ -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
@@ -1,3 +1,3 @@
1
1
  module GitAll
2
- VERSION = '1.1.14'
2
+ VERSION = '1.1.15'
3
3
  end
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.14
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-22 00:00:00.000000000 Z
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