mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-10-31 22:38:49 +00:00
If config is no dir asume its a folder (#354)
If config is no dir assume its a folder (user do not always add / suffix)
This commit is contained in:
parent
4df9c8d6a5
commit
d8cd4925ec
1 changed files with 6 additions and 7 deletions
|
@ -26,14 +26,15 @@ func NewConfigFetcher(remote remote.Remote, user *model.User, repo *model.Repo,
|
||||||
|
|
||||||
func (cf *configFetcher) Fetch() (files []*remote.FileMeta, err error) {
|
func (cf *configFetcher) Fetch() (files []*remote.FileMeta, err error) {
|
||||||
var file []byte
|
var file []byte
|
||||||
|
config := strings.TrimSpace(cf.repo.Config)
|
||||||
|
|
||||||
for i := 0; i < 5; i++ {
|
for i := 0; i < 5; i++ {
|
||||||
select {
|
select {
|
||||||
case <-time.After(time.Second * time.Duration(i)):
|
case <-time.After(time.Second * time.Duration(i)):
|
||||||
if len(cf.repo.Config) > 0 {
|
if len(cf.repo.Config) > 0 {
|
||||||
// either a file
|
// either a file
|
||||||
if !strings.HasSuffix(cf.repo.Config, "/") {
|
if !strings.HasSuffix(config, "/") {
|
||||||
file, err = cf.remote_.File(cf.user, cf.repo, cf.build, cf.repo.Config)
|
file, err = cf.remote_.File(cf.user, cf.repo, cf.build, config)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return []*remote.FileMeta{{
|
return []*remote.FileMeta{{
|
||||||
Name: cf.repo.Config,
|
Name: cf.repo.Config,
|
||||||
|
@ -43,11 +44,9 @@ func (cf *configFetcher) Fetch() (files []*remote.FileMeta, err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// or a folder
|
// or a folder
|
||||||
if strings.HasSuffix(cf.repo.Config, "/") {
|
files, err = cf.remote_.Dir(cf.user, cf.repo, cf.build, strings.TrimSuffix(config, "/"))
|
||||||
files, err = cf.remote_.Dir(cf.user, cf.repo, cf.build, strings.TrimSuffix(cf.repo.Config, "/"))
|
if err == nil {
|
||||||
if err == nil {
|
return filterPipelineFiles(files), nil
|
||||||
return filterPipelineFiles(files), nil
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// no user defined config so try .woodpecker/*.yml -> .woodpecker.yml -> .drone.yml
|
// no user defined config so try .woodpecker/*.yml -> .woodpecker.yml -> .drone.yml
|
||||||
|
|
Loading…
Reference in a new issue