Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit.go
More file actions
Latest commit
76 lines (62 loc) · 1.36 KB
/
Copy pathgit.go
File metadata and controls
76 lines (62 loc) · 1.36 KB
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
package git
import (
"fmt"
"strings"
"time"
)
const_VERSION="0.0.2"
funcVersion() string {
return_VERSION
}
var (
// Debug enables verbose logging on everything.
// This should be false in case Gitote starts in SSH mode.
Debug=false
Prefix="[git-module] "
)
funclog(formatstring, args...interface{}) {
if!Debug {
return
}
fmt.Print(Prefix)
iflen(args) ==0 {
fmt.Println(format)
} else {
fmt.Printf(format+"\n", args...)
}
}
vargitVersionstring
// Version returns current Git version from shell.
funcBinVersion() (string, error) {
iflen(gitVersion) >0 {
returngitVersion, nil
}
stdout, err:=NewCommand("version").Run()
iferr!=nil {
return"", err
}
fields:=strings.Fields(stdout)
iflen(fields) <3 {
return"", fmt.Errorf("not enough output: %s", stdout)
}
// Handle special case on Windows.
i:=strings.Index(fields[2], "windows")
ifi>=1 {
gitVersion=fields[2][:i-1]
returngitVersion, nil
}
gitVersion=fields[2]
returngitVersion, nil
}
funcinit() {
BinVersion()
}
// Fsck verifies the connectivity and validity of the objects in the database
funcFsck(repoPathstring, timeout time.Duration, args...string) error {
// Make sure timeout makes sense.
iftimeout<=0 {
timeout=-1
}
_, err:=NewCommand("fsck").AddArguments(args...).RunInDirTimeout(timeout, repoPath)
returnerr
}