Add gitignore template

This commit is contained in:
2025-09-05 20:46:12 +03:00
parent aae5299b8a
commit c9627e1068
2 changed files with 19 additions and 0 deletions
+2
View File
@@ -0,0 +1,2 @@
# Exclude bpm archives
*.bpm
+17
View File
@@ -4,6 +4,7 @@ import (
bpmutilsshared "bpm-utils-shared" bpmutilsshared "bpm-utils-shared"
"bufio" "bufio"
"fmt" "fmt"
"io"
"log" "log"
"os" "os"
"os/exec" "os/exec"
@@ -163,5 +164,21 @@ func createDirectory() {
if err != nil { if err != nil {
log.Fatalf("Error: could not initialize git repository: %s", err) log.Fatalf("Error: could not initialize git repository: %s", err)
} }
// Copy default gitignore
defaultGitignoreFile, err := os.Open("/etc/bpm-utils/gitignore.default")
if err != nil {
return
}
defer defaultGitignoreFile.Close()
newGitignoreFile, err := os.OpenFile(path.Join(*directory, ".gitignore"), os.O_CREATE|os.O_WRONLY, 0644)
if err != nil {
log.Fatalf("Error: could not create .gitignore file: %s", err)
}
_, err = io.Copy(newGitignoreFile, defaultGitignoreFile)
if err != nil {
log.Fatalf("Error: could not copy data to .gitignore file: %s", err)
}
} }
} }