mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-02-23 06:36:17 +00:00
Merge branch 'origin/main' into 'next-release/main'
This commit is contained in:
commit
017a3d24d4
2 changed files with 8 additions and 24 deletions
|
@ -20,8 +20,6 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
@ -287,22 +285,16 @@ func (c *Forgejo) Dir(ctx context.Context, u *model.User, r *model.Repo, b *mode
|
|||
return nil, err
|
||||
}
|
||||
|
||||
// List files in repository. Path from root
|
||||
tree, _, err := client.GetTrees(r.Owner, r.Name, b.Commit, true)
|
||||
// List files in repository
|
||||
contents, _, err := client.ListContents(r.Owner, r.Name, b.Commit, f)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
f = path.Clean(f) // We clean path and remove trailing slash
|
||||
f += "/" + "*" // construct pattern for match i.e. file in subdir
|
||||
for _, e := range tree.Entries {
|
||||
// Filter path matching pattern and type file (blob)
|
||||
if m, _ := filepath.Match(f, e.Path); m && e.Type == "blob" {
|
||||
for _, e := range contents {
|
||||
if e.Type == "file" {
|
||||
data, err := c.File(ctx, u, r, b, e.Path)
|
||||
if err != nil {
|
||||
if errors.Is(err, &forge_types.ErrConfigNotFound{}) {
|
||||
return nil, fmt.Errorf("git tree reported existence of file but we got: %s", err.Error())
|
||||
}
|
||||
return nil, fmt.Errorf("multi-pipeline cannot get %s: %w", e.Path, err)
|
||||
}
|
||||
|
||||
|
|
|
@ -22,8 +22,6 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
@ -289,22 +287,16 @@ func (c *Gitea) Dir(ctx context.Context, u *model.User, r *model.Repo, b *model.
|
|||
return nil, err
|
||||
}
|
||||
|
||||
// List files in repository. Path from root
|
||||
tree, _, err := client.GetTrees(r.Owner, r.Name, b.Commit, true)
|
||||
// List files in repository
|
||||
contents, _, err := client.ListContents(r.Owner, r.Name, b.Commit, f)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
f = path.Clean(f) // We clean path and remove trailing slash
|
||||
f += "/" + "*" // construct pattern for match i.e. file in subdir
|
||||
for _, e := range tree.Entries {
|
||||
// Filter path matching pattern and type file (blob)
|
||||
if m, _ := filepath.Match(f, e.Path); m && e.Type == "blob" {
|
||||
for _, e := range contents {
|
||||
if e.Type == "file" {
|
||||
data, err := c.File(ctx, u, r, b, e.Path)
|
||||
if err != nil {
|
||||
if errors.Is(err, &forge_types.ErrConfigNotFound{}) {
|
||||
return nil, fmt.Errorf("git tree reported existence of file but we got: %s", err.Error())
|
||||
}
|
||||
return nil, fmt.Errorf("multi-pipeline cannot get %s: %w", e.Path, err)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue