Browse Source

为GitHub Actions添加fetch-depth配置并增强调试日志

在.go-tag-release.yml中为所有checkout步骤添加了fetch-depth: 0配置以获取完整Git历史记录,同时在gitutils和git_data.go中增加了多处调试日志输出,便于排查标签生成相关问题,并移除了冗余的空行。
SongZihuan 5 days ago
parent
commit
d13a8604b4

+ 8 - 0
.github/workflows/go-tag-release.yml

@@ -24,6 +24,8 @@ jobs:
     steps:
       - name: Checkout code
         uses: actions/checkout@v4
+        with:
+          fetch-depth: 0
 
       - name: Set up Go
         uses: actions/setup-go@v5
@@ -44,6 +46,8 @@ jobs:
     steps:
       - name: Checkout code
         uses: actions/checkout@v4
+        with:
+          fetch-depth: 0
 
       - name: Set up Go
         uses: actions/setup-go@v5
@@ -76,6 +80,8 @@ jobs:
     steps:
       - name: Checkout code
         uses: actions/checkout@v4
+        with:
+          fetch-depth: 0
 
       - name: Set up Go
         uses: actions/setup-go@v5
@@ -130,6 +136,8 @@ jobs:
     steps:
       - name: Checkout code
         uses: actions/checkout@v4
+        with:
+          fetch-depth: 0
 
       - name: Set up Go
         uses: actions/setup-go@v5

+ 0 - 1
tool/generate/git/git_data.go

@@ -72,7 +72,6 @@ func initGitData() (err error) {
 	if err != nil {
 		return err
 	}
-
 	log.Printf("generate: get git tag list length: %d\n", len(tagList))
 
 	if len(tagList) > 0 {

+ 7 - 0
tool/utils/gitutils/git.go

@@ -5,6 +5,7 @@
 package gitutils
 
 import (
+	"fmt"
 	"github.com/SongZihuan/BackendServerTemplate/tool/utils/cleanstringutils"
 	"github.com/SongZihuan/BackendServerTemplate/tool/utils/executils"
 	"github.com/SongZihuan/BackendServerTemplate/tool/utils/filesystemutils"
@@ -32,13 +33,19 @@ func GetTagListWithFilter(filter func(string) bool) ([]string, error) {
 		return nil, err
 	}
 
+	fmt.Printf("\n=1=\n%s\n=1=\n", ret)
 	ret = cleanstringutils.GetString(ret)
+	fmt.Printf("\n=2=\n%s\n=2=\n", ret)
+
 	tagListSrc := strings.Split(ret, "\n")
+	fmt.Printf("tagListSrc length=%d\n", len(tagListSrc))
+
 	tagList := make([]string, 0, len(tagListSrc))
 
 	for _, tag := range tagListSrc {
 		tag = strings.TrimSpace(tag)
 		if tag == "" || (filter != nil && !filter(tag)) {
+			fmt.Printf("generate: skip tag %s\n", tag)
 			continue
 		}
 		tagList = append(tagList, tag)