Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ RSpec:
Layout/ClassStructure:
Enabled: true

Layout/LineLength:
Max: 100

Metrics:
Enabled: true

Expand All @@ -41,9 +44,6 @@ Metrics/BlockLength:
- 'spec/**/*.rb'
- 'Guardfile'

Metrics/LineLength:
Max: 100

Performance/CaseWhenSplat:
Enabled: true

Expand Down
7 changes: 3 additions & 4 deletions app/controllers/edit_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -164,16 +164,15 @@ def update_branch(repo, name, sha)
end

def open_pr(head, base, title, description)
pr = github.create_pull_request(
original_repo_path, base, head, title, description,
labels: ["groupthink::proposal"]
)
pr = github.create_pull_request(original_repo_path, base, head, title, description)
Proposal.find_or_create_by!(
number: pr.number,
opened_at: Time.zone.now,
title: title,
proposer: @current_user
)
# Set PR label directly using admin as other users might not be able to
Octokit.add_issue_labels(original_repo_path, pr.number, [PROPOSAL_LABEL])
end

def commit_file(repo, name, content, message, base_sha, branch_name)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/ideas_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#
class IdeasController < ApplicationController
def index
@ideas = Octokit.issues(ENV.fetch("GITHUB_REPO"), labels: "groupthink::idea")
@ideas = Octokit.issues(ENV.fetch("GITHUB_REPO"), labels: IDEA_LABEL)
end

def show
Expand Down
2 changes: 1 addition & 1 deletion app/views/ideas/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class='pull-right'>
<a href='https://github.com/<%= ENV.fetch("GITHUB_REPO") %>/issues/new?labels=groupthink::idea' class='btn btn-primary' style='margin: 25px 0px'>
<a href='https://github.com/<%= ENV.fetch("GITHUB_REPO") %>/issues/new?labels=<%= IDEA_LABEL %>' class='btn btn-primary' style='margin: 25px 0px'>
<%= fa_icon 'plus' %>
Suggest a new idea
</a>
Expand Down
7 changes: 5 additions & 2 deletions config/initializers/octokit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ def create_label_if_missing(label:, colour:, description:)
Octokit.add_label(ENV.fetch("GITHUB_REPO"), label, colour, description: description)
end

IDEA_LABEL = "groupthink::idea"
PROPOSAL_LABEL = "groupthink::proposal"

unless Rails.env.test?
# Configure GitHub webhook automatically
begin
Expand Down Expand Up @@ -44,6 +47,6 @@ def create_label_if_missing(label:, colour:, description:)
}
Octokit.edit_repository(ENV.fetch("GITHUB_REPO"), repo_options)
# Set up labels
create_label_if_missing(label: "groupthink::proposal", colour: "d4c5f9", description: "Proposals to be voted on in Groupthink")
create_label_if_missing(label: "groupthink::idea", colour: "fbca04", description: "Ideas for future proposals")
create_label_if_missing(label: PROPOSAL_LABEL, colour: "d4c5f9", description: "Proposals to be voted on in Groupthink")
create_label_if_missing(label: IDEA_LABEL, colour: "fbca04", description: "Ideas for future proposals")
end