@@ -2,9 +2,13 @@ package provider
2
2
3
3
import (
4
4
"errors"
5
+ "os"
6
+ "path/filepath"
5
7
"srcfingerprint/cloner"
6
8
"strings"
7
9
"time"
10
+
11
+ log "github.com/sirupsen/logrus"
8
12
)
9
13
10
14
// Repository Structure. Generic.
@@ -55,15 +59,25 @@ func (p *GenericProvider) Gather(user string) ([]GitRepository, error) {
55
59
if p .options .RepositoryName != "" {
56
60
name = p .options .RepositoryName
57
61
} else {
62
+ path := user
63
+ if _ , err := os .Stat (user ); err == nil || ! os .IsNotExist (err ) {
64
+ if absPath , err := filepath .Abs (user ); err == nil {
65
+ log .Debugf ("`%v` is a local path, will use absolute path `%v`" , user , absPath )
66
+ path = absPath
67
+ }
68
+ }
69
+
58
70
// Split the repository URL or patch and use the last part
59
- parts := strings .Split (user , "/" )
71
+ parts := strings .Split (path , "/" )
60
72
if parts [len (parts )- 1 ] == ".git" && len (parts ) > 2 {
61
73
// As "path/to/project/.git" is valid, we use the second to last part when the last part is ".git"
62
74
name = parts [len (parts )- 2 ]
63
75
} else {
64
76
name = parts [len (parts )- 1 ]
65
77
name = strings .TrimSuffix (name , ".git" )
66
78
}
79
+
80
+ log .Warnf ("Name of the repository unspecified (see --repo-name). '%v' has been inferred from the object." , name )
67
81
}
68
82
69
83
return []GitRepository {& Repository {
0 commit comments