Module: Fastlane::GitHubNotifier
- Defined in:
- lib/fastlane/plugin/firebase_test_lab_android/helper/github_notifier.rb
Class Method Summary collapse
- .delete_comment(github_owner, github_repository, comment_id, github_api_token) ⇒ Object
- .delete_comments(github_owner, github_repository, github_pr_number, comment_prefix, github_api_token) ⇒ Object
- .fold_comments(github_owner, github_repository, github_pr_number, comment_prefix, summary, github_api_token) ⇒ Object
- .get_comments(github_owner, github_repository, github_pr_number, github_api_token) ⇒ Object
- .patch_comment(github_owner, github_repository, comment_id, body, github_api_token) ⇒ Object
- .put_comment(github_owner, github_repository, github_pr_number, body, github_api_token) ⇒ Object
Class Method Details
.delete_comment(github_owner, github_repository, comment_id, github_api_token) ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/fastlane/plugin/firebase_test_lab_android/helper/github_notifier.rb', line 72 def self.delete_comment(github_owner, github_repository, comment_id, github_api_token) api_url = "https://api.github.com/repos/#{github_owner}/#{github_repository}/issues/comments/#{comment_id}" UI. "delete comment #{api_url}" uri = URI.parse(api_url) req = Net::HTTP::Delete.new(uri) req["Content-Type"] = "application/json" req["Authorization"] = "token #{github_api_token}" res = Net::HTTP.start(uri.hostname, uri.port, {use_ssl: uri.scheme = "https"}) {|http| http.request(req)} UI. "#{res.code}\n#{res.body}" res end |
.delete_comments(github_owner, github_repository, github_pr_number, comment_prefix, github_api_token) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/fastlane/plugin/firebase_test_lab_android/helper/github_notifier.rb', line 18 def self.delete_comments(github_owner, github_repository, github_pr_number, comment_prefix, github_api_token) res = get_comments(github_owner, github_repository, github_pr_number, github_api_token) JSON.parse(res.body) .select {|comment| comment["body"].start_with?(comment_prefix)} .each {|comment| delete_comment(github_owner, github_repository, comment["id"], github_api_token)} end |
.fold_comments(github_owner, github_repository, github_pr_number, comment_prefix, summary, github_api_token) ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'lib/fastlane/plugin/firebase_test_lab_android/helper/github_notifier.rb', line 8 def self.fold_comments(github_owner, github_repository, github_pr_number, comment_prefix, summary, github_api_token) res = get_comments(github_owner, github_repository, github_pr_number, github_api_token) JSON.parse(res.body) .select {|comment| comment["body"].start_with?(comment_prefix)} .each {|comment| body = "<details><summary>#{summary}</summary>\n\n#{comment["body"]}\n\n</details>\n" patch_comment(github_owner, github_repository, comment["id"], body, github_api_token) } end |
.get_comments(github_owner, github_repository, github_pr_number, github_api_token) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/fastlane/plugin/firebase_test_lab_android/helper/github_notifier.rb', line 25 def self.get_comments(github_owner, github_repository, github_pr_number, github_api_token) api_url = "https://api.github.com/repos/#{github_owner}/#{github_repository}/issues/#{github_pr_number}/comments" UI. "get comments #{api_url}" uri = URI.parse(api_url) req = Net::HTTP::Get.new(uri) req["Content-Type"] = "application/json" req["Authorization"] = "token #{github_api_token}" res = Net::HTTP.start(uri.hostname, uri.port, {use_ssl: uri.scheme = "https"}) {|http| http.request(req)} UI. "#{res.code}\n#{res.body}" res end |
.patch_comment(github_owner, github_repository, comment_id, body, github_api_token) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/fastlane/plugin/firebase_test_lab_android/helper/github_notifier.rb', line 56 def self.patch_comment(github_owner, github_repository, comment_id, body, github_api_token) api_url = "https://api.github.com/repos/#{github_owner}/#{github_repository}/issues/comments/#{comment_id}" UI. "patch comment #{api_url}" uri = URI.parse(api_url) req = Net::HTTP::Patch.new(uri) req["Content-Type"] = "application/json" req["Authorization"] = "token #{github_api_token}" req.body = {:body => body}.to_json res = Net::HTTP.start(uri.hostname, uri.port, {use_ssl: uri.scheme = "https"}) {|http| http.request(req)} UI. "#{res.code}\n#{res.body}" res end |
.put_comment(github_owner, github_repository, github_pr_number, body, github_api_token) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/fastlane/plugin/firebase_test_lab_android/helper/github_notifier.rb', line 40 def self.put_comment(github_owner, github_repository, github_pr_number, body, github_api_token) api_url = "https://api.github.com/repos/#{github_owner}/#{github_repository}/issues/#{github_pr_number}/comments" UI. "put comment #{api_url}" uri = URI.parse(api_url) req = Net::HTTP::Post.new(uri) req["Content-Type"] = "application/json" req["Authorization"] = "token #{github_api_token}" req.body = {:body => body}.to_json res = Net::HTTP.start(uri.hostname, uri.port, {use_ssl: uri.scheme = "https"}) {|http| http.request(req)} UI. "#{res.code}\n#{res.body}" res end |