From 08219b72190689d701070141b6b262af3ed61d2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Tue, 14 Jun 2022 20:36:50 +0800 Subject: [PATCH] =?UTF-8?q?git=E6=94=AF=E6=8C=81=E7=94=9F=E6=88=90.gitigno?= =?UTF-8?q?re=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 4 ++++ git.go | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) 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, + } +}