errbit-ng-github-plugin 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: f7bbdc6db9882c0e802e1f26afb96f156180da41b1a2ea2e9c809a41b117ee74
4
+ data.tar.gz: b6d4cb800782e7409f723acf284f8b975b6fa47c496d99b3a0853155de0840d6
5
+ SHA512:
6
+ metadata.gz: 37c64da4da97c1295662b653ef2cf49c53c2180647b995b5a77d172632d1ba9c73332296b46bb317d44a99a6681a3c8e87e312445286db207b8294f2c0c3e24f
7
+ data.tar.gz: c6fb8f65be8c3a3ca9a059b01c478efb07cad42c01749e9b125846e8deeaa49c39b6a29952b221985fce2f5c5e59ca58759353abb586817802c530b32a0b81a0
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.1.6
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ # Changelog
2
+
3
+ ## main
4
+
5
+ * Rename to `errbit-ng-github-plugin`
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2013 Cyril Mougel
4
+ Copyright (c) 2025 Errbit-NG Team
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in
14
+ all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,12 @@
1
+ # Errbit-NG GitHub Plugin
2
+
3
+ This plugin provides GitHub issue tracker integration for Errbit-NG, and it is the
4
+ only one plugin included by default in Errbit-NG.
5
+
6
+ ## Contributing
7
+
8
+ Bug reports and pull requests are welcome on GitHub at https://github.com/errbit-ng/errbit-ng-github-plugin.
9
+
10
+ ## License
11
+
12
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "errbit_github_plugin"
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ErrbitGithubPlugin
4
+ class AuthenticationError < Exception; end
5
+ end
@@ -0,0 +1,109 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "octokit"
4
+
5
+ module ErrbitGithubPlugin
6
+ class IssueTracker < ErrbitPlugin::IssueTracker
7
+ LABEL = "github"
8
+
9
+ NOTE = "Please configure your github repository in the <strong>GITHUB " \
10
+ "REPO</strong> field above.<br/> Instead of providing your " \
11
+ "username & password, you can link your Github account to your " \
12
+ "user profile, and allow Errbit to create issues using your " \
13
+ "OAuth token."
14
+
15
+ FIELDS = {
16
+ username: {
17
+ placeholder: "Your username on GitHub"
18
+ },
19
+ password: {
20
+ placeholder: "Password for your account"
21
+ }
22
+ }
23
+
24
+ def self.label
25
+ LABEL
26
+ end
27
+
28
+ def self.note
29
+ NOTE
30
+ end
31
+
32
+ def self.fields
33
+ FIELDS
34
+ end
35
+
36
+ def self.icons
37
+ @icons ||= {
38
+ create: [
39
+ "image/png", ErrbitGithubPlugin.read_static_file("github_create.png")
40
+ ],
41
+ goto: [
42
+ "image/png", ErrbitGithubPlugin.read_static_file("github_goto.png")
43
+ ],
44
+ inactive: [
45
+ "image/png", ErrbitGithubPlugin.read_static_file("github_inactive.png")
46
+ ]
47
+ }
48
+ end
49
+
50
+ def configured?
51
+ errors.empty?
52
+ end
53
+
54
+ def url
55
+ "https://github.com/#{repo}/issues"
56
+ end
57
+
58
+ def errors
59
+ errors = []
60
+ if self.class.fields.detect { |f| options[f[0]].blank? }
61
+ errors << [:base, "You must specify your GitHub username and password"]
62
+ end
63
+ if repo.blank?
64
+ errors << [:base, "You must specify your GitHub repository url."]
65
+ end
66
+ errors
67
+ end
68
+
69
+ def repo
70
+ options[:github_repo]
71
+ end
72
+
73
+ def create_issue(title, body, user: {})
74
+ github_client = if user["github_login"] && user["github_oauth_token"]
75
+ Octokit::Client.new(
76
+ login: user["github_login"], access_token: user["github_oauth_token"]
77
+ )
78
+ else
79
+ Octokit::Client.new(
80
+ login: options["username"], password: options["password"]
81
+ )
82
+ end
83
+ issue = github_client.create_issue(repo, title, body)
84
+ issue.html_url
85
+ rescue Octokit::Unauthorized
86
+ raise ErrbitGithubPlugin::AuthenticationError, "Could not authenticate with GitHub. Please check your username and password."
87
+ end
88
+
89
+ def close_issue(url, user: {})
90
+ github_client = if user["github_login"] && user["github_oauth_token"]
91
+ Octokit::Client.new(
92
+ login: user["github_login"], access_token: user["github_oauth_token"]
93
+ )
94
+ else
95
+ Octokit::Client.new(
96
+ login: options["username"], password: options["password"]
97
+ )
98
+ end
99
+ # It would be better to get the number from issue.number when we create the issue,
100
+ # however, since we only have the url, get the number from it.
101
+ # ex: "https://github.com/octocat/Hello-World/issues/1347"
102
+ issue_number = url.split("/").last
103
+ issue = github_client.close_issue(repo, issue_number)
104
+ issue.html_url
105
+ rescue Octokit::Unauthorized
106
+ raise ErrbitGithubPlugin::AuthenticationError, "Could not authenticate with GitHub. Please check your username and password."
107
+ end
108
+ end
109
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ErrbitGithubPlugin
4
+ VERSION = "0.1.0"
5
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "errbit_github_plugin/version"
4
+ require "errbit_github_plugin/error"
5
+ require "errbit_github_plugin/issue_tracker"
6
+
7
+ module ErrbitGithubPlugin
8
+ def self.root
9
+ File.expand_path "../..", __FILE__
10
+ end
11
+
12
+ def self.read_static_file(file)
13
+ File.read(File.join(root, "static", file))
14
+ end
15
+ end
16
+
17
+ ErrbitPlugin::Registry.add_issue_tracker(ErrbitGithubPlugin::IssueTracker)
Binary file
Binary file
Binary file
metadata ADDED
@@ -0,0 +1,104 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: errbit-ng-github-plugin
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Ihor Zubkov
8
+ bindir: exe
9
+ cert_chain: []
10
+ date: 2025-01-31 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: errbit-ng-plugin
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: '0'
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - ">="
24
+ - !ruby/object:Gem::Version
25
+ version: '0'
26
+ - !ruby/object:Gem::Dependency
27
+ name: octokit
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ - !ruby/object:Gem::Dependency
41
+ name: activesupport
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ type: :development
48
+ prerelease: false
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ description: GitHub integration for Errbit-NG
55
+ email:
56
+ - igor.zubkov@gmail.com
57
+ executables: []
58
+ extensions: []
59
+ extra_rdoc_files: []
60
+ files:
61
+ - ".rspec"
62
+ - ".ruby-version"
63
+ - CHANGELOG.md
64
+ - LICENSE.txt
65
+ - README.md
66
+ - Rakefile
67
+ - lib/errbit-ng-github-plugin.rb
68
+ - lib/errbit_github_plugin.rb
69
+ - lib/errbit_github_plugin/error.rb
70
+ - lib/errbit_github_plugin/issue_tracker.rb
71
+ - lib/errbit_github_plugin/version.rb
72
+ - static/github_create.png
73
+ - static/github_goto.png
74
+ - static/github_inactive.png
75
+ - vendor/assets/images/github_create.png
76
+ - vendor/assets/images/github_inactive.png
77
+ homepage: https://github.com/errbit-ng/errbit-ng-github-plugin
78
+ licenses:
79
+ - MIT
80
+ metadata:
81
+ rubygems_mfa_required: 'true'
82
+ bug_tracker_uri: https://github.com/errbit-ng/errbit-ng-github-plugin/issues
83
+ changelog_uri: https://github.com/errbit-ng/errbit-ng-github-plugin/blob/main/CHANGELOG.md
84
+ documentation_uri: https://github.com/errbit-ng/errbit-ng-github-plugin/blob/main/README.md
85
+ homepage_uri: https://github.com/errbit-ng/errbit-ng-github-plugin
86
+ source_code_uri: https://github.com/errbit-ng/errbit-ng-github-plugin
87
+ rdoc_options: []
88
+ require_paths:
89
+ - lib
90
+ required_ruby_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: 3.1.0
95
+ required_rubygems_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ requirements: []
101
+ rubygems_version: 3.6.3
102
+ specification_version: 4
103
+ summary: GitHub integration for Errbit-NG
104
+ test_files: []