Skip to content

Commit de6ef19

Browse files
Merge branch 'main' into feat/service-accounts
2 parents 4b1d3d5 + 09905de commit de6ef19

File tree

15 files changed

+56
-60
lines changed

15 files changed

+56
-60
lines changed

github_hooks/.rubocop.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
inherit_from: .rubocop_todo.yml
22

3-
require:
3+
plugins:
44
- rubocop-rails
55
- rubocop-factory_bot
66
- rubocop-rspec

github_hooks/.rubocop_todo.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,12 @@ RSpec/ExpectInHook:
540540
# Offense count: 2
541541
# Configuration parameters: Include, CustomTransform, IgnoreMethods, SpecSuffixOnly.
542542
# Include: **/*_spec*rb*, **/spec/**/*
543-
RSpec/FilePath:
543+
RSpec/SpecFilePathFormat:
544+
Exclude:
545+
- 'spec/lib/repo_host/repository/hook_spec.rb'
546+
- 'spec/lib/repo_host/repository_spec.rb'
547+
548+
RSpec/SpecFilePathSuffix:
544549
Exclude:
545550
- 'spec/lib/repo_host/repository/hook_spec.rb'
546551
- 'spec/lib/repo_host/repository_spec.rb'

github_hooks/app/controllers/pages_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
class PagesController < ApplicationController
22

3-
def is_alive # rubocop:disable Naming/PredicateName
3+
def alive?
44
render :plain => "yes"
55
end
66

github_hooks/app/models/branch.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class Branch < ActiveRecord::Base
1616
def self.find_or_create_for_workflow(workflow)
1717
branch = workflow.project.branches.find_or_create_by(:name => workflow.payload.branch)
1818

19-
if workflow.payload.is_pull_request?
19+
if workflow.payload.pull_request?
2020
options = {
2121
:pull_request_number => workflow.payload.pull_request_number,
2222
:pull_request_name => workflow.payload.pull_request_name,

github_hooks/config/environments/production.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
config.log_level = ENV.fetch("LOG_LEVEL", "info")
5656

5757
config.lograge.enabled = true
58-
config.lograge.ignore_actions = ["PagesController#is_alive"]
58+
config.lograge.ignore_actions = ["PagesController#alive?"]
5959

6060
config.lograge.custom_options = lambda do |event|
6161
{ :time => event.time }

github_hooks/config/routes.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
post "/github" => "projects#repo_host_post_commit_hook"
33

44
# liveness and readiness probe
5-
get "/is_alive" => "pages#is_alive"
5+
get "/is_alive" => "pages#alive?"
66
end

github_hooks/lib/internal_api/repo_proxy/repo_proxy_server.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def create_for_github_project(req, logger)
152152
end
153153

154154
label =
155-
if workflow.payload.is_pull_request?
155+
if workflow.payload.pull_request?
156156
workflow.pull_request_number.to_s
157157
elsif workflow.payload.tag_created?
158158
workflow.payload.tag_name
@@ -309,15 +309,15 @@ def pr_mergeable(hook)
309309
end
310310

311311
def branch_name(hook)
312-
if hook.payload.is_pull_request?
312+
if hook.payload.pull_request?
313313
hook.payload.pr_base_branch_name.to_s
314314
else
315315
hook.branch_name.to_s
316316
end
317317
end
318318

319319
def type(hook)
320-
if hook.payload.is_pull_request?
320+
if hook.payload.pull_request?
321321
InternalApi::RepoProxy::Hook::Type::PR
322322
elsif hook.payload.tag?
323323
InternalApi::RepoProxy::Hook::Type::TAG

github_hooks/lib/presenter_base.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@ def routes
1818

1919
alias_method :r, :routes
2020

21-
def helpers
22-
ApplicationController.helpers
23-
end
21+
delegate :helpers, to: ApplicationController
2422

2523
alias_method :h, :helpers
2624

github_hooks/lib/repo_host/bitbucket/payload.rb

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def issue_number
5555

5656
# ❌
5757
def branch_created?
58-
if is_pull_request?
58+
if pull_request?
5959
pull_request_opened?
6060
else
6161
@data["created"] && @data["ref"].starts_with?("refs/heads/")
@@ -69,7 +69,7 @@ def tag_created?
6969

7070
# ✔️
7171
def branch_deleted?
72-
if is_pull_request?
72+
if pull_request?
7373
pull_request_closed?
7474
else
7575
first_push_change["closed"]
@@ -83,7 +83,7 @@ def force_pushed?
8383

8484
# ✔️
8585
def includes_ci_skip?
86-
return false if is_pull_request? || head_commit_message.nil?
86+
return false if pull_request? || head_commit_message.nil?
8787

8888
::Semaphore::SkipCi.new.call(head_commit_message)
8989
end
@@ -136,7 +136,7 @@ def author_avatar_url
136136
end
137137

138138
# ✔️
139-
def is_pull_request? # rubocop:disable Naming/PredicateName
139+
def pull_request?
140140
@data["pullrequest"].present?
141141
end
142142

@@ -145,12 +145,10 @@ def repo_url
145145
@data.dig("repository", "links", "html", "href")
146146
end
147147

148-
def is_draft_pull_request? # rubocop:disable Naming/PredicateName
148+
def draft_pull_request?
149149
false
150150
end
151151

152-
alias_method :pull_request?, :is_pull_request?
153-
154152
# ❌
155153
def pull_request_within_repo?
156154
return false unless pull_request?
@@ -316,13 +314,13 @@ def single?
316314
end
317315

318316
def extract_action
319-
if is_pull_request?
317+
if pull_request?
320318
"undefined"
321319
end
322320
end
323321

324322
def extract_branch
325-
if is_pull_request?
323+
if pull_request?
326324
pull_request_branch_name
327325
elsif pr_comment?
328326
"pull-request-#{issue_number}"
@@ -338,7 +336,7 @@ def extract_branch
338336

339337
# ✔️
340338
def extract_commits
341-
unless is_pull_request?
339+
unless pull_request?
342340
extract_commits_from_push
343341
end
344342
end
@@ -355,7 +353,7 @@ def extract_commits_from_push
355353
end
356354

357355
def extract_head
358-
if is_pull_request?
356+
if pull_request?
359357
pr_head_sha
360358
elsif @data["head_commit"]
361359
# If head commit exists, use that one to extract the commit.
@@ -372,7 +370,7 @@ def extract_head
372370
end
373371

374372
def extract_prev_head
375-
if is_pull_request?
373+
if pull_request?
376374
"0000000000000000000000000000000000000000"
377375
else
378376
first_push_change.dig("old", "target", "hash")

github_hooks/lib/repo_host/git/payload.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def pull_request?
1515
end
1616
alias is_pull_request? pull_request?
1717

18-
def is_draft_pull_request? # rubocop:disable Naming/PredicateName
18+
def draft_pull_request?
1919
false
2020
end
2121

0 commit comments

Comments
 (0)