/
gitexec.go
78 lines (65 loc) · 1.32 KB
/
gitexec.go
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package cmd
import "github.com/zbiljic/fget/pkg/gitexec"
func gitRepoPathPull(repoPath string) ([]byte, error) {
out, err := gitexec.Pull(&gitexec.PullOptions{
CmdDir: repoPath,
Prune: true,
})
if err != nil {
return out, err
}
return out, nil
}
func gitRepoRefetch(repoPath string) ([]byte, error) {
out, err := gitexec.Fetch(&gitexec.FetchOptions{
CmdDir: repoPath,
Prune: true,
Refetch: true,
})
if err != nil {
return out, err
}
return out, nil
}
func gitRepoPathGc(repoPath string) ([]byte, error) {
out, err := gitexec.Gc(&gitexec.GcOptions{
CmdDir: repoPath,
Prune: "all",
})
if err != nil {
return out, err
}
return out, nil
}
func gitRepoReset(repoPath, commit string) ([]byte, error) {
out, err := gitexec.Reset(&gitexec.ResetOptions{
CmdDir: repoPath,
Hard: true,
Commit: commit,
})
if err != nil {
return out, err
}
return out, nil
}
func gitRepoDiff(repoPath string) ([]byte, error) {
out, err := gitexec.Diff(&gitexec.DiffOptions{
CmdDir: repoPath,
Cached: true,
})
if err != nil {
return out, err
}
return out, nil
}
func gitRepoIgnoreFileMode(repoPath string) ([]byte, error) {
out, err := gitexec.Config(&gitexec.ConfigOptions{
CmdDir: repoPath,
Name: "core.filemode",
Value: "false",
})
if err != nil {
return out, err
}
return out, nil
}