mirror of
https://gitea.com/gitea/tea.git
synced 2026-10-26 19:11:25 +01:00
fix: tighten error classification and pull request selection
Only Gitea's archived-repository messages mean the repository is archived, so an archived label is no longer reported as one. Refused POSTs to the organization, team, user and SSH key collections name the resource they would have created, and the existing pull request is looked up with escaped branch names. pullSelector without an argument refuses an explicit --repo, like gh: the checked-out branch says nothing about another repository. Signed-off-by: bircni <bircni@icloud.com>
This commit is contained in:
7 files changed
+41
-23
No files matched your search
@@ -5,6 +5,7 @@ package app
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"cmp"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
@@ -58,10 +59,10 @@ func (f downloadFlags) destination(name string) (path string, skip bool, err err
|
||||
}
|
||||
path = f.output
|
||||
if path == "" || isDirectory(path) {
|
||||
if name != filepath.Base(name) || name == "." || name == ".." || strings.ContainsAny(name, `/\`) {
|
||||
if name == "" || name == "." || name == ".." || strings.ContainsAny(name, `/\`) {
|
||||
return "", false, clierr.Wrap(clierr.Usage, fmt.Errorf("cannot use %q as a file name; pass --output", name))
|
||||
}
|
||||
path = filepath.Join(cmpOrDot(path, f.dir), name)
|
||||
path = filepath.Join(cmp.Or(path, f.dir, "."), name)
|
||||
}
|
||||
if _, err := os.Lstat(path); err == nil {
|
||||
if f.skipExisting {
|
||||
@@ -76,15 +77,6 @@ func (f downloadFlags) destination(name string) (path string, skip bool, err err
|
||||
return path, false, nil
|
||||
}
|
||||
|
||||
func cmpOrDot(values ...string) string {
|
||||
for _, value := range values {
|
||||
if value != "" {
|
||||
return value
|
||||
}
|
||||
}
|
||||
return "."
|
||||
}
|
||||
|
||||
func isDirectory(path string) bool {
|
||||
info, err := os.Stat(path)
|
||||
return (err == nil && info.IsDir()) || strings.HasSuffix(path, string(filepath.Separator)) || strings.HasSuffix(path, "/")
|
||||
|
||||
Reference in new issue
Block a user