Skip to content
Permalink
Browse files

Sync assignees

  • Loading branch information...
arfon committed May 6, 2019
1 parent ad4280f commit 4bedc9f64c1c72f73343f9b6365a480b020b4b47
Showing with 26 additions and 7 deletions.
  1. +1 −1 Gemfile
  2. +6 −6 Gemfile.lock
  3. +19 −0 lib/tasks/sync.rake
@@ -13,7 +13,7 @@ gem 'html-pipeline', '~> 2.7.1'
gem 'commonmarker', '~> 0.17.7'
gem 'octicons_helper', '~> 4.0'
gem 'omniauth-orcid', '~> 2.0.2'
gem 'octokit', '~> 4.3.0'
gem 'octokit', '~> 4.14'
gem 'pg', '~> 0.21.0'
gem 'will_paginate', '~> 3.1.6'
gem 'rails', '5.2.2.1'
@@ -170,8 +170,8 @@ GEM
octicons_helper (4.3.0)
octicons (= 5.3.0)
rails
octokit (4.3.0)
sawyer (~> 0.7.0, >= 0.5.3)
octokit (4.14.0)
sawyer (~> 0.8.0, >= 0.5.3)
omniauth (1.9.0)
hashie (>= 3.4.6, < 3.7.0)
rack (>= 1.6.2, < 3)
@@ -267,9 +267,9 @@ GEM
sprockets (>= 2.8, < 4.0)
sprockets-rails (>= 2.0, < 4.0)
tilt (>= 1.1, < 3)
sawyer (0.7.0)
addressable (>= 2.3.5, < 2.5)
faraday (~> 0.8, < 0.10)
sawyer (0.8.1)
addressable (>= 2.3.5, < 2.6)
faraday (~> 0.8, < 1.0)
signet (0.11.0)
addressable (~> 2.3)
faraday (~> 0.9)
@@ -335,7 +335,7 @@ DEPENDENCIES
jquery-rails (~> 4.3.1)
newrelic_rpm (~> 4.6.0)
octicons_helper (~> 4.0)
octokit (~> 4.3.0)
octokit (~> 4.14)
omniauth-orcid (~> 2.0.2)
pg (~> 0.21.0)
pry-byebug
@@ -0,0 +1,19 @@
namespace :sync do
desc "Restrict permissions on reviews repository to those that need it"
task :assignees => :environment do
# We run this task daily on Heroku
reviews_repo = Rails.application.settings["reviews"]
open_issues = GITHUB.list_issues(reviews_repo, :state => 'open')

open_issues.each do |issue|
editor = issue.body.match(/\*\*Editor:\*\*\s*(@\S*|Pending)/i)[1]
reviewers = issue.body.match(/Reviewers?:\*\*\s*(.+?)\r?\n/)[1].split(", ") - ["Pending"]
assignees = reviewers << editor unless editor == "Pending"

if assignees
assignees = assignees.collect {|a| a.sub!(/^@/, '')}
GITHUB.add_assignees(reviews_repo, issue.number, assignees)
end
end
end
end

0 comments on commit 4bedc9f

Please sign in to comment.
You can’t perform that action at this time.