Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit562fcd8

Browse files
committed
feat: fix .git dir erro issues
1 parent3450099 commit562fcd8

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

‎cmd/cloc.go‎

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@ import (
44
"fmt"
55
"github.com/boyter/scc/processor"
66
"github.com/phodal/coca/cmd/config"
7+
"github.com/phodal/coca/pkg/domain/cloc"
78
"github.com/spf13/cobra"
9+
"gopkg.in/yaml.v2"
810
"io/ioutil"
911
"log"
1012
"os"
1113
"path/filepath"
14+
"strings"
1215
)
1316

1417
type CocaClocConfig struct {
@@ -42,15 +45,35 @@ var clocCmd = &cobra.Command{
4245

4346
processor.Format ="cloc-yaml"
4447

48+
var outputFiles []string
4549
for _, dir := range dirs {
4650
baseName := filepath.Base(dir)
51+
if baseName ==".git" || baseName ==".svn" || baseName ==".hg" {
52+
continue
53+
}
4754
processor.DirFilePaths = []string{dir}
48-
processor.FileOutput = filepath.FromSlash(config.CocaConfig.ReporterPath +"/cloc/" + baseName +".yaml")
55+
outputFile := filepath.FromSlash(config.CocaConfig.ReporterPath +"/cloc/" + baseName +".yaml")
56+
outputFiles =append(outputFiles, outputFile)
57+
processor.FileOutput = outputFile
4958
processor.ConfigureGc()
5059
processor.ConfigureLazy(true)
5160
processor.Process()
5261
}
5362

63+
var summaryMap =make(map[string]cloc.ClocSummary)
64+
for _, file := range outputFiles {
65+
var summary = cloc.ClocSummary{}
66+
contents, _ := ioutil.ReadFile(file)
67+
baseName := strings.TrimSuffix(filepath.Base(file), filepath.Ext(file))
68+
err := yaml.Unmarshal(contents, &summary)
69+
if err != nil {
70+
panic(err);
71+
}
72+
summaryMap[baseName] = summary
73+
}
74+
75+
fmt.Println(summaryMap)
76+
5477
return
5578
}else {
5679
processor.DirFilePaths = args

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp