You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@skywalking.apache.org by ke...@apache.org on 2021/02/27 13:56:46 UTC

[skywalking-eyes] 01/01: defect: avoid crash when no comment style is found

This is an automated email from the ASF dual-hosted git repository.

kezhenxu94 pushed a commit to branch defect/review-comment-style
in repository https://gitbox.apache.org/repos/asf/skywalking-eyes.git

commit f9004170524ba80f605e010e6c64575ed1586a34
Author: kezhenxu94 <ke...@apache.org>
AuthorDate: Sat Feb 27 21:56:33 2021 +0800

    defect: avoid crash when no comment style is found
---
 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 8b96e26..b9cae79 100644
--- a/pkg/review/header.go
+++ b/pkg/review/header.go
@@ -144,7 +144,12 @@ func Header(result *header2.Result, config *config2.Config) error {
 				logger.Log.Warnln("Failed to get blob:", changedFile.GetFilename(), changedFile.GetSHA())
 				continue
 			}
-			header, err := header2.GenerateLicenseHeader(comments2.FileCommentStyle(changedFile.GetFilename()), &config.Header)
+			style := comments2.FileCommentStyle(changedFile.GetFilename())
+			if style == nil {
+				logger.Log.Warnln("Failed to determine the comment style of file:", changedFile.GetFilename())
+				continue
+			}
+			header, err := header2.GenerateLicenseHeader(style, &config.Header)
 			if err != nil {
 				logger.Log.Warnln("Failed to generate comment header:", changedFile.GetFilename())
 				continue