Merge remote-tracking branch 'upstream/main' into limit-repo-size

This commit is contained in:
DmitryFrolovTri
2023-01-29 09:33:49 +00:00
32 changed files with 716 additions and 180 deletions
+10 -1
View File
@@ -259,7 +259,9 @@ func (f *valuedField) WriteTo(builder *strings.Builder) {
}
// write label
_, _ = fmt.Fprintf(builder, "### %s\n\n", f.Label())
if !f.HideLabel() {
_, _ = fmt.Fprintf(builder, "### %s\n\n", f.Label())
}
blankPlaceholder := "_No response_\n"
@@ -311,6 +313,13 @@ func (f *valuedField) Label() string {
return ""
}
func (f *valuedField) HideLabel() bool {
if label, ok := f.Attributes["hide_label"].(bool); ok {
return label
}
return false
}
func (f *valuedField) Render() string {
if render, ok := f.Attributes["render"].(string); ok {
return render
+1 -2
View File
@@ -640,6 +640,7 @@ body:
description: Description of input
placeholder: Placeholder of input
value: Value of input
hide_label: true
validations:
required: true
is_number: true
@@ -681,8 +682,6 @@ body:
` + "```bash\nValue of id2\n```" + `
### Label of input
Value of id3
### Label of dropdown
+1 -1
View File
@@ -76,7 +76,7 @@ func validate(bs []byte, datatype interface{}, isJSON bool) error {
}
err = sch.Validate(v)
if err != nil {
log.Error("migration validation with %s failed for\n%s", schemaFilename, string(bs))
log.Error("migration validation with %s failed:\n%#v", schemaFilename, err)
}
return err
}
+1
View File
@@ -97,6 +97,7 @@ func (ns *notificationService) NotifyIssueChangeStatus(ctx context.Context, doer
_ = ns.issueQueue.Push(issueNotificationOpts{
IssueID: issue.ID,
NotificationAuthorID: doer.ID,
CommentID: actionComment.ID,
})
}
+22
View File
@@ -4,6 +4,7 @@
package util
import (
"errors"
"io"
)
@@ -17,3 +18,24 @@ func ReadAtMost(r io.Reader, buf []byte) (n int, err error) {
}
return n, err
}
// ErrNotEmpty is an error reported when there is a non-empty reader
var ErrNotEmpty = errors.New("not-empty")
// IsEmptyReader reads a reader and ensures it is empty
func IsEmptyReader(r io.Reader) (err error) {
var buf [1]byte
for {
n, err := r.Read(buf[:])
if err != nil {
if err == io.EOF {
return nil
}
return err
}
if n > 0 {
return ErrNotEmpty
}
}
}