-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit.go
More file actions
55 lines (46 loc) · 1001 Bytes
/
git.go
File metadata and controls
55 lines (46 loc) · 1001 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// SPDX-License-Identifier: Unlicense
package main
import (
"io"
"net/http"
"os"
"os/exec"
"strings"
)
func gitInit() error {
cmd := exec.Command("git", "init")
return cmd.Run()
}
func createGitIgnore() error {
res, err := http.Get("https://www.toptal.com/developers/gitignore/api/" + strings.Join(gitIgnoreTemplates, ","))
if err != nil {
return err
}
defer res.Body.Close()
f, err := os.Create(".gitignore")
if err != nil {
return err
}
defer f.Close()
_, err = io.Copy(f, res.Body)
return err
}
func createGitAttributes() error {
res, err := http.Get("https://gitattributes.com/api/" + strings.Join(gitAttributesTemplates, "%2C"))
if err != nil {
return err
}
defer res.Body.Close()
f, err := os.Create(".gitattributes")
if err != nil {
return err
}
defer f.Close()
_, err = io.Copy(f, res.Body)
return err
}
func createGitRemote() error {
cmd := exec.Command("git", "remote", "add", "origin", gitRemoteAddr)
cmd.Stdout = os.Stdout
return cmd.Run()
}