|
@@ -1,9 +1,9 @@
|
1
|
1
|
package git
|
2
|
2
|
|
3
|
3
|
import (
|
|
4
|
+ "fmt"
|
4
|
5
|
"io/ioutil"
|
5
|
6
|
"os"
|
6
|
|
- "strings"
|
7
|
7
|
|
8
|
8
|
"config"
|
9
|
9
|
|
|
@@ -36,6 +36,19 @@ func Sync(cfg config.GitSettings) (r *gogit.Repository, err error) {
|
36
|
36
|
return
|
37
|
37
|
}
|
38
|
38
|
|
|
39
|
+ // Check whether the clone path is a Git repository
|
|
40
|
+ var isRepo bool
|
|
41
|
+ if isRepo, err = dirExists(cfg.ClonePath + "/.git"); err != nil {
|
|
42
|
+ return
|
|
43
|
+ } else if exists && !isRepo {
|
|
44
|
+ err = fmt.Errorf(
|
|
45
|
+ "%s already exists but is not a Git repository",
|
|
46
|
+ cfg.ClonePath,
|
|
47
|
+ )
|
|
48
|
+
|
|
49
|
+ return
|
|
50
|
+ }
|
|
51
|
+
|
39
|
52
|
logrus.WithFields(logrus.Fields{
|
40
|
53
|
"repo": cfg.User + "@" + cfg.URL,
|
41
|
54
|
"clone_path": cfg.ClonePath,
|