cyclid-gh-comment-plugin 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/cyclid/plugins/action/github_comment.rb +88 -0
- metadata +72 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: bf04d0a049d0c85fc66a8812791ff49dd02c66e8
|
4
|
+
data.tar.gz: b2a83c04d0b97d2eabd09bdf5c1792efd46d3775
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 72952ae2decd6ec410311ac562d43cbbbc48545a2909b4d1b491ce4a9728d50c2bf6baafdb44aac09c44ecd399bd12cd5d815bcba2938765f86ee959a2274ecb
|
7
|
+
data.tar.gz: 4daf7a123c4a9992cbc698b695d14ab9eeca5574ca82244b01d8e1f1ea4bcfc487e3f706f5895cbe35a5a14776aa99fd6ec85db8b7b783b0cc631559bb86f2de
|
@@ -0,0 +1,88 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright 2017 Liqwyd Ltd.
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
require 'octokit'
|
18
|
+
|
19
|
+
# Top level module for the core Cyclid code.
|
20
|
+
module Cyclid
|
21
|
+
# Module for the Cyclid API
|
22
|
+
module API
|
23
|
+
# Module for Cyclid Plugins
|
24
|
+
module Plugins
|
25
|
+
# Post a comment to a Github plugin (including Pull Requests)
|
26
|
+
class GithubComment < Action
|
27
|
+
Cyclid.logger.debug 'in the Github Comment plugin'
|
28
|
+
|
29
|
+
def initialize(args = {})
|
30
|
+
args.symbolize_keys!
|
31
|
+
|
32
|
+
# There must be a repository name.
|
33
|
+
raise 'a github comment action requires a repository' unless args.include? :repo
|
34
|
+
|
35
|
+
# There must be an issue number.
|
36
|
+
raise 'a github comment action requires an issue number' unless args.include? :number
|
37
|
+
|
38
|
+
@repo = args[:repo]
|
39
|
+
@number = args[:number].to_s
|
40
|
+
|
41
|
+
@comment = args[:comment] if args.include? :comment
|
42
|
+
@path = args[:path] if args.include? :path
|
43
|
+
|
44
|
+
# There must be either a comment or a file to read as a comment
|
45
|
+
raise 'a github comment action requires a comment or file' if @comment.nil? && @path.nil?
|
46
|
+
end
|
47
|
+
|
48
|
+
def perform(log)
|
49
|
+
# If a path was given, read the file and use it as the comment
|
50
|
+
if @path
|
51
|
+
content = StringIO.new
|
52
|
+
@transport.download(content, @path**@ctx)
|
53
|
+
@comment = content.string
|
54
|
+
end
|
55
|
+
|
56
|
+
# Insert context
|
57
|
+
repo = @repo**@ctx
|
58
|
+
number = @number**@ctx
|
59
|
+
comment = @comment**@ctx
|
60
|
+
|
61
|
+
# Append the comment
|
62
|
+
client = Octokit::Client.new(access_token: oauth_token)
|
63
|
+
client.add_comment(repo, number, comment)
|
64
|
+
|
65
|
+
[true, 0]
|
66
|
+
rescue StandardError => ex
|
67
|
+
log.write "Failed to add Github comment to #{repo} ##{number}: #{ex}"
|
68
|
+
[false, 0]
|
69
|
+
end
|
70
|
+
|
71
|
+
# Register this plugin
|
72
|
+
register_plugin 'github_comment'
|
73
|
+
|
74
|
+
private
|
75
|
+
|
76
|
+
def config
|
77
|
+
# Retrieve the configuration
|
78
|
+
plugin_config = Cyclid::API::Plugins::Github.get_config(@ctx[:organization])
|
79
|
+
plugin_config['config']
|
80
|
+
end
|
81
|
+
|
82
|
+
def oauth_token
|
83
|
+
@token ||= config['oauth_token']
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
metadata
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cyclid-gh-comment-plugin
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Kristian Van Der Vliet
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-06-24 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: cyclid
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.3'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: octokit
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '4.3'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '4.3'
|
41
|
+
description: Add comments to Github issues & pull requests
|
42
|
+
email: contact@cyclid.io
|
43
|
+
executables: []
|
44
|
+
extensions: []
|
45
|
+
extra_rdoc_files: []
|
46
|
+
files:
|
47
|
+
- lib/cyclid/plugins/action/github_comment.rb
|
48
|
+
homepage: https://cyclid.io
|
49
|
+
licenses:
|
50
|
+
- Apache-2.0
|
51
|
+
metadata: {}
|
52
|
+
post_install_message:
|
53
|
+
rdoc_options: []
|
54
|
+
require_paths:
|
55
|
+
- lib
|
56
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
62
|
+
requirements:
|
63
|
+
- - ">="
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
requirements: []
|
67
|
+
rubyforge_project:
|
68
|
+
rubygems_version: 2.5.1
|
69
|
+
signing_key:
|
70
|
+
specification_version: 4
|
71
|
+
summary: Cyclid Github Comment plugin
|
72
|
+
test_files: []
|