From 1e4774af4db2a4b51665f094cc9d9e75ffa53521 Mon Sep 17 00:00:00 2001 From: Brad Rydzewski Date: Mon, 29 Jul 2019 19:18:25 -0700 Subject: [PATCH] disable commit status API for cron jobs --- CHANGELOG.md | 5 +++++ service/status/status.go | 2 +- service/status/status_test.go | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c726d856..0fba17be 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## Unreleased +### Added + +- disable github status for cron jobs + ## [1.2.2] - 2019-07-29 ### Added diff --git a/service/status/status.go b/service/status/status.go index 215fcb49..64c15a33 100644 --- a/service/status/status.go +++ b/service/status/status.go @@ -49,7 +49,7 @@ type service struct { } func (s *service) Send(ctx context.Context, user *core.User, req *core.StatusInput) error { - if s.disabled { + if s.disabled || req.Build.Trigger == core.TriggerCron { return nil } diff --git a/service/status/status_test.go b/service/status/status_test.go index e57a0c1c..89d68551 100644 --- a/service/status/status_test.go +++ b/service/status/status_test.go @@ -102,7 +102,7 @@ func TestStatus_RenewalError(t *testing.T) { mockRenewer.EXPECT().Renew(gomock.Any(), mockUser, false).Return(scm.ErrNotAuthorized) service := New(nil, mockRenewer, Config{Base: "https://drone.company.com"}) - err := service.Send(noContext, mockUser, nil) + err := service.Send(noContext, mockUser, &core.StatusInput{Build: &core.Build{}}) if err == nil { t.Errorf("Expect error refreshing token") }