1
- // We'd love a working pure Go implementation. But so far we didn't find any
2
- // that would work for us. src-d/go-git is innapropriate due to
3
- // https://github.com/src-d/go-git/issues/793 and
4
- // https://github.com/src-d/go-git/issues/785 . And binding to the libgit C lib
5
- // aren't pure Go either. So we need the git binary for now.
6
-
7
- // Package git makes a git repository out of a local directory, keeps the
8
- // content committed when the directory content changes, and optionaly (if
9
- // a remote repos url is provided), keep it in sync with a remote repository.
10
1
package git
11
2
12
3
import (
@@ -23,11 +14,20 @@ import (
23
14
)
24
15
25
16
var (
26
- timeoutCommands = 60 * time .Second
27
- checkInterval = 10 * time .Second
28
- gitAuthor = "Katafygio"
29
- gitEmail = "katafygio@localhost"
30
- gitMsg = "Kubernetes cluster change"
17
+ // TimeoutCommands defines the max execution time for git commands
18
+ TimeoutCommands = 60 * time .Second
19
+
20
+ // CheckInterval defines the interval between local directory checks
21
+ CheckInterval = 10 * time .Second
22
+
23
+ // GitAuthor is the name of the commiter
24
+ GitAuthor = "Katafygio"
25
+
26
+ // GitEmail is the email of the commiter
27
+ GitEmail = "katafygio@localhost"
28
+
29
+ // GitMsg is the commit message we'll use
30
+ GitMsg = "Kubernetes cluster change"
31
31
)
32
32
33
33
var appFs = afero .NewOsFs ()
@@ -51,9 +51,9 @@ func New(config *config.KfConfig) *Store {
51
51
Logger : config .Logger ,
52
52
URL : config .GitURL ,
53
53
LocalDir : config .LocalDir ,
54
- Author : gitAuthor ,
55
- Email : gitEmail ,
56
- Msg : gitMsg ,
54
+ Author : GitAuthor ,
55
+ Email : GitEmail ,
56
+ Msg : GitMsg ,
57
57
DryRun : config .DryRun ,
58
58
}
59
59
}
@@ -70,7 +70,7 @@ func (s *Store) Start() (*Store, error) {
70
70
}
71
71
72
72
go func () {
73
- checkTick := time .NewTicker (checkInterval )
73
+ checkTick := time .NewTicker (CheckInterval )
74
74
defer checkTick .Stop ()
75
75
defer close (s .donech )
76
76
@@ -100,7 +100,7 @@ func (s *Store) Git(args ...string) error {
100
100
return nil
101
101
}
102
102
103
- ctx , cancel := context .WithTimeout (context .Background (), timeoutCommands )
103
+ ctx , cancel := context .WithTimeout (context .Background (), TimeoutCommands )
104
104
defer cancel ()
105
105
106
106
cmd := exec .CommandContext (ctx , "git" , args ... ) // #nosec
@@ -121,7 +121,7 @@ func (s *Store) Status() (changed bool, err error) {
121
121
return false , nil
122
122
}
123
123
124
- ctx , cancel := context .WithTimeout (context .Background (), timeoutCommands )
124
+ ctx , cancel := context .WithTimeout (context .Background (), TimeoutCommands )
125
125
defer cancel ()
126
126
127
127
cmd := exec .CommandContext (ctx , "git" , "status" , "--porcelain" ) // #nosec
0 commit comments