diff --git a/.gitignore b/.gitignore index 32d6a63..6a951cb 100644 --- a/.gitignore +++ b/.gitignore @@ -16,8 +16,12 @@ # Dependency directories (remove the comment below to include it) # vendor/ +# goland的相关配置 .idea +# vscode 的相关配置 .vscode +# 构建后的产物目录 +release *_test.go *.txt diff --git a/git.go b/git.go index 1478c9c..5b23c4d 100644 --- a/git.go +++ b/git.go @@ -100,3 +100,51 @@ func (g *git) Push(force bool) *define.Result { } return Execute(g.workDir, g.gitCmdPath, param) } + +// AddGitignore 添加 .gitignore 文件 +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 20:31 2022/6/14 +func (g *git) AddGitignore(fileList ...string) *define.Result { + baseFileContent := `# Created by .ignore support plugin (hsz.mobi) +### Go template +# Binaries for programs and plugins +*.exe +*.exe~ +*.dll +*.so +*.dylib +*.xlsx + +# Test binary, built with "go test -c" +*.test + +# Output of the go coverage tool, specifically when used with LiteIDE +*.out + +# Dependency directories (remove the comment below to include it) +# vendor/ +# goland的相关配置 +.idea +# vscode 的相关配置 +.vscode +# 构建后的产物目录 +release +*_test.go +*.txt +` + for _, item := range fileList { + baseFileContent = baseFileContent + "\n" + item + } + // 将信息写入文件 + return &define.Result{ + WorkDir: g.workDir, + CmdPath: "", + Param: nil, + Error: File(g.workDir, ".gitignore").Write([]byte(baseFileContent)), + Output: nil, + StartTime: 0, + FinishTime: 0, + } +}