You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@skywalking.apache.org by wu...@apache.org on 2022/06/04 02:04:58 UTC
[skywalking-eyes] branch main updated: Lazy initialize GitHub client for comment (#111)
This is an automated email from the ASF dual-hosted git repository.
wusheng pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-eyes.git
The following commit(s) were added to refs/heads/main by this push:
new 5f15d23 Lazy initialize GitHub client for comment (#111)
5f15d23 is described below
commit 5f15d230a1914858ebccba7664026ffc7288b670
Author: kezhenxu94 <ke...@apache.org>
AuthorDate: Sat Jun 4 10:04:53 2022 +0800
Lazy initialize GitHub client for comment (#111)
---
pkg/review/header.go | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/pkg/review/header.go b/pkg/review/header.go
index bc00800..139c51e 100644
--- a/pkg/review/header.go
+++ b/pkg/review/header.go
@@ -26,6 +26,7 @@ import (
"regexp"
"strconv"
"strings"
+ "sync"
"github.com/google/go-github/v33/github"
"golang.org/x/oauth2"
@@ -54,9 +55,11 @@ var (
"GITHUB_EVENT_NAME",
"GITHUB_EVENT_PATH",
}
+
+ ghOnce sync.Once
)
-func init() {
+func Init() {
if os.Getenv("GITHUB_TOKEN") == "" {
logger.Log.Infoln("GITHUB_TOKEN is not set, license-eye won't comment on the pull request")
return
@@ -107,6 +110,8 @@ func init() {
// Header reviews the license header, including suggestions on the pull request and an overview of the checks.
func Header(result *header2.Result, config *config2.Config) error {
+ ghOnce.Do(Init)
+
if !result.HasFailure() || !IsPR() || gh == nil || config.Header.Comment == header2.Never {
return nil
}