mirror of
https://github.com/go-gitea/gitea.git
synced 2025-07-17 00:01:00 -04:00
Compare commits
3 Commits
2bdc38e592
...
80d7288ea4
Author | SHA1 | Date | |
---|---|---|---|
|
80d7288ea4 | ||
|
2d1202b32c | ||
|
9112ce22a4 |
@ -4,6 +4,7 @@
|
|||||||
package setting
|
package setting
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"os"
|
"os"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
@ -131,6 +132,11 @@ func EnvironmentToConfig(cfg ConfigProvider, envs []string) (changed bool) {
|
|||||||
log.Error("Error reading file for %s : %v", envKey, envValue, err)
|
log.Error("Error reading file for %s : %v", envKey, envValue, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
if bytes.HasSuffix(fileContent, []byte("\r\n")) {
|
||||||
|
fileContent = fileContent[:len(fileContent)-2]
|
||||||
|
} else if bytes.HasSuffix(fileContent, []byte("\n")) {
|
||||||
|
fileContent = fileContent[:len(fileContent)-1]
|
||||||
|
}
|
||||||
keyValue = string(fileContent)
|
keyValue = string(fileContent)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,4 +99,19 @@ key = old
|
|||||||
changed = EnvironmentToConfig(cfg, []string{"GITEA__sec__key__FILE=" + tmpFile})
|
changed = EnvironmentToConfig(cfg, []string{"GITEA__sec__key__FILE=" + tmpFile})
|
||||||
assert.True(t, changed)
|
assert.True(t, changed)
|
||||||
assert.Equal(t, "value-from-file", cfg.Section("sec").Key("key").String())
|
assert.Equal(t, "value-from-file", cfg.Section("sec").Key("key").String())
|
||||||
|
|
||||||
|
cfg, _ = NewConfigProviderFromData("")
|
||||||
|
_ = os.WriteFile(tmpFile, []byte("value-from-file\n"), 0o644)
|
||||||
|
EnvironmentToConfig(cfg, []string{"GITEA__sec__key__FILE=" + tmpFile})
|
||||||
|
assert.Equal(t, "value-from-file", cfg.Section("sec").Key("key").String())
|
||||||
|
|
||||||
|
cfg, _ = NewConfigProviderFromData("")
|
||||||
|
_ = os.WriteFile(tmpFile, []byte("value-from-file\r\n"), 0o644)
|
||||||
|
EnvironmentToConfig(cfg, []string{"GITEA__sec__key__FILE=" + tmpFile})
|
||||||
|
assert.Equal(t, "value-from-file", cfg.Section("sec").Key("key").String())
|
||||||
|
|
||||||
|
cfg, _ = NewConfigProviderFromData("")
|
||||||
|
_ = os.WriteFile(tmpFile, []byte("value-from-file\n\n"), 0o644)
|
||||||
|
EnvironmentToConfig(cfg, []string{"GITEA__sec__key__FILE=" + tmpFile})
|
||||||
|
assert.Equal(t, "value-from-file\n", cfg.Section("sec").Key("key").String())
|
||||||
}
|
}
|
||||||
|
@ -90,12 +90,16 @@ func NewMinioStorage(ctx context.Context, cfg *setting.Storage) (ObjectStorage,
|
|||||||
return nil, convertMinioErr(err)
|
return nil, convertMinioErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := minioClient.MakeBucket(ctx, config.Bucket, minio.MakeBucketOptions{
|
// Check to see if we already own this bucket
|
||||||
Region: config.Location,
|
exists, errBucketExists := minioClient.BucketExists(ctx, config.Bucket)
|
||||||
}); err != nil {
|
if errBucketExists != nil {
|
||||||
// Check to see if we already own this bucket (which happens if you run this twice)
|
return nil, convertMinioErr(err)
|
||||||
exists, errBucketExists := minioClient.BucketExists(ctx, config.Bucket)
|
}
|
||||||
if !exists || errBucketExists != nil {
|
|
||||||
|
if !exists {
|
||||||
|
if err := minioClient.MakeBucket(ctx, config.Bucket, minio.MakeBucketOptions{
|
||||||
|
Region: config.Location,
|
||||||
|
}); err != nil {
|
||||||
return nil, convertMinioErr(err)
|
return nil, convertMinioErr(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ function makeCollections({mentions, emoji}) {
|
|||||||
|
|
||||||
if (mentions) {
|
if (mentions) {
|
||||||
collections.push({
|
collections.push({
|
||||||
values: window.config.tributeValues,
|
values: window.config.tributeValues ?? [],
|
||||||
requireLeadingSpace: true,
|
requireLeadingSpace: true,
|
||||||
menuItemTemplate: (item) => {
|
menuItemTemplate: (item) => {
|
||||||
return `
|
return `
|
||||||
|
@ -32,7 +32,7 @@ export function matchMention(queryText) {
|
|||||||
|
|
||||||
// results is a map of weights, lower is better
|
// results is a map of weights, lower is better
|
||||||
const results = new Map();
|
const results = new Map();
|
||||||
for (const obj of window.config.tributeValues) {
|
for (const obj of window.config.tributeValues ?? []) {
|
||||||
const index = obj.key.toLowerCase().indexOf(query);
|
const index = obj.key.toLowerCase().indexOf(query);
|
||||||
if (index === -1) continue;
|
if (index === -1) continue;
|
||||||
const existing = results.get(obj);
|
const existing = results.get(obj);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user