未验证 提交 9c1ba22f 编写于 作者: P Phodal Huang

fix: fix git format issue

上级 afbf1b44
......@@ -115,17 +115,16 @@ var gitCmd = &cobra.Command{
}
GetRelatedFiles(commitMessages, config)
//results := GetRelatedFiles(commitMessages, config)
//fmt.Println(results)
}
},
}
func getCommitMessage() string {
historyArgs := []string{"log", "--pretty=format:[%h] %aN %ad %s", "--date=short", "--numstat", "--reverse", "--summary"}
historyArgs := []string{"log", "--pretty=\"format:[%h] %aN %ad %s\"", "--date=short", "--numstat", "--reverse", "--summary"}
cmd := exec.Command("git", historyArgs...)
out, err := cmd.CombinedOutput()
if err != nil {
fmt.Println(string(out))
log.Fatalf("cmd.Run() failed with %s\n", err)
}
......
......@@ -95,11 +95,11 @@ func buildComment(path string) []*astitodo.TODO {
func runGitGetLog(line int, fileName string) string {
// git log -1 -L2:README.md --pretty="format:[%h] %aN %ad %s" --date=short --numstat
historyArgs := []string{"log", "-1", "-L" + strconv.Itoa(line) + ":" + fileName, "--pretty=format:[%h] %aN %ad %s", "--date=short", "--numstat", "--summary"}
historyArgs := []string{"log", "-1", "-L" + strconv.Itoa(line) + ":" + fileName, "--pretty=\"format:[%h] %aN %ad %s\"", "--date=short", "--numstat", "--summary"}
cmd := exec.Command("git", historyArgs...)
out, err := cmd.CombinedOutput()
if err != nil {
fmt.Println(out)
fmt.Println(string(out))
log.Fatalf("cmd.Run() failed with %s\n", err)
}
......
......@@ -14,7 +14,7 @@ func GetJavaFiles(codeDir string) []string {
files := make([]string, 0)
gitIgnore, err := ignore.CompileIgnoreFile(".gitignore")
if err != nil {
fmt.Println(err)
//fmt.Println(err)
}
fi, err := os.Stat(codeDir)
......
......@@ -5,23 +5,23 @@ import (
"github.com/phodal/coca/config"
"io/ioutil"
"os"
"path/filepath"
)
var reporterPath = config.CocaConfig.ReporterPath
func WriteToCocaFile(fileName string, payload string) {
if _, err := os.Stat(reporterPath); os.IsNotExist(err) {
err := os.Mkdir(reporterPath, os.ModePerm)
if err != nil {
fmt.Println(err)
mkdirErr := os.Mkdir(reporterPath, os.ModePerm)
if mkdirErr != nil {
fmt.Println(mkdirErr)
}
}
_ = ioutil.WriteFile(reporterPath+"/"+fileName, []byte(payload), os.ModePerm)
_ = ioutil.WriteFile(filepath.FromSlash(reporterPath+"/"+fileName), []byte(payload), os.ModePerm)
}
func ReadCocaFile(fileName string) []byte {
return ReadFile(reporterPath + "/" + fileName)
return ReadFile(filepath.FromSlash(reporterPath + "/" + fileName))
}
func ReadFile(fileName string) []byte {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册