ignore git files

pull/6/head
Marcus Kok 2 years ago
parent 887ed15f35
commit 4866495c76

@ -60,6 +60,7 @@ var initCommand = &cobra.Command {
log.Fatal("path needs trailing slash") log.Fatal("path needs trailing slash")
} }
// TODO make a configurable list of binaries we want to look for
var programs []string var programs []string
var acceptedprograms [3] string var acceptedprograms [3] string
acceptedprograms[0] = "nvim" acceptedprograms[0] = "nvim"

@ -4,12 +4,18 @@ import (
"fmt" "fmt"
"io" "io"
"path/filepath" "path/filepath"
"strings"
"github.com/spf13/afero" "github.com/spf13/afero"
) )
func CopyFile(os afero.Fs, srcFile, destFile string) error{ func CopyFile(os afero.Fs, srcFile, destFile string) error{
// helper function to copy files over // helper function to copy files over
// ignore pre-existing git files
if strings.Contains(srcFile, ".git") {
return nil
}
sourceFileStat, err := os.Stat(srcFile) sourceFileStat, err := os.Stat(srcFile)
if err != nil { if err != nil {
return err return err
@ -19,6 +25,7 @@ func CopyFile(os afero.Fs, srcFile, destFile string) error{
return fmt.Errorf("%s is not a regular file", srcFile) return fmt.Errorf("%s is not a regular file", srcFile)
} }
source, err := os.Open(srcFile) source, err := os.Open(srcFile)
if err != nil { if err != nil {
return err return err
@ -44,6 +51,9 @@ func CopyDir(os afero.Fs, srcDir, destDir string) error {
for _, entry := range(entries) { for _, entry := range(entries) {
if entry.IsDir() { if entry.IsDir() {
if entry.Name() == ".git" {
continue
}
subDir := filepath.Join(srcDir, entry.Name()) subDir := filepath.Join(srcDir, entry.Name())
destSubDir := filepath.Join(destDir, entry.Name()) destSubDir := filepath.Join(destDir, entry.Name())
err := os.MkdirAll(destSubDir, entry.Mode().Perm()) err := os.MkdirAll(destSubDir, entry.Mode().Perm())

Loading…
Cancel
Save