mirror of
https://github.com/go-gitea/gitea.git
synced 2024-09-30 03:26:01 -04:00
Compare commits
No commits in common. "ac85271fb416d35e7542c243857c91a1688c531f" and "cda64789a2f34fce20a3cec4c2445e144e71cc8d" have entirely different histories.
ac85271fb4
...
cda64789a2
@ -5,48 +5,72 @@ package repo
|
|||||||
|
|
||||||
import "code.gitea.io/gitea/models/db"
|
import "code.gitea.io/gitea/models/db"
|
||||||
|
|
||||||
// OrderByMap represents all possible search order
|
// Strings for sorting result
|
||||||
var OrderByMap = map[string]map[string]db.SearchOrderBy{
|
const (
|
||||||
|
// only used for repos
|
||||||
|
SearchOrderByAlphabetically db.SearchOrderBy = "owner_name ASC, name ASC"
|
||||||
|
SearchOrderByAlphabeticallyReverse db.SearchOrderBy = "owner_name DESC, name DESC"
|
||||||
|
SearchOrderBySize db.SearchOrderBy = "size ASC"
|
||||||
|
SearchOrderBySizeReverse db.SearchOrderBy = "size DESC"
|
||||||
|
SearchOrderByGitSize db.SearchOrderBy = "git_size ASC"
|
||||||
|
SearchOrderByGitSizeReverse db.SearchOrderBy = "git_size DESC"
|
||||||
|
SearchOrderByLFSSize db.SearchOrderBy = "lfs_size ASC"
|
||||||
|
SearchOrderByLFSSizeReverse db.SearchOrderBy = "lfs_size DESC"
|
||||||
|
// alias as also used elsewhere
|
||||||
|
SearchOrderByLeastUpdated db.SearchOrderBy = db.SearchOrderByLeastUpdated
|
||||||
|
SearchOrderByRecentUpdated db.SearchOrderBy = db.SearchOrderByRecentUpdated
|
||||||
|
SearchOrderByOldest db.SearchOrderBy = db.SearchOrderByOldest
|
||||||
|
SearchOrderByNewest db.SearchOrderBy = db.SearchOrderByNewest
|
||||||
|
SearchOrderByID db.SearchOrderBy = db.SearchOrderByID
|
||||||
|
SearchOrderByIDReverse db.SearchOrderBy = db.SearchOrderByIDReverse
|
||||||
|
SearchOrderByStars db.SearchOrderBy = db.SearchOrderByStars
|
||||||
|
SearchOrderByStarsReverse db.SearchOrderBy = db.SearchOrderByStarsReverse
|
||||||
|
SearchOrderByForks db.SearchOrderBy = db.SearchOrderByForks
|
||||||
|
SearchOrderByForksReverse db.SearchOrderBy = db.SearchOrderByForksReverse
|
||||||
|
)
|
||||||
|
|
||||||
|
// SearchOrderByMap represents all possible search order
|
||||||
|
var SearchOrderByMap = map[string]map[string]db.SearchOrderBy{
|
||||||
"asc": {
|
"asc": {
|
||||||
"alpha": "owner_name ASC, name ASC",
|
"alpha": SearchOrderByAlphabetically,
|
||||||
"created": db.SearchOrderByOldest,
|
"created": SearchOrderByOldest,
|
||||||
"updated": db.SearchOrderByLeastUpdated,
|
"updated": SearchOrderByLeastUpdated,
|
||||||
"size": "size ASC",
|
"size": SearchOrderBySize,
|
||||||
"git_size": "git_size ASC",
|
"git_size": SearchOrderByGitSize,
|
||||||
"lfs_size": "lfs_size ASC",
|
"lfs_size": SearchOrderByLFSSize,
|
||||||
"id": db.SearchOrderByID,
|
"id": SearchOrderByID,
|
||||||
"stars": db.SearchOrderByStars,
|
"stars": SearchOrderByStars,
|
||||||
"forks": db.SearchOrderByForks,
|
"forks": SearchOrderByForks,
|
||||||
},
|
},
|
||||||
"desc": {
|
"desc": {
|
||||||
"alpha": "owner_name DESC, name DESC",
|
"alpha": SearchOrderByAlphabeticallyReverse,
|
||||||
"created": db.SearchOrderByNewest,
|
"created": SearchOrderByNewest,
|
||||||
"updated": db.SearchOrderByRecentUpdated,
|
"updated": SearchOrderByRecentUpdated,
|
||||||
"size": "size DESC",
|
"size": SearchOrderBySizeReverse,
|
||||||
"git_size": "git_size DESC",
|
"git_size": SearchOrderByGitSizeReverse,
|
||||||
"lfs_size": "lfs_size DESC",
|
"lfs_size": SearchOrderByLFSSizeReverse,
|
||||||
"id": db.SearchOrderByIDReverse,
|
"id": SearchOrderByIDReverse,
|
||||||
"stars": db.SearchOrderByStarsReverse,
|
"stars": SearchOrderByStarsReverse,
|
||||||
"forks": db.SearchOrderByForksReverse,
|
"forks": SearchOrderByForksReverse,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
// OrderByFlatMap is similar to OrderByMap but use human language keywords
|
// SearchOrderByFlatMap is similar to SearchOrderByMap but use human language keywords
|
||||||
// to decide between asc and desc
|
// to decide between asc and desc
|
||||||
var OrderByFlatMap = map[string]db.SearchOrderBy{
|
var SearchOrderByFlatMap = map[string]db.SearchOrderBy{
|
||||||
"newest": OrderByMap["desc"]["created"],
|
"newest": SearchOrderByMap["desc"]["created"],
|
||||||
"oldest": OrderByMap["asc"]["created"],
|
"oldest": SearchOrderByMap["asc"]["created"],
|
||||||
"leastupdate": OrderByMap["asc"]["updated"],
|
"leastupdate": SearchOrderByMap["asc"]["updated"],
|
||||||
"reversealphabetically": OrderByMap["desc"]["alpha"],
|
"reversealphabetically": SearchOrderByMap["desc"]["alpha"],
|
||||||
"alphabetically": OrderByMap["asc"]["alpha"],
|
"alphabetically": SearchOrderByMap["asc"]["alpha"],
|
||||||
"reversesize": OrderByMap["desc"]["size"],
|
"reversesize": SearchOrderByMap["desc"]["size"],
|
||||||
"size": OrderByMap["asc"]["size"],
|
"size": SearchOrderByMap["asc"]["size"],
|
||||||
"reversegitsize": OrderByMap["desc"]["git_size"],
|
"reversegitsize": SearchOrderByMap["desc"]["git_size"],
|
||||||
"gitsize": OrderByMap["asc"]["git_size"],
|
"gitsize": SearchOrderByMap["asc"]["git_size"],
|
||||||
"reverselfssize": OrderByMap["desc"]["lfs_size"],
|
"reverselfssize": SearchOrderByMap["desc"]["lfs_size"],
|
||||||
"lfssize": OrderByMap["asc"]["lfs_size"],
|
"lfssize": SearchOrderByMap["asc"]["lfs_size"],
|
||||||
"moststars": OrderByMap["desc"]["stars"],
|
"moststars": SearchOrderByMap["desc"]["stars"],
|
||||||
"feweststars": OrderByMap["asc"]["stars"],
|
"feweststars": SearchOrderByMap["asc"]["stars"],
|
||||||
"mostforks": OrderByMap["desc"]["forks"],
|
"mostforks": SearchOrderByMap["desc"]["forks"],
|
||||||
"fewestforks": OrderByMap["asc"]["forks"],
|
"fewestforks": SearchOrderByMap["asc"]["forks"],
|
||||||
}
|
}
|
||||||
|
@ -4,67 +4,12 @@
|
|||||||
package base
|
package base
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"unicode/utf8"
|
|
||||||
|
|
||||||
"golang.org/x/text/collate"
|
"golang.org/x/text/collate"
|
||||||
"golang.org/x/text/language"
|
"golang.org/x/text/language"
|
||||||
)
|
)
|
||||||
|
|
||||||
func naturalSortGetRune(str string, pos int) (r rune, size int, has bool) {
|
|
||||||
if pos >= len(str) {
|
|
||||||
return 0, 0, false
|
|
||||||
}
|
|
||||||
r, size = utf8.DecodeRuneInString(str[pos:])
|
|
||||||
if r == utf8.RuneError {
|
|
||||||
r, size = rune(str[pos]), 1 // if invalid input, treat it as a single byte ascii
|
|
||||||
}
|
|
||||||
return r, size, true
|
|
||||||
}
|
|
||||||
|
|
||||||
func naturalSortAdvance(str string, pos int) (end int, isNumber bool) {
|
|
||||||
end = pos
|
|
||||||
for {
|
|
||||||
r, size, has := naturalSortGetRune(str, end)
|
|
||||||
if !has {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
isCurRuneNum := '0' <= r && r <= '9'
|
|
||||||
if end == pos {
|
|
||||||
isNumber = isCurRuneNum
|
|
||||||
end += size
|
|
||||||
} else if isCurRuneNum == isNumber {
|
|
||||||
end += size
|
|
||||||
} else {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return end, isNumber
|
|
||||||
}
|
|
||||||
|
|
||||||
// NaturalSortLess compares two strings so that they could be sorted in natural order
|
// NaturalSortLess compares two strings so that they could be sorted in natural order
|
||||||
func NaturalSortLess(s1, s2 string) bool {
|
func NaturalSortLess(s1, s2 string) bool {
|
||||||
// There is a bug in Golang's collate package: https://github.com/golang/go/issues/67997
|
|
||||||
// text/collate: CompareString(collate.Numeric) returns wrong result for "0.0" vs "1.0" #67997
|
|
||||||
// So we need to handle the number parts by ourselves
|
|
||||||
c := collate.New(language.English, collate.Numeric)
|
c := collate.New(language.English, collate.Numeric)
|
||||||
pos1, pos2 := 0, 0
|
return c.CompareString(s1, s2) < 0
|
||||||
for pos1 < len(s1) && pos2 < len(s2) {
|
|
||||||
end1, isNum1 := naturalSortAdvance(s1, pos1)
|
|
||||||
end2, isNum2 := naturalSortAdvance(s2, pos2)
|
|
||||||
part1, part2 := s1[pos1:end1], s2[pos2:end2]
|
|
||||||
if isNum1 && isNum2 {
|
|
||||||
if part1 != part2 {
|
|
||||||
if len(part1) != len(part2) {
|
|
||||||
return len(part1) < len(part2)
|
|
||||||
}
|
|
||||||
return part1 < part2
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if cmp := c.CompareString(part1, part2); cmp != 0 {
|
|
||||||
return cmp < 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
pos1, pos2 = end1, end2
|
|
||||||
}
|
|
||||||
return len(s1) < len(s2)
|
|
||||||
}
|
}
|
||||||
|
@ -10,36 +10,21 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestNaturalSortLess(t *testing.T) {
|
func TestNaturalSortLess(t *testing.T) {
|
||||||
testLess := func(s1, s2 string) {
|
test := func(s1, s2 string, less bool) {
|
||||||
assert.True(t, NaturalSortLess(s1, s2), "s1<s2 should be true: s1=%q, s2=%q", s1, s2)
|
assert.Equal(t, less, NaturalSortLess(s1, s2), "s1=%q, s2=%q", s1, s2)
|
||||||
assert.False(t, NaturalSortLess(s2, s1), "s2<s1 should be false: s1=%q, s2=%q", s1, s2)
|
|
||||||
}
|
|
||||||
testEqual := func(s1, s2 string) {
|
|
||||||
assert.False(t, NaturalSortLess(s1, s2), "s1<s2 should be false: s1=%q, s2=%q", s1, s2)
|
|
||||||
assert.False(t, NaturalSortLess(s2, s1), "s2<s1 should be false: s1=%q, s2=%q", s1, s2)
|
|
||||||
}
|
}
|
||||||
|
test("v1.20.0", "v1.2.0", false)
|
||||||
|
test("v1.20.0", "v1.29.0", true)
|
||||||
|
test("v1.20.0", "v1.20.0", false)
|
||||||
|
test("abc", "bcd", true)
|
||||||
|
test("a-1-a", "a-1-b", true)
|
||||||
|
test("2", "12", true)
|
||||||
|
test("a", "ab", true)
|
||||||
|
|
||||||
testEqual("", "")
|
test("A", "b", true)
|
||||||
testLess("", "a")
|
test("a", "B", true)
|
||||||
testLess("", "1")
|
|
||||||
|
|
||||||
testLess("v1.2", "v1.2.0")
|
test("cafe", "café", true)
|
||||||
testLess("v1.2.0", "v1.10.0")
|
test("café", "cafe", false)
|
||||||
testLess("v1.20.0", "v1.29.0")
|
test("caff", "café", false)
|
||||||
testEqual("v1.20.0", "v1.20.0")
|
|
||||||
|
|
||||||
testLess("a", "A")
|
|
||||||
testLess("a", "B")
|
|
||||||
testLess("A", "b")
|
|
||||||
testLess("A", "ab")
|
|
||||||
|
|
||||||
testLess("abc", "bcd")
|
|
||||||
testLess("a-1-a", "a-1-b")
|
|
||||||
testLess("2", "12")
|
|
||||||
|
|
||||||
testLess("cafe", "café")
|
|
||||||
testLess("café", "caff")
|
|
||||||
|
|
||||||
testLess("A-2", "A-11")
|
|
||||||
testLess("0.txt", "1.txt")
|
|
||||||
}
|
}
|
||||||
|
32
modules/cache/cache.go
vendored
32
modules/cache/cache.go
vendored
@ -4,7 +4,6 @@
|
|||||||
package cache
|
package cache
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -36,37 +35,6 @@ func Init() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
|
||||||
testCacheKey = "DefaultCache.TestKey"
|
|
||||||
SlowCacheThreshold = 100 * time.Microsecond
|
|
||||||
)
|
|
||||||
|
|
||||||
func Test() (time.Duration, error) {
|
|
||||||
if defaultCache == nil {
|
|
||||||
return 0, fmt.Errorf("default cache not initialized")
|
|
||||||
}
|
|
||||||
|
|
||||||
testData := fmt.Sprintf("%x", make([]byte, 500))
|
|
||||||
|
|
||||||
start := time.Now()
|
|
||||||
|
|
||||||
if err := defaultCache.Delete(testCacheKey); err != nil {
|
|
||||||
return 0, fmt.Errorf("expect cache to delete data based on key if exist but got: %w", err)
|
|
||||||
}
|
|
||||||
if err := defaultCache.Put(testCacheKey, testData, 10); err != nil {
|
|
||||||
return 0, fmt.Errorf("expect cache to store data but got: %w", err)
|
|
||||||
}
|
|
||||||
testVal, hit := defaultCache.Get(testCacheKey)
|
|
||||||
if !hit {
|
|
||||||
return 0, fmt.Errorf("expect cache hit but got none")
|
|
||||||
}
|
|
||||||
if testVal != testData {
|
|
||||||
return 0, fmt.Errorf("expect cache to return same value as stored but got other")
|
|
||||||
}
|
|
||||||
|
|
||||||
return time.Since(start), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetCache returns the currently configured cache
|
// GetCache returns the currently configured cache
|
||||||
func GetCache() StringCache {
|
func GetCache() StringCache {
|
||||||
return defaultCache
|
return defaultCache
|
||||||
|
12
modules/cache/cache_test.go
vendored
12
modules/cache/cache_test.go
vendored
@ -34,18 +34,6 @@ func TestNewContext(t *testing.T) {
|
|||||||
assert.Nil(t, con)
|
assert.Nil(t, con)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestTest(t *testing.T) {
|
|
||||||
defaultCache = nil
|
|
||||||
_, err := Test()
|
|
||||||
assert.Error(t, err)
|
|
||||||
|
|
||||||
createTestCache()
|
|
||||||
elapsed, err := Test()
|
|
||||||
assert.NoError(t, err)
|
|
||||||
// mem cache should take from 300ns up to 1ms on modern hardware ...
|
|
||||||
assert.Less(t, elapsed, SlowCacheThreshold)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestGetCache(t *testing.T) {
|
func TestGetCache(t *testing.T) {
|
||||||
createTestCache()
|
createTestCache()
|
||||||
|
|
||||||
|
@ -144,6 +144,20 @@ func CustomLinkURLSchemes(schemes []string) {
|
|||||||
common.LinkRegex, _ = xurls.StrictMatchingScheme(strings.Join(withAuth, "|"))
|
common.LinkRegex, _ = xurls.StrictMatchingScheme(strings.Join(withAuth, "|"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IsSameDomain checks if given url string has the same hostname as current Gitea instance
|
||||||
|
func IsSameDomain(s string) bool {
|
||||||
|
if strings.HasPrefix(s, "/") {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
if uapp, err := url.Parse(setting.AppURL); err == nil {
|
||||||
|
if u, err := url.Parse(s); err == nil {
|
||||||
|
return u.Host == uapp.Host
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
type postProcessError struct {
|
type postProcessError struct {
|
||||||
context string
|
context string
|
||||||
err error
|
err error
|
||||||
@ -415,7 +429,7 @@ func visitNode(ctx *RenderContext, procs []processor, node *html.Node) *html.Nod
|
|||||||
// We ignore code and pre.
|
// We ignore code and pre.
|
||||||
switch node.Type {
|
switch node.Type {
|
||||||
case html.TextNode:
|
case html.TextNode:
|
||||||
processTextNodes(ctx, procs, node)
|
textNode(ctx, procs, node)
|
||||||
case html.ElementNode:
|
case html.ElementNode:
|
||||||
if node.Data == "img" {
|
if node.Data == "img" {
|
||||||
next := node.NextSibling
|
next := node.NextSibling
|
||||||
@ -451,16 +465,15 @@ func visitNode(ctx *RenderContext, procs []processor, node *html.Node) *html.Nod
|
|||||||
for n := node.FirstChild; n != nil; {
|
for n := node.FirstChild; n != nil; {
|
||||||
n = visitNode(ctx, procs, n)
|
n = visitNode(ctx, procs, n)
|
||||||
}
|
}
|
||||||
default:
|
|
||||||
}
|
}
|
||||||
return node.NextSibling
|
return node.NextSibling
|
||||||
}
|
}
|
||||||
|
|
||||||
// processTextNodes runs the passed node through various processors, in order to handle
|
// textNode runs the passed node through various processors, in order to handle
|
||||||
// all kinds of special links handled by the post-processing.
|
// all kinds of special links handled by the post-processing.
|
||||||
func processTextNodes(ctx *RenderContext, procs []processor, node *html.Node) {
|
func textNode(ctx *RenderContext, procs []processor, node *html.Node) {
|
||||||
for _, p := range procs {
|
for _, processor := range procs {
|
||||||
p(ctx, node)
|
processor(ctx, node)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -926,11 +939,14 @@ func issueIndexPatternProcessor(ctx *RenderContext, node *html.Node) {
|
|||||||
// Path determines the type of link that will be rendered. It's unknown at this point whether
|
// Path determines the type of link that will be rendered. It's unknown at this point whether
|
||||||
// the linked item is actually a PR or an issue. Luckily it's of no real consequence because
|
// the linked item is actually a PR or an issue. Luckily it's of no real consequence because
|
||||||
// Gitea will redirect on click as appropriate.
|
// Gitea will redirect on click as appropriate.
|
||||||
issuePath := util.Iif(ref.IsPull, "pulls", "issues")
|
path := "issues"
|
||||||
|
if ref.IsPull {
|
||||||
|
path = "pulls"
|
||||||
|
}
|
||||||
if ref.Owner == "" {
|
if ref.Owner == "" {
|
||||||
link = createLink(util.URLJoin(ctx.Links.Prefix(), ctx.Metas["user"], ctx.Metas["repo"], issuePath, ref.Issue), reftext, "ref-issue")
|
link = createLink(util.URLJoin(ctx.Links.Prefix(), ctx.Metas["user"], ctx.Metas["repo"], path, ref.Issue), reftext, "ref-issue")
|
||||||
} else {
|
} else {
|
||||||
link = createLink(util.URLJoin(ctx.Links.Prefix(), ref.Owner, ref.Name, issuePath, ref.Issue), reftext, "ref-issue")
|
link = createLink(util.URLJoin(ctx.Links.Prefix(), ref.Owner, ref.Name, path, ref.Issue), reftext, "ref-issue")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1191,7 +1207,7 @@ func hashCurrentPatternProcessor(ctx *RenderContext, node *html.Node) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
ctx.AddCancel(func() {
|
ctx.AddCancel(func() {
|
||||||
_ = closer.Close()
|
closer.Close()
|
||||||
ctx.GitRepo = nil
|
ctx.GitRepo = nil
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -144,6 +144,17 @@ func TestRender_CrossReferences(t *testing.T) {
|
|||||||
`<p><a href="`+inputURL+`" rel="nofollow"><code>0123456789/foo.txt (L2-L3)</code></a></p>`)
|
`<p><a href="`+inputURL+`" rel="nofollow"><code>0123456789/foo.txt (L2-L3)</code></a></p>`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestMisc_IsSameDomain(t *testing.T) {
|
||||||
|
setting.AppURL = markup.TestAppURL
|
||||||
|
|
||||||
|
sha := "b6dd6210eaebc915fd5be5579c58cce4da2e2579"
|
||||||
|
commit := util.URLJoin(markup.TestRepoURL, "commit", sha)
|
||||||
|
|
||||||
|
assert.True(t, markup.IsSameDomain(commit))
|
||||||
|
assert.False(t, markup.IsSameDomain("http://google.com/ncr"))
|
||||||
|
assert.False(t, markup.IsSameDomain("favicon.ico"))
|
||||||
|
}
|
||||||
|
|
||||||
func TestRender_links(t *testing.T) {
|
func TestRender_links(t *testing.T) {
|
||||||
setting.AppURL = markup.TestAppURL
|
setting.AppURL = markup.TestAppURL
|
||||||
|
|
||||||
|
@ -86,10 +86,10 @@ type RenderContext struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Links struct {
|
type Links struct {
|
||||||
AbsolutePrefix bool // add absolute URL prefix to auto-resolved links like "#issue", but not for pre-provided links and medias
|
AbsolutePrefix bool
|
||||||
Base string // base prefix for pre-provided links and medias (images, videos)
|
Base string
|
||||||
BranchPath string // actually it is the ref path, eg: "branch/features/feat-12", "tag/v1.0"
|
BranchPath string
|
||||||
TreePath string // the dir of the file, eg: "doc" if the file "doc/CHANGE.md" is being rendered
|
TreePath string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *Links) Prefix() string {
|
func (l *Links) Prefix() string {
|
||||||
|
@ -25,8 +25,7 @@ type MarkupOption struct {
|
|||||||
//
|
//
|
||||||
// in: body
|
// in: body
|
||||||
Mode string
|
Mode string
|
||||||
// URL path for rendering issue, media and file links
|
// Context to render
|
||||||
// Expected format: /subpath/{user}/{repo}/src/{branch, commit, tag}/{identifier/path}/{file/dir}
|
|
||||||
//
|
//
|
||||||
// in: body
|
// in: body
|
||||||
Context string
|
Context string
|
||||||
@ -54,8 +53,7 @@ type MarkdownOption struct {
|
|||||||
//
|
//
|
||||||
// in: body
|
// in: body
|
||||||
Mode string
|
Mode string
|
||||||
// URL path for rendering issue, media and file links
|
// Context to render
|
||||||
// Expected format: /subpath/{user}/{repo}/src/{branch, commit, tag}/{identifier/path}/{file/dir}
|
|
||||||
//
|
//
|
||||||
// in: body
|
// in: body
|
||||||
Context string
|
Context string
|
||||||
|
@ -194,9 +194,8 @@ func (r *Route) normalizeRequestPath(resp http.ResponseWriter, req *http.Request
|
|||||||
normalizedPath = buf.String()
|
normalizedPath = buf.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the config tells Gitea to use a sub-url path directly without reverse proxy,
|
// if the config tells Gitea to use a sub-url path directly without reverse proxy,
|
||||||
// then we need to remove the sub-url path from the request URL path.
|
// then we need to remove the sub-url path from the request URL path
|
||||||
// But "/v2" is special for OCI container registry, it should always be in the root of the site.
|
|
||||||
if setting.UseSubURLPath {
|
if setting.UseSubURLPath {
|
||||||
remainingPath, ok := strings.CutPrefix(normalizedPath, setting.AppSubURL+"/")
|
remainingPath, ok := strings.CutPrefix(normalizedPath, setting.AppSubURL+"/")
|
||||||
if ok {
|
if ok {
|
||||||
|
@ -215,7 +215,6 @@ func TestRouteNormalizePath(t *testing.T) {
|
|||||||
testPath("/sub-path/", paths{EscapedPath: "/", RawPath: "/", Path: "/"})
|
testPath("/sub-path/", paths{EscapedPath: "/", RawPath: "/", Path: "/"})
|
||||||
testPath("/sub-path//a/b///", paths{EscapedPath: "/a/b", RawPath: "/a/b", Path: "/a/b"})
|
testPath("/sub-path//a/b///", paths{EscapedPath: "/a/b", RawPath: "/a/b", Path: "/a/b"})
|
||||||
testPath("/sub-path/%2f/", paths{EscapedPath: "/%2f", RawPath: "/%2f", Path: "//"})
|
testPath("/sub-path/%2f/", paths{EscapedPath: "/%2f", RawPath: "/%2f", Path: "//"})
|
||||||
// "/v2" is special for OCI container registry, it should always be in the root of the site
|
|
||||||
testPath("/v2", paths{EscapedPath: "/v2", RawPath: "/v2", Path: "/v2"})
|
testPath("/v2", paths{EscapedPath: "/v2", RawPath: "/v2", Path: "/v2"})
|
||||||
testPath("/v2/", paths{EscapedPath: "/v2", RawPath: "/v2", Path: "/v2"})
|
testPath("/v2/", paths{EscapedPath: "/v2", RawPath: "/v2", Path: "/v2"})
|
||||||
testPath("/v2/%2f", paths{EscapedPath: "/v2/%2f", RawPath: "/v2/%2f", Path: "/v2//"})
|
testPath("/v2/%2f", paths{EscapedPath: "/v2/%2f", RawPath: "/v2/%2f", Path: "/v2//"})
|
||||||
|
@ -1,47 +0,0 @@
|
|||||||
# Compiled binaries
|
|
||||||
*.o
|
|
||||||
*.bin
|
|
||||||
*.elf
|
|
||||||
*.hex
|
|
||||||
*.map
|
|
||||||
*.out
|
|
||||||
*.obj
|
|
||||||
|
|
||||||
# Trash
|
|
||||||
*.bak
|
|
||||||
thumbs.db
|
|
||||||
*.~*
|
|
||||||
|
|
||||||
# IAR Settings
|
|
||||||
**/settings/*.crun
|
|
||||||
**/settings/*.dbgdt
|
|
||||||
**/settings/*.cspy
|
|
||||||
**/settings/*.cspy.*
|
|
||||||
**/settings/*.xcl
|
|
||||||
**/settings/*.dni
|
|
||||||
**/settings/*.wsdt
|
|
||||||
**/settings/*.wspos
|
|
||||||
|
|
||||||
# IAR Debug Exe
|
|
||||||
**/Exe/*.sim
|
|
||||||
|
|
||||||
# IAR Debug Obj
|
|
||||||
**/Obj/*.pbd
|
|
||||||
**/Obj/*.pbd.*
|
|
||||||
**/Obj/*.pbi
|
|
||||||
**/Obj/*.pbi.*
|
|
||||||
|
|
||||||
# IAR project "Debug" directory
|
|
||||||
Debug/
|
|
||||||
|
|
||||||
# IAR project "Release" directory
|
|
||||||
Release/
|
|
||||||
|
|
||||||
# IAR project settings directory
|
|
||||||
settings/
|
|
||||||
|
|
||||||
# IAR backup files
|
|
||||||
Backup*
|
|
||||||
|
|
||||||
# IAR .dep files
|
|
||||||
*.dep
|
|
@ -42,3 +42,10 @@ fastlane/report.xml
|
|||||||
fastlane/Preview.html
|
fastlane/Preview.html
|
||||||
fastlane/screenshots/**/*.png
|
fastlane/screenshots/**/*.png
|
||||||
fastlane/test_output
|
fastlane/test_output
|
||||||
|
|
||||||
|
# Code Injection
|
||||||
|
#
|
||||||
|
# After new code Injection tools there's a generated folder /iOSInjectionProject
|
||||||
|
# https://github.com/johnno1962/injectionforxcode
|
||||||
|
|
||||||
|
iOSInjectionProject/
|
||||||
|
@ -35,3 +35,6 @@ override.tf.json
|
|||||||
# Ignore CLI configuration files
|
# Ignore CLI configuration files
|
||||||
.terraformrc
|
.terraformrc
|
||||||
terraform.rc
|
terraform.rc
|
||||||
|
|
||||||
|
# Ignore hcl file
|
||||||
|
.terraform.lock.hcl
|
||||||
|
@ -93,7 +93,6 @@ remove_all = Remove All
|
|||||||
remove_label_str = Remove item "%s"
|
remove_label_str = Remove item "%s"
|
||||||
edit = Edit
|
edit = Edit
|
||||||
view = View
|
view = View
|
||||||
test = Test
|
|
||||||
|
|
||||||
enabled = Enabled
|
enabled = Enabled
|
||||||
disabled = Disabled
|
disabled = Disabled
|
||||||
@ -3226,10 +3225,6 @@ config.cache_adapter = Cache Adapter
|
|||||||
config.cache_interval = Cache Interval
|
config.cache_interval = Cache Interval
|
||||||
config.cache_conn = Cache Connection
|
config.cache_conn = Cache Connection
|
||||||
config.cache_item_ttl = Cache Item TTL
|
config.cache_item_ttl = Cache Item TTL
|
||||||
config.cache_test = Test Cache
|
|
||||||
config.cache_test_failed = Failed to probe the cache: %v.
|
|
||||||
config.cache_test_slow = Cache test successful, but response is slow: %s.
|
|
||||||
config.cache_test_succeeded = Cache test successful, got a response in %s.
|
|
||||||
|
|
||||||
config.session_config = Session Configuration
|
config.session_config = Session Configuration
|
||||||
config.session_provider = Session Provider
|
config.session_provider = Session Provider
|
||||||
|
@ -1238,7 +1238,6 @@ file_view_rendered=レンダリング表示
|
|||||||
file_view_raw=Rawデータを見る
|
file_view_raw=Rawデータを見る
|
||||||
file_permalink=パーマリンク
|
file_permalink=パーマリンク
|
||||||
file_too_large=このファイルは大きすぎるため、表示できません。
|
file_too_large=このファイルは大きすぎるため、表示できません。
|
||||||
file_is_empty=ファイルは空です。
|
|
||||||
code_preview_line_from_to=%[1]d 行目から %[2]d 行目 in %[3]s
|
code_preview_line_from_to=%[1]d 行目から %[2]d 行目 in %[3]s
|
||||||
code_preview_line_in=%[1]d 行目 in %[2]s
|
code_preview_line_in=%[1]d 行目 in %[2]s
|
||||||
invisible_runes_header=このファイルには不可視のUnicode文字が含まれています
|
invisible_runes_header=このファイルには不可視のUnicode文字が含まれています
|
||||||
@ -1443,7 +1442,6 @@ issues.new.clear_assignees=担当者をクリア
|
|||||||
issues.new.no_assignees=担当者なし
|
issues.new.no_assignees=担当者なし
|
||||||
issues.new.no_reviewers=レビューアなし
|
issues.new.no_reviewers=レビューアなし
|
||||||
issues.new.blocked_user=リポジトリのオーナーがあなたをブロックしているため、イシューを作成できません。
|
issues.new.blocked_user=リポジトリのオーナーがあなたをブロックしているため、イシューを作成できません。
|
||||||
issues.edit.already_changed=イシューの変更を保存できません。 他のユーザーによって内容がすでに変更されているようです。 変更を上書きしないようにするため、ページを更新してからもう一度編集してください
|
|
||||||
issues.edit.blocked_user=投稿者またはリポジトリのオーナーがあなたをブロックしているため、内容を編集できません。
|
issues.edit.blocked_user=投稿者またはリポジトリのオーナーがあなたをブロックしているため、内容を編集できません。
|
||||||
issues.choose.get_started=始める
|
issues.choose.get_started=始める
|
||||||
issues.choose.open_external_link=オープン
|
issues.choose.open_external_link=オープン
|
||||||
@ -1759,7 +1757,6 @@ compare.compare_head=比較
|
|||||||
pulls.desc=プルリクエストとコードレビューの有効化。
|
pulls.desc=プルリクエストとコードレビューの有効化。
|
||||||
pulls.new=新しいプルリクエスト
|
pulls.new=新しいプルリクエスト
|
||||||
pulls.new.blocked_user=リポジトリのオーナーがあなたをブロックしているため、プルリクエストを作成できません。
|
pulls.new.blocked_user=リポジトリのオーナーがあなたをブロックしているため、プルリクエストを作成できません。
|
||||||
pulls.edit.already_changed=プルリクエストの変更を保存できません。 他のユーザーによって内容がすでに変更されているようです。 変更を上書きしないようにするため、ページを更新してからもう一度編集してください
|
|
||||||
pulls.view=プルリクエストを表示
|
pulls.view=プルリクエストを表示
|
||||||
pulls.compare_changes=新規プルリクエスト
|
pulls.compare_changes=新規プルリクエスト
|
||||||
pulls.allow_edits_from_maintainers=メンテナーからの編集を許可する
|
pulls.allow_edits_from_maintainers=メンテナーからの編集を許可する
|
||||||
@ -1905,7 +1902,6 @@ pulls.recently_pushed_new_branches=%[2]s 、あなたはブランチ <strong>%[1
|
|||||||
|
|
||||||
pull.deleted_branch=(削除済み):%s
|
pull.deleted_branch=(削除済み):%s
|
||||||
|
|
||||||
comments.edit.already_changed=コメントの変更を保存できません。 他のユーザーによって内容がすでに変更されているようです。 変更を上書きしないようにするため、ページを更新してからもう一度編集してください
|
|
||||||
|
|
||||||
milestones.new=新しいマイルストーン
|
milestones.new=新しいマイルストーン
|
||||||
milestones.closed=%s にクローズ
|
milestones.closed=%s にクローズ
|
||||||
|
@ -588,8 +588,6 @@ func CommonRoutes() *web.Route {
|
|||||||
r.Get("/prerelease_specs.4.8.gz", rubygems.EnumeratePackagesPreRelease)
|
r.Get("/prerelease_specs.4.8.gz", rubygems.EnumeratePackagesPreRelease)
|
||||||
r.Get("/quick/Marshal.4.8/{filename}", rubygems.ServePackageSpecification)
|
r.Get("/quick/Marshal.4.8/{filename}", rubygems.ServePackageSpecification)
|
||||||
r.Get("/gems/{filename}", rubygems.DownloadPackageFile)
|
r.Get("/gems/{filename}", rubygems.DownloadPackageFile)
|
||||||
r.Get("/info/{packagename}", rubygems.GetPackageInfo)
|
|
||||||
r.Get("/versions", rubygems.GetAllPackagesVersions)
|
|
||||||
r.Group("/api/v1/gems", func() {
|
r.Group("/api/v1/gems", func() {
|
||||||
r.Post("/", rubygems.UploadPackageFile)
|
r.Post("/", rubygems.UploadPackageFile)
|
||||||
r.Delete("/yank", rubygems.DeletePackage)
|
r.Delete("/yank", rubygems.DeletePackage)
|
||||||
|
@ -6,7 +6,6 @@ package rubygems
|
|||||||
import (
|
import (
|
||||||
"compress/gzip"
|
"compress/gzip"
|
||||||
"compress/zlib"
|
"compress/zlib"
|
||||||
"crypto/md5"
|
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
@ -228,7 +227,12 @@ func UploadPackageFile(ctx *context.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
filename := makeGemFullFileName(rp.Name, rp.Version, rp.Metadata.Platform)
|
var filename string
|
||||||
|
if rp.Metadata.Platform == "" || rp.Metadata.Platform == "ruby" {
|
||||||
|
filename = strings.ToLower(fmt.Sprintf("%s-%s.gem", rp.Name, rp.Version))
|
||||||
|
} else {
|
||||||
|
filename = strings.ToLower(fmt.Sprintf("%s-%s-%s.gem", rp.Name, rp.Version, rp.Metadata.Platform))
|
||||||
|
}
|
||||||
|
|
||||||
_, _, err = packages_service.CreatePackageAndAddFile(
|
_, _, err = packages_service.CreatePackageAndAddFile(
|
||||||
ctx,
|
ctx,
|
||||||
@ -296,136 +300,6 @@ func DeletePackage(ctx *context.Context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetPackageInfo returns a custom text based format for the single rubygem with a line for each version of the rubygem
|
|
||||||
// ref: https://guides.rubygems.org/rubygems-org-compact-index-api/
|
|
||||||
func GetPackageInfo(ctx *context.Context) {
|
|
||||||
packageName := ctx.Params("packagename")
|
|
||||||
versions, err := packages_model.GetVersionsByPackageName(ctx, ctx.Package.Owner.ID, packages_model.TypeRubyGems, packageName)
|
|
||||||
if err != nil {
|
|
||||||
apiError(ctx, http.StatusInternalServerError, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if len(versions) == 0 {
|
|
||||||
apiError(ctx, http.StatusNotFound, nil)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
infoContent, err := makePackageInfo(ctx, versions)
|
|
||||||
if err != nil {
|
|
||||||
apiError(ctx, http.StatusInternalServerError, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
ctx.PlainText(http.StatusOK, infoContent)
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetAllPackagesVersions returns a custom text based format containing information about all versions of all rubygems.
|
|
||||||
// ref: https://guides.rubygems.org/rubygems-org-compact-index-api/
|
|
||||||
func GetAllPackagesVersions(ctx *context.Context) {
|
|
||||||
packages, err := packages_model.GetPackagesByType(ctx, ctx.Package.Owner.ID, packages_model.TypeRubyGems)
|
|
||||||
if err != nil {
|
|
||||||
apiError(ctx, http.StatusInternalServerError, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
out := &strings.Builder{}
|
|
||||||
out.WriteString("---\n")
|
|
||||||
for _, pkg := range packages {
|
|
||||||
versions, err := packages_model.GetVersionsByPackageName(ctx, ctx.Package.Owner.ID, packages_model.TypeRubyGems, pkg.Name)
|
|
||||||
if err != nil {
|
|
||||||
apiError(ctx, http.StatusInternalServerError, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if len(versions) == 0 {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
info, err := makePackageInfo(ctx, versions)
|
|
||||||
if err != nil {
|
|
||||||
apiError(ctx, http.StatusInternalServerError, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// format: RUBYGEM [-]VERSION_PLATFORM[,VERSION_PLATFORM],...] MD5
|
|
||||||
_, _ = fmt.Fprintf(out, "%s ", pkg.Name)
|
|
||||||
for i, v := range versions {
|
|
||||||
sep := util.Iif(i == len(versions)-1, "", ",")
|
|
||||||
_, _ = fmt.Fprintf(out, "%s%s", v.Version, sep)
|
|
||||||
}
|
|
||||||
_, _ = fmt.Fprintf(out, " %x\n", md5.Sum([]byte(info)))
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx.PlainText(http.StatusOK, out.String())
|
|
||||||
}
|
|
||||||
|
|
||||||
func writePackageVersionRequirements(prefix string, reqs []rubygems_module.VersionRequirement, out *strings.Builder) {
|
|
||||||
out.WriteString(prefix)
|
|
||||||
if len(reqs) == 0 {
|
|
||||||
reqs = []rubygems_module.VersionRequirement{{Restriction: ">=", Version: "0"}}
|
|
||||||
}
|
|
||||||
for i, req := range reqs {
|
|
||||||
sep := util.Iif(i == 0, "", "&")
|
|
||||||
_, _ = fmt.Fprintf(out, "%s%s %s", sep, req.Restriction, req.Version)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func makePackageVersionDependency(ctx *context.Context, version *packages_model.PackageVersion) (string, error) {
|
|
||||||
// format: VERSION[-PLATFORM] [DEPENDENCY[,DEPENDENCY,...]]|REQUIREMENT[,REQUIREMENT,...]
|
|
||||||
// DEPENDENCY: GEM:CONSTRAINT[&CONSTRAINT]
|
|
||||||
// REQUIREMENT: KEY:VALUE (always contains "checksum")
|
|
||||||
pd, err := packages_model.GetPackageDescriptor(ctx, version)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
metadata := pd.Metadata.(*rubygems_module.Metadata)
|
|
||||||
fullFilename := makeGemFullFileName(pd.Package.Name, version.Version, metadata.Platform)
|
|
||||||
file, err := packages_model.GetFileForVersionByName(ctx, version.ID, fullFilename, "")
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
blob, err := packages_model.GetBlobByID(ctx, file.BlobID)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
buf := &strings.Builder{}
|
|
||||||
buf.WriteString(version.Version)
|
|
||||||
buf.WriteByte(' ')
|
|
||||||
for i, dep := range metadata.RuntimeDependencies {
|
|
||||||
sep := util.Iif(i == 0, "", ",")
|
|
||||||
writePackageVersionRequirements(fmt.Sprintf("%s%s:", sep, dep.Name), dep.Version, buf)
|
|
||||||
}
|
|
||||||
_, _ = fmt.Fprintf(buf, "|checksum:%s", blob.HashSHA256)
|
|
||||||
if len(metadata.RequiredRubyVersion) != 0 {
|
|
||||||
writePackageVersionRequirements(",ruby:", metadata.RequiredRubyVersion, buf)
|
|
||||||
}
|
|
||||||
if len(metadata.RequiredRubygemsVersion) != 0 {
|
|
||||||
writePackageVersionRequirements(",rubygems:", metadata.RequiredRubygemsVersion, buf)
|
|
||||||
}
|
|
||||||
return buf.String(), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func makePackageInfo(ctx *context.Context, versions []*packages_model.PackageVersion) (string, error) {
|
|
||||||
ret := "---\n"
|
|
||||||
for _, v := range versions {
|
|
||||||
dep, err := makePackageVersionDependency(ctx, v)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
ret += dep + "\n"
|
|
||||||
}
|
|
||||||
return ret, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func makeGemFullFileName(gemName, version, platform string) string {
|
|
||||||
var basename string
|
|
||||||
if platform == "" || platform == "ruby" {
|
|
||||||
basename = fmt.Sprintf("%s-%s", gemName, version)
|
|
||||||
} else {
|
|
||||||
basename = fmt.Sprintf("%s-%s-%s", gemName, version, platform)
|
|
||||||
}
|
|
||||||
return strings.ToLower(basename) + ".gem"
|
|
||||||
}
|
|
||||||
|
|
||||||
func getVersionsByFilename(ctx *context.Context, filename string) ([]*packages_model.PackageVersion, error) {
|
func getVersionsByFilename(ctx *context.Context, filename string) ([]*packages_model.PackageVersion, error) {
|
||||||
pvs, _, err := packages_model.SearchVersions(ctx, &packages_model.PackageSearchOptions{
|
pvs, _, err := packages_model.SearchVersions(ctx, &packages_model.PackageSearchOptions{
|
||||||
OwnerID: ctx.Package.Owner.ID,
|
OwnerID: ctx.Package.Owner.ID,
|
||||||
|
@ -7,7 +7,6 @@ import (
|
|||||||
go_context "context"
|
go_context "context"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"path"
|
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@ -20,40 +19,36 @@ import (
|
|||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
const AppURL = "http://localhost:3000/"
|
const (
|
||||||
|
AppURL = "http://localhost:3000/"
|
||||||
|
Repo = "gogits/gogs"
|
||||||
|
FullURL = AppURL + Repo + "/"
|
||||||
|
)
|
||||||
|
|
||||||
func testRenderMarkup(t *testing.T, mode string, wiki bool, filePath, text, expectedBody string, expectedCode int) {
|
func testRenderMarkup(t *testing.T, mode, filePath, text, responseBody string, responseCode int) {
|
||||||
setting.AppURL = AppURL
|
setting.AppURL = AppURL
|
||||||
context := "/gogits/gogs"
|
|
||||||
if !wiki {
|
|
||||||
context += path.Join("/src/branch/main", path.Dir(filePath))
|
|
||||||
}
|
|
||||||
options := api.MarkupOption{
|
options := api.MarkupOption{
|
||||||
Mode: mode,
|
Mode: mode,
|
||||||
Text: text,
|
Text: text,
|
||||||
Context: context,
|
Context: Repo,
|
||||||
Wiki: wiki,
|
Wiki: true,
|
||||||
FilePath: filePath,
|
FilePath: filePath,
|
||||||
}
|
}
|
||||||
ctx, resp := contexttest.MockAPIContext(t, "POST /api/v1/markup")
|
ctx, resp := contexttest.MockAPIContext(t, "POST /api/v1/markup")
|
||||||
web.SetForm(ctx, &options)
|
web.SetForm(ctx, &options)
|
||||||
Markup(ctx)
|
Markup(ctx)
|
||||||
assert.Equal(t, expectedBody, resp.Body.String())
|
assert.Equal(t, responseBody, resp.Body.String())
|
||||||
assert.Equal(t, expectedCode, resp.Code)
|
assert.Equal(t, responseCode, resp.Code)
|
||||||
resp.Body.Reset()
|
resp.Body.Reset()
|
||||||
}
|
}
|
||||||
|
|
||||||
func testRenderMarkdown(t *testing.T, mode string, wiki bool, text, responseBody string, responseCode int) {
|
func testRenderMarkdown(t *testing.T, mode, text, responseBody string, responseCode int) {
|
||||||
setting.AppURL = AppURL
|
setting.AppURL = AppURL
|
||||||
context := "/gogits/gogs"
|
|
||||||
if !wiki {
|
|
||||||
context += "/src/branch/main"
|
|
||||||
}
|
|
||||||
options := api.MarkdownOption{
|
options := api.MarkdownOption{
|
||||||
Mode: mode,
|
Mode: mode,
|
||||||
Text: text,
|
Text: text,
|
||||||
Context: context,
|
Context: Repo,
|
||||||
Wiki: wiki,
|
Wiki: true,
|
||||||
}
|
}
|
||||||
ctx, resp := contexttest.MockAPIContext(t, "POST /api/v1/markdown")
|
ctx, resp := contexttest.MockAPIContext(t, "POST /api/v1/markdown")
|
||||||
web.SetForm(ctx, &options)
|
web.SetForm(ctx, &options)
|
||||||
@ -70,7 +65,7 @@ func TestAPI_RenderGFM(t *testing.T) {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
testCasesWiki := []string{
|
testCasesCommon := []string{
|
||||||
// dear imgui wiki markdown extract: special wiki syntax
|
// dear imgui wiki markdown extract: special wiki syntax
|
||||||
`Wiki! Enjoy :)
|
`Wiki! Enjoy :)
|
||||||
- [[Links, Language bindings, Engine bindings|Links]]
|
- [[Links, Language bindings, Engine bindings|Links]]
|
||||||
@ -79,20 +74,20 @@ func TestAPI_RenderGFM(t *testing.T) {
|
|||||||
// rendered
|
// rendered
|
||||||
`<p>Wiki! Enjoy :)</p>
|
`<p>Wiki! Enjoy :)</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="http://localhost:3000/gogits/gogs/wiki/Links" rel="nofollow">Links, Language bindings, Engine bindings</a></li>
|
<li><a href="` + FullURL + `wiki/Links" rel="nofollow">Links, Language bindings, Engine bindings</a></li>
|
||||||
<li><a href="http://localhost:3000/gogits/gogs/wiki/Tips" rel="nofollow">Tips</a></li>
|
<li><a href="` + FullURL + `wiki/Tips" rel="nofollow">Tips</a></li>
|
||||||
<li>Bezier widget (by <a href="http://localhost:3000/r-lyeh" rel="nofollow">@r-lyeh</a>) <a href="https://github.com/ocornut/imgui/issues/786" rel="nofollow">https://github.com/ocornut/imgui/issues/786</a></li>
|
<li>Bezier widget (by <a href="` + AppURL + `r-lyeh" rel="nofollow">@r-lyeh</a>) <a href="https://github.com/ocornut/imgui/issues/786" rel="nofollow">https://github.com/ocornut/imgui/issues/786</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
`,
|
`,
|
||||||
// Guard wiki sidebar: special syntax
|
// Guard wiki sidebar: special syntax
|
||||||
`[[Guardfile-DSL / Configuring-Guard|Guardfile-DSL---Configuring-Guard]]`,
|
`[[Guardfile-DSL / Configuring-Guard|Guardfile-DSL---Configuring-Guard]]`,
|
||||||
// rendered
|
// rendered
|
||||||
`<p><a href="http://localhost:3000/gogits/gogs/wiki/Guardfile-DSL---Configuring-Guard" rel="nofollow">Guardfile-DSL / Configuring-Guard</a></p>
|
`<p><a href="` + FullURL + `wiki/Guardfile-DSL---Configuring-Guard" rel="nofollow">Guardfile-DSL / Configuring-Guard</a></p>
|
||||||
`,
|
`,
|
||||||
// special syntax
|
// special syntax
|
||||||
`[[Name|Link]]`,
|
`[[Name|Link]]`,
|
||||||
// rendered
|
// rendered
|
||||||
`<p><a href="http://localhost:3000/gogits/gogs/wiki/Link" rel="nofollow">Name</a></p>
|
`<p><a href="` + FullURL + `wiki/Link" rel="nofollow">Name</a></p>
|
||||||
`,
|
`,
|
||||||
// empty
|
// empty
|
||||||
``,
|
``,
|
||||||
@ -100,7 +95,7 @@ func TestAPI_RenderGFM(t *testing.T) {
|
|||||||
``,
|
``,
|
||||||
}
|
}
|
||||||
|
|
||||||
testCasesWikiDocument := []string{
|
testCasesDocument := []string{
|
||||||
// wine-staging wiki home extract: special wiki syntax, images
|
// wine-staging wiki home extract: special wiki syntax, images
|
||||||
`## What is Wine Staging?
|
`## What is Wine Staging?
|
||||||
**Wine Staging** on website [wine-staging.com](http://wine-staging.com).
|
**Wine Staging** on website [wine-staging.com](http://wine-staging.com).
|
||||||
@ -116,48 +111,31 @@ Here are some links to the most important topics. You can find the full list of
|
|||||||
<p><strong>Wine Staging</strong> on website <a href="http://wine-staging.com" rel="nofollow">wine-staging.com</a>.</p>
|
<p><strong>Wine Staging</strong> on website <a href="http://wine-staging.com" rel="nofollow">wine-staging.com</a>.</p>
|
||||||
<h2 id="user-content-quick-links">Quick Links</h2>
|
<h2 id="user-content-quick-links">Quick Links</h2>
|
||||||
<p>Here are some links to the most important topics. You can find the full list of pages at the sidebar.</p>
|
<p>Here are some links to the most important topics. You can find the full list of pages at the sidebar.</p>
|
||||||
<p><a href="http://localhost:3000/gogits/gogs/wiki/Configuration" rel="nofollow">Configuration</a>
|
<p><a href="` + FullURL + `wiki/Configuration" rel="nofollow">Configuration</a>
|
||||||
<a href="http://localhost:3000/gogits/gogs/wiki/raw/images/icon-bug.png" rel="nofollow"><img src="http://localhost:3000/gogits/gogs/wiki/raw/images/icon-bug.png" title="icon-bug.png" alt="images/icon-bug.png"/></a></p>
|
<a href="` + FullURL + `wiki/raw/images/icon-bug.png" rel="nofollow"><img src="` + FullURL + `wiki/raw/images/icon-bug.png" title="icon-bug.png" alt="images/icon-bug.png"/></a></p>
|
||||||
`,
|
`,
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := 0; i < len(testCasesWiki); i += 2 {
|
for i := 0; i < len(testCasesCommon); i += 2 {
|
||||||
text := testCasesWiki[i]
|
text := testCasesCommon[i]
|
||||||
response := testCasesWiki[i+1]
|
response := testCasesCommon[i+1]
|
||||||
testRenderMarkdown(t, "gfm", true, text, response, http.StatusOK)
|
testRenderMarkdown(t, "gfm", text, response, http.StatusOK)
|
||||||
testRenderMarkup(t, "gfm", true, "", text, response, http.StatusOK)
|
testRenderMarkup(t, "gfm", "", text, response, http.StatusOK)
|
||||||
testRenderMarkdown(t, "comment", true, text, response, http.StatusOK)
|
testRenderMarkdown(t, "comment", text, response, http.StatusOK)
|
||||||
testRenderMarkup(t, "comment", true, "", text, response, http.StatusOK)
|
testRenderMarkup(t, "comment", "", text, response, http.StatusOK)
|
||||||
testRenderMarkup(t, "file", true, "path/test.md", text, response, http.StatusOK)
|
testRenderMarkup(t, "file", "path/test.md", text, response, http.StatusOK)
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := 0; i < len(testCasesWikiDocument); i += 2 {
|
for i := 0; i < len(testCasesDocument); i += 2 {
|
||||||
text := testCasesWikiDocument[i]
|
text := testCasesDocument[i]
|
||||||
response := testCasesWikiDocument[i+1]
|
response := testCasesDocument[i+1]
|
||||||
testRenderMarkdown(t, "gfm", true, text, response, http.StatusOK)
|
testRenderMarkdown(t, "gfm", text, response, http.StatusOK)
|
||||||
testRenderMarkup(t, "gfm", true, "", text, response, http.StatusOK)
|
testRenderMarkup(t, "gfm", "", text, response, http.StatusOK)
|
||||||
testRenderMarkup(t, "file", true, "path/test.md", text, response, http.StatusOK)
|
testRenderMarkup(t, "file", "path/test.md", text, response, http.StatusOK)
|
||||||
}
|
}
|
||||||
|
|
||||||
input := "[Link](test.md)\n![Image](image.png)"
|
testRenderMarkup(t, "file", "path/test.unknown", "## Test", "Unsupported render extension: .unknown\n", http.StatusUnprocessableEntity)
|
||||||
testRenderMarkdown(t, "gfm", false, input, `<p><a href="http://localhost:3000/gogits/gogs/src/branch/main/test.md" rel="nofollow">Link</a>
|
testRenderMarkup(t, "unknown", "", "## Test", "Unknown mode: unknown\n", http.StatusUnprocessableEntity)
|
||||||
<a href="http://localhost:3000/gogits/gogs/media/branch/main/image.png" target="_blank" rel="nofollow noopener"><img src="http://localhost:3000/gogits/gogs/media/branch/main/image.png" alt="Image"/></a></p>
|
|
||||||
`, http.StatusOK)
|
|
||||||
|
|
||||||
testRenderMarkdown(t, "gfm", false, input, `<p><a href="http://localhost:3000/gogits/gogs/src/branch/main/test.md" rel="nofollow">Link</a>
|
|
||||||
<a href="http://localhost:3000/gogits/gogs/media/branch/main/image.png" target="_blank" rel="nofollow noopener"><img src="http://localhost:3000/gogits/gogs/media/branch/main/image.png" alt="Image"/></a></p>
|
|
||||||
`, http.StatusOK)
|
|
||||||
|
|
||||||
testRenderMarkup(t, "gfm", false, "", input, `<p><a href="http://localhost:3000/gogits/gogs/src/branch/main/test.md" rel="nofollow">Link</a>
|
|
||||||
<a href="http://localhost:3000/gogits/gogs/media/branch/main/image.png" target="_blank" rel="nofollow noopener"><img src="http://localhost:3000/gogits/gogs/media/branch/main/image.png" alt="Image"/></a></p>
|
|
||||||
`, http.StatusOK)
|
|
||||||
|
|
||||||
testRenderMarkup(t, "file", false, "path/new-file.md", input, `<p><a href="http://localhost:3000/gogits/gogs/src/branch/main/path/test.md" rel="nofollow">Link</a>
|
|
||||||
<a href="http://localhost:3000/gogits/gogs/media/branch/main/path/image.png" target="_blank" rel="nofollow noopener"><img src="http://localhost:3000/gogits/gogs/media/branch/main/path/image.png" alt="Image"/></a></p>
|
|
||||||
`, http.StatusOK)
|
|
||||||
|
|
||||||
testRenderMarkup(t, "file", true, "path/test.unknown", "## Test", "Unsupported render extension: .unknown\n", http.StatusUnprocessableEntity)
|
|
||||||
testRenderMarkup(t, "unknown", true, "", "## Test", "Unknown mode: unknown\n", http.StatusUnprocessableEntity)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var simpleCases = []string{
|
var simpleCases = []string{
|
||||||
@ -182,7 +160,7 @@ func TestAPI_RenderSimple(t *testing.T) {
|
|||||||
options := api.MarkdownOption{
|
options := api.MarkdownOption{
|
||||||
Mode: "markdown",
|
Mode: "markdown",
|
||||||
Text: "",
|
Text: "",
|
||||||
Context: "/gogits/gogs",
|
Context: Repo,
|
||||||
}
|
}
|
||||||
ctx, resp := contexttest.MockAPIContext(t, "POST /api/v1/markdown")
|
ctx, resp := contexttest.MockAPIContext(t, "POST /api/v1/markdown")
|
||||||
for i := 0; i < len(simpleCases); i += 2 {
|
for i := 0; i < len(simpleCases); i += 2 {
|
||||||
|
@ -184,7 +184,7 @@ func Search(ctx *context.APIContext) {
|
|||||||
if len(sortOrder) == 0 {
|
if len(sortOrder) == 0 {
|
||||||
sortOrder = "asc"
|
sortOrder = "asc"
|
||||||
}
|
}
|
||||||
if searchModeMap, ok := repo_model.OrderByMap[sortOrder]; ok {
|
if searchModeMap, ok := repo_model.SearchOrderByMap[sortOrder]; ok {
|
||||||
if orderBy, ok := searchModeMap[sortMode]; ok {
|
if orderBy, ok := searchModeMap[sortMode]; ok {
|
||||||
opts.OrderBy = orderBy
|
opts.OrderBy = orderBy
|
||||||
} else {
|
} else {
|
||||||
|
@ -7,67 +7,63 @@ package common
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"path"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
repo_model "code.gitea.io/gitea/models/repo"
|
repo_model "code.gitea.io/gitea/models/repo"
|
||||||
"code.gitea.io/gitea/modules/httplib"
|
|
||||||
"code.gitea.io/gitea/modules/markup"
|
"code.gitea.io/gitea/modules/markup"
|
||||||
"code.gitea.io/gitea/modules/markup/markdown"
|
"code.gitea.io/gitea/modules/markup/markdown"
|
||||||
"code.gitea.io/gitea/modules/setting"
|
"code.gitea.io/gitea/modules/setting"
|
||||||
|
"code.gitea.io/gitea/modules/util"
|
||||||
"code.gitea.io/gitea/services/context"
|
"code.gitea.io/gitea/services/context"
|
||||||
|
|
||||||
|
"mvdan.cc/xurls/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
// RenderMarkup renders markup text for the /markup and /markdown endpoints
|
// RenderMarkup renders markup text for the /markup and /markdown endpoints
|
||||||
func RenderMarkup(ctx *context.Base, repo *context.Repository, mode, text, urlPathContext, filePath string, wiki bool) {
|
func RenderMarkup(ctx *context.Base, repo *context.Repository, mode, text, urlPrefix, filePath string, wiki bool) {
|
||||||
// urlPathContext format is "/subpath/{user}/{repo}/src/{branch, commit, tag}/{identifier/path}/{file/dir}"
|
var markupType string
|
||||||
// filePath is the path of the file to render if the end user is trying to preview a repo file (mode == "file")
|
relativePath := ""
|
||||||
// filePath will be used as RenderContext.RelativePath
|
|
||||||
|
|
||||||
// for example, when previewing file "/gitea/owner/repo/src/branch/features/feat-123/doc/CHANGE.md", then filePath is "doc/CHANGE.md"
|
if len(text) == 0 {
|
||||||
// and the urlPathContext is "/gitea/owner/repo/src/branch/features/feat-123/doc"
|
_, _ = ctx.Write([]byte(""))
|
||||||
|
return
|
||||||
var markupType, relativePath string
|
|
||||||
|
|
||||||
links := markup.Links{AbsolutePrefix: true}
|
|
||||||
if urlPathContext != "" {
|
|
||||||
links.Base = fmt.Sprintf("%s%s", httplib.GuessCurrentHostURL(ctx), urlPathContext)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch mode {
|
switch mode {
|
||||||
case "markdown":
|
case "markdown":
|
||||||
// Raw markdown
|
// Raw markdown
|
||||||
if err := markdown.RenderRaw(&markup.RenderContext{
|
if err := markdown.RenderRaw(&markup.RenderContext{
|
||||||
Ctx: ctx,
|
Ctx: ctx,
|
||||||
Links: links,
|
Links: markup.Links{
|
||||||
|
AbsolutePrefix: true,
|
||||||
|
Base: urlPrefix,
|
||||||
|
},
|
||||||
}, strings.NewReader(text), ctx.Resp); err != nil {
|
}, strings.NewReader(text), ctx.Resp); err != nil {
|
||||||
ctx.Error(http.StatusInternalServerError, err.Error())
|
ctx.Error(http.StatusInternalServerError, err.Error())
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
case "comment":
|
case "comment":
|
||||||
// Issue & comment content
|
// Comment as markdown
|
||||||
markupType = markdown.MarkupName
|
markupType = markdown.MarkupName
|
||||||
case "gfm":
|
case "gfm":
|
||||||
// GitHub Flavored Markdown
|
// Github Flavored Markdown as document
|
||||||
markupType = markdown.MarkupName
|
markupType = markdown.MarkupName
|
||||||
case "file":
|
case "file":
|
||||||
markupType = "" // render the repo file content by its extension
|
// File as document based on file extension
|
||||||
|
markupType = ""
|
||||||
relativePath = filePath
|
relativePath = filePath
|
||||||
default:
|
default:
|
||||||
ctx.Error(http.StatusUnprocessableEntity, fmt.Sprintf("Unknown mode: %s", mode))
|
ctx.Error(http.StatusUnprocessableEntity, fmt.Sprintf("Unknown mode: %s", mode))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
fields := strings.SplitN(strings.TrimPrefix(urlPathContext, setting.AppSubURL+"/"), "/", 5)
|
if !strings.HasPrefix(setting.AppSubURL+"/", urlPrefix) {
|
||||||
if len(fields) == 5 && fields[2] == "src" && (fields[3] == "branch" || fields[3] == "commit" || fields[3] == "tag") {
|
// check if urlPrefix is already set to a URL
|
||||||
// absolute base prefix is something like "https://host/subpath/{user}/{repo}"
|
linkRegex, _ := xurls.StrictMatchingScheme("https?://")
|
||||||
absoluteBasePrefix := fmt.Sprintf("%s%s/%s", httplib.GuessCurrentAppURL(ctx), fields[0], fields[1])
|
m := linkRegex.FindStringIndex(urlPrefix)
|
||||||
|
if m == nil {
|
||||||
fileDir := path.Dir(filePath) // it is "doc" if filePath is "doc/CHANGE.md"
|
urlPrefix = util.URLJoin(setting.AppURL, urlPrefix)
|
||||||
refPath := strings.Join(fields[3:], "/") // it is "branch/features/feat-12/doc"
|
}
|
||||||
refPath = strings.TrimSuffix(refPath, "/"+fileDir) // now we get the correct branch path: "branch/features/feat-12"
|
|
||||||
|
|
||||||
links = markup.Links{AbsolutePrefix: true, Base: absoluteBasePrefix, BranchPath: refPath, TreePath: fileDir}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
meta := map[string]string{}
|
meta := map[string]string{}
|
||||||
@ -85,9 +81,12 @@ func RenderMarkup(ctx *context.Base, repo *context.Repository, mode, text, urlPa
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := markup.Render(&markup.RenderContext{
|
if err := markup.Render(&markup.RenderContext{
|
||||||
Ctx: ctx,
|
Ctx: ctx,
|
||||||
Repo: repoCtx,
|
Repo: repoCtx,
|
||||||
Links: links,
|
Links: markup.Links{
|
||||||
|
AbsolutePrefix: true,
|
||||||
|
Base: urlPrefix,
|
||||||
|
},
|
||||||
Metas: meta,
|
Metas: meta,
|
||||||
IsWiki: wiki,
|
IsWiki: wiki,
|
||||||
Type: markupType,
|
Type: markupType,
|
||||||
|
@ -191,8 +191,7 @@ func NormalRoutes() *web.Route {
|
|||||||
if setting.Packages.Enabled {
|
if setting.Packages.Enabled {
|
||||||
// This implements package support for most package managers
|
// This implements package support for most package managers
|
||||||
r.Mount("/api/packages", packages_router.CommonRoutes())
|
r.Mount("/api/packages", packages_router.CommonRoutes())
|
||||||
// This implements the OCI API, this container registry "/v2" endpoint must be in the root of the site.
|
// This implements the OCI API (Note this is not preceded by /api but is instead /v2)
|
||||||
// If site admin deploys Gitea in a sub-path, they must configure their reverse proxy to map the "https://host/v2" endpoint to Gitea.
|
|
||||||
r.Mount("/v2", packages_router.ContainerRoutes())
|
r.Mount("/v2", packages_router.ContainerRoutes())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,7 +15,6 @@ import (
|
|||||||
activities_model "code.gitea.io/gitea/models/activities"
|
activities_model "code.gitea.io/gitea/models/activities"
|
||||||
"code.gitea.io/gitea/models/db"
|
"code.gitea.io/gitea/models/db"
|
||||||
"code.gitea.io/gitea/modules/base"
|
"code.gitea.io/gitea/modules/base"
|
||||||
"code.gitea.io/gitea/modules/cache"
|
|
||||||
"code.gitea.io/gitea/modules/graceful"
|
"code.gitea.io/gitea/modules/graceful"
|
||||||
"code.gitea.io/gitea/modules/httplib"
|
"code.gitea.io/gitea/modules/httplib"
|
||||||
"code.gitea.io/gitea/modules/json"
|
"code.gitea.io/gitea/modules/json"
|
||||||
@ -223,14 +222,6 @@ func SelfCheck(ctx *context.Context) {
|
|||||||
|
|
||||||
ctx.Data["DatabaseCheckHasProblems"] = hasProblem
|
ctx.Data["DatabaseCheckHasProblems"] = hasProblem
|
||||||
}
|
}
|
||||||
|
|
||||||
elapsed, err := cache.Test()
|
|
||||||
if err != nil {
|
|
||||||
ctx.Data["CacheError"] = err
|
|
||||||
} else if elapsed > cache.SlowCacheThreshold {
|
|
||||||
ctx.Data["CacheSlow"] = fmt.Sprint(elapsed)
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx.HTML(http.StatusOK, tplSelfCheck)
|
ctx.HTML(http.StatusOK, tplSelfCheck)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,7 +12,6 @@ import (
|
|||||||
|
|
||||||
system_model "code.gitea.io/gitea/models/system"
|
system_model "code.gitea.io/gitea/models/system"
|
||||||
"code.gitea.io/gitea/modules/base"
|
"code.gitea.io/gitea/modules/base"
|
||||||
"code.gitea.io/gitea/modules/cache"
|
|
||||||
"code.gitea.io/gitea/modules/git"
|
"code.gitea.io/gitea/modules/git"
|
||||||
"code.gitea.io/gitea/modules/json"
|
"code.gitea.io/gitea/modules/json"
|
||||||
"code.gitea.io/gitea/modules/log"
|
"code.gitea.io/gitea/modules/log"
|
||||||
@ -43,22 +42,6 @@ func SendTestMail(ctx *context.Context) {
|
|||||||
ctx.Redirect(setting.AppSubURL + "/admin/config")
|
ctx.Redirect(setting.AppSubURL + "/admin/config")
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestCache test the cache settings
|
|
||||||
func TestCache(ctx *context.Context) {
|
|
||||||
elapsed, err := cache.Test()
|
|
||||||
if err != nil {
|
|
||||||
ctx.Flash.Error(ctx.Tr("admin.config.cache_test_failed", err))
|
|
||||||
} else {
|
|
||||||
if elapsed > cache.SlowCacheThreshold {
|
|
||||||
ctx.Flash.Warning(ctx.Tr("admin.config.cache_test_slow", elapsed))
|
|
||||||
} else {
|
|
||||||
ctx.Flash.Info(ctx.Tr("admin.config.cache_test_succeeded", elapsed))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx.Redirect(setting.AppSubURL + "/admin/config")
|
|
||||||
}
|
|
||||||
|
|
||||||
func shadowPasswordKV(cfgItem, splitter string) string {
|
func shadowPasswordKV(cfgItem, splitter string) string {
|
||||||
fields := strings.Split(cfgItem, splitter)
|
fields := strings.Split(cfgItem, splitter)
|
||||||
for i := 0; i < len(fields); i++ {
|
for i := 0; i < len(fields); i++ {
|
||||||
|
@ -63,7 +63,7 @@ func RenderRepoSearch(ctx *context.Context, opts *RepoSearchOptions) {
|
|||||||
sortOrder = setting.UI.ExploreDefaultSort
|
sortOrder = setting.UI.ExploreDefaultSort
|
||||||
}
|
}
|
||||||
|
|
||||||
if order, ok := repo_model.OrderByFlatMap[sortOrder]; ok {
|
if order, ok := repo_model.SearchOrderByFlatMap[sortOrder]; ok {
|
||||||
orderBy = order
|
orderBy = order
|
||||||
} else {
|
} else {
|
||||||
sortOrder = "recentupdate"
|
sortOrder = "recentupdate"
|
||||||
|
@ -616,7 +616,7 @@ func SearchRepo(ctx *context.Context) {
|
|||||||
if len(sortOrder) == 0 {
|
if len(sortOrder) == 0 {
|
||||||
sortOrder = "asc"
|
sortOrder = "asc"
|
||||||
}
|
}
|
||||||
if searchModeMap, ok := repo_model.OrderByMap[sortOrder]; ok {
|
if searchModeMap, ok := repo_model.SearchOrderByMap[sortOrder]; ok {
|
||||||
if orderBy, ok := searchModeMap[sortMode]; ok {
|
if orderBy, ok := searchModeMap[sortMode]; ok {
|
||||||
opts.OrderBy = orderBy
|
opts.OrderBy = orderBy
|
||||||
} else {
|
} else {
|
||||||
|
@ -692,7 +692,6 @@ func registerRoutes(m *web.Route) {
|
|||||||
m.Get("", admin.Config)
|
m.Get("", admin.Config)
|
||||||
m.Post("", admin.ChangeConfig)
|
m.Post("", admin.ChangeConfig)
|
||||||
m.Post("/test_mail", admin.SendTestMail)
|
m.Post("/test_mail", admin.SendTestMail)
|
||||||
m.Post("/test_cache", admin.TestCache)
|
|
||||||
m.Get("/settings", admin.ConfigSettings)
|
m.Get("/settings", admin.ConfigSettings)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -6,13 +6,10 @@ package repository
|
|||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"code.gitea.io/gitea/models/db"
|
"code.gitea.io/gitea/models/db"
|
||||||
repo_model "code.gitea.io/gitea/models/repo"
|
|
||||||
"code.gitea.io/gitea/models/unittest"
|
"code.gitea.io/gitea/models/unittest"
|
||||||
user_model "code.gitea.io/gitea/models/user"
|
|
||||||
"code.gitea.io/gitea/modules/setting"
|
"code.gitea.io/gitea/modules/setting"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
@ -86,13 +83,3 @@ func TestListUnadoptedRepositories_ListOptions(t *testing.T) {
|
|||||||
assert.Equal(t, 2, count)
|
assert.Equal(t, 2, count)
|
||||||
assert.Equal(t, unadoptedList[1], repoNames[0])
|
assert.Equal(t, unadoptedList[1], repoNames[0])
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAdoptRepository(t *testing.T) {
|
|
||||||
assert.NoError(t, unittest.PrepareTestDatabase())
|
|
||||||
assert.NoError(t, unittest.CopyDir(filepath.Join(setting.RepoRootPath, "user2", "repo1.git"), filepath.Join(setting.RepoRootPath, "user2", "test-adopt.git")))
|
|
||||||
user2 := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2})
|
|
||||||
_, err := AdoptRepository(db.DefaultContext, user2, user2, CreateRepoOptions{Name: "test-adopt"})
|
|
||||||
assert.NoError(t, err)
|
|
||||||
repoTestAdopt := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{Name: "test-adopt"})
|
|
||||||
assert.Equal(t, "sha1", repoTestAdopt.ObjectFormatName)
|
|
||||||
}
|
|
||||||
|
@ -229,8 +229,8 @@
|
|||||||
<dt>{{ctx.Locale.Tr "admin.config.mailer_user"}}</dt>
|
<dt>{{ctx.Locale.Tr "admin.config.mailer_user"}}</dt>
|
||||||
<dd>{{if .Mailer.User}}{{.Mailer.User}}{{else}}(empty){{end}}</dd>
|
<dd>{{if .Mailer.User}}{{.Mailer.User}}{{else}}(empty){{end}}</dd>
|
||||||
<div class="divider"></div>
|
<div class="divider"></div>
|
||||||
<dt class="tw-py-1 tw-flex tw-items-center">{{ctx.Locale.Tr "admin.config.send_test_mail"}}</dt>
|
<dt class="tw-py-1">{{ctx.Locale.Tr "admin.config.send_test_mail"}}</dt>
|
||||||
<dd class="tw-py-0">
|
<dd>
|
||||||
<form class="ui form ignore-dirty" action="{{AppSubUrl}}/admin/config/test_mail" method="post">
|
<form class="ui form ignore-dirty" action="{{AppSubUrl}}/admin/config/test_mail" method="post">
|
||||||
{{.CsrfTokenHtml}}
|
{{.CsrfTokenHtml}}
|
||||||
<div class="ui tiny input">
|
<div class="ui tiny input">
|
||||||
@ -260,14 +260,6 @@
|
|||||||
<dt>{{ctx.Locale.Tr "admin.config.cache_item_ttl"}}</dt>
|
<dt>{{ctx.Locale.Tr "admin.config.cache_item_ttl"}}</dt>
|
||||||
<dd><code>{{.CacheItemTTL}}</code></dd>
|
<dd><code>{{.CacheItemTTL}}</code></dd>
|
||||||
{{end}}
|
{{end}}
|
||||||
<div class="divider"></div>
|
|
||||||
<dt class="tw-py-1 tw-flex tw-items-center">{{ctx.Locale.Tr "admin.config.cache_test"}}</dt>
|
|
||||||
<dd class="tw-py-0">
|
|
||||||
<form class="ui form ignore-dirty" action="{{AppSubUrl}}/admin/config/test_cache" method="post">
|
|
||||||
{{.CsrfTokenHtml}}
|
|
||||||
<button class="ui tiny primary button">{{ctx.Locale.Tr "test"}}</button>
|
|
||||||
</form>
|
|
||||||
</dd>
|
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -76,11 +76,9 @@
|
|||||||
{{ctx.Locale.Tr "admin.dashboard.system_status"}}
|
{{ctx.Locale.Tr "admin.dashboard.system_status"}}
|
||||||
</h4>
|
</h4>
|
||||||
{{/* TODO: make these stats work in multi-server deployments, likely needs per-server stats in DB */}}
|
{{/* TODO: make these stats work in multi-server deployments, likely needs per-server stats in DB */}}
|
||||||
<div class="ui attached table segment">
|
<div class="no-loading-indicator tw-hidden"></div>
|
||||||
<div class="no-loading-indicator tw-hidden"></div>
|
<div hx-get="{{$.Link}}/system_status" hx-swap="morph:innerHTML" hx-trigger="every 5s" hx-indicator=".no-loading-indicator" class="ui attached table segment">
|
||||||
<div hx-get="{{$.Link}}/system_status" hx-swap="morph:innerHTML" hx-trigger="every 5s" hx-indicator=".no-loading-indicator">
|
{{template "admin/system_status" .}}
|
||||||
{{template "admin/system_status" .}}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{{template "admin/layout_footer" .}}
|
{{template "admin/layout_footer" .}}
|
||||||
|
@ -17,40 +17,32 @@
|
|||||||
<div class="ui attached segment tw-hidden self-check-problem" id="self-check-by-frontend"></div>
|
<div class="ui attached segment tw-hidden self-check-problem" id="self-check-by-frontend"></div>
|
||||||
|
|
||||||
{{if .DatabaseCheckHasProblems}}
|
{{if .DatabaseCheckHasProblems}}
|
||||||
<div class="ui attached segment self-check-problem">
|
<div class="ui attached segment self-check-problem">
|
||||||
{{if .DatabaseType.IsMySQL}}
|
{{if .DatabaseType.IsMySQL}}
|
||||||
<div class="tw-p-2">{{ctx.Locale.Tr "admin.self_check.database_fix_mysql"}}</div>
|
<div class="tw-p-2">{{ctx.Locale.Tr "admin.self_check.database_fix_mysql"}}</div>
|
||||||
{{else if .DatabaseType.IsMSSQL}}
|
{{else if .DatabaseType.IsMSSQL}}
|
||||||
<div class="tw-p-2">{{ctx.Locale.Tr "admin.self_check.database_fix_mssql"}}</div>
|
<div class="tw-p-2">{{ctx.Locale.Tr "admin.self_check.database_fix_mssql"}}</div>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{if .DatabaseCheckCollationMismatch}}
|
{{if .DatabaseCheckCollationMismatch}}
|
||||||
<div class="ui red message">{{ctx.Locale.Tr "admin.self_check.database_collation_mismatch" .DatabaseCheckResult.ExpectedCollation}}</div>
|
<div class="ui red message">{{ctx.Locale.Tr "admin.self_check.database_collation_mismatch" .DatabaseCheckResult.ExpectedCollation}}</div>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{if .DatabaseCheckCollationCaseInsensitive}}
|
{{if .DatabaseCheckCollationCaseInsensitive}}
|
||||||
<div class="ui warning message">{{ctx.Locale.Tr "admin.self_check.database_collation_case_insensitive" .DatabaseCheckResult.DatabaseCollation}}</div>
|
<div class="ui warning message">{{ctx.Locale.Tr "admin.self_check.database_collation_case_insensitive" .DatabaseCheckResult.DatabaseCollation}}</div>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{if .DatabaseCheckInconsistentCollationColumns}}
|
{{if .DatabaseCheckInconsistentCollationColumns}}
|
||||||
<div class="ui red message">
|
<div class="ui red message">
|
||||||
<details>
|
<details>
|
||||||
<summary>{{ctx.Locale.Tr "admin.self_check.database_inconsistent_collation_columns" .DatabaseCheckResult.DatabaseCollation}}</summary>
|
<summary>{{ctx.Locale.Tr "admin.self_check.database_inconsistent_collation_columns" .DatabaseCheckResult.DatabaseCollation}}</summary>
|
||||||
<ul class="tw-w-full">
|
<ul class="tw-w-full">
|
||||||
{{range .DatabaseCheckInconsistentCollationColumns}}
|
{{range .DatabaseCheckInconsistentCollationColumns}}
|
||||||
<li>{{.}}</li>
|
<li>{{.}}</li>
|
||||||
{{end}}
|
{{end}}
|
||||||
</ul>
|
</ul>
|
||||||
</details>
|
</details>
|
||||||
</div>
|
</div>
|
||||||
{{end}}
|
{{end}}
|
||||||
</div>
|
</div>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
{{if .CacheError}}
|
|
||||||
<div class="ui red message">{{ctx.Locale.Tr "admin.config.cache_test_failed" .CacheError}}</div>
|
|
||||||
{{end}}
|
|
||||||
{{if .CacheSlow}}
|
|
||||||
<div class="ui warning message">{{ctx.Locale.Tr "admin.config.cache_test_slow" .CacheSlow}}</div>
|
|
||||||
{{end}}
|
|
||||||
|
|
||||||
{{/* only shown when there is no visible "self-check-problem" */}}
|
{{/* only shown when there is no visible "self-check-problem" */}}
|
||||||
<div class="ui attached segment tw-hidden self-check-no-problem">
|
<div class="ui attached segment tw-hidden self-check-no-problem">
|
||||||
{{ctx.Locale.Tr "admin.self_check.no_problem_found"}}
|
{{ctx.Locale.Tr "admin.self_check.no_problem_found"}}
|
||||||
|
4
templates/swagger/v1_json.tmpl
generated
4
templates/swagger/v1_json.tmpl
generated
@ -22404,7 +22404,7 @@
|
|||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"Context": {
|
"Context": {
|
||||||
"description": "URL path for rendering issue, media and file links\nExpected format: /subpath/{user}/{repo}/src/{branch, commit, tag}/{identifier/path}/{file/dir}\n\nin: body",
|
"description": "Context to render\n\nin: body",
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"Mode": {
|
"Mode": {
|
||||||
@ -22427,7 +22427,7 @@
|
|||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"Context": {
|
"Context": {
|
||||||
"description": "URL path for rendering issue, media and file links\nExpected format: /subpath/{user}/{repo}/src/{branch, commit, tag}/{identifier/path}/{file/dir}\n\nin: body",
|
"description": "Context to render\n\nin: body",
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"FilePath": {
|
"FilePath": {
|
||||||
|
@ -4,11 +4,7 @@
|
|||||||
package integration
|
package integration
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"archive/tar"
|
|
||||||
"bytes"
|
"bytes"
|
||||||
"compress/gzip"
|
|
||||||
"crypto/sha256"
|
|
||||||
"crypto/sha512"
|
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"fmt"
|
"fmt"
|
||||||
"mime/multipart"
|
"mime/multipart"
|
||||||
@ -25,167 +21,101 @@ import (
|
|||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
type tarFile struct {
|
|
||||||
Name string
|
|
||||||
Data []byte
|
|
||||||
}
|
|
||||||
|
|
||||||
func makeArchiveFileTar(files []*tarFile) []byte {
|
|
||||||
buf := new(bytes.Buffer)
|
|
||||||
tarWriter := tar.NewWriter(buf)
|
|
||||||
for _, file := range files {
|
|
||||||
_ = tarWriter.WriteHeader(&tar.Header{
|
|
||||||
Typeflag: tar.TypeReg,
|
|
||||||
Name: file.Name,
|
|
||||||
Mode: 0o644,
|
|
||||||
Size: int64(len(file.Data)),
|
|
||||||
})
|
|
||||||
_, _ = tarWriter.Write(file.Data)
|
|
||||||
}
|
|
||||||
_ = tarWriter.Close()
|
|
||||||
return buf.Bytes()
|
|
||||||
}
|
|
||||||
|
|
||||||
func makeArchiveFileGz(data []byte) []byte {
|
|
||||||
buf := new(bytes.Buffer)
|
|
||||||
gzWriter, _ := gzip.NewWriterLevel(buf, gzip.NoCompression)
|
|
||||||
_, _ = gzWriter.Write(data)
|
|
||||||
_ = gzWriter.Close()
|
|
||||||
return buf.Bytes()
|
|
||||||
}
|
|
||||||
|
|
||||||
func makeRubyGem(name, version string) []byte {
|
|
||||||
metadataContent := fmt.Sprintf(`--- !ruby/object:Gem::Specification
|
|
||||||
name: %s
|
|
||||||
version: !ruby/object:Gem::Version
|
|
||||||
version: %s
|
|
||||||
platform: ruby
|
|
||||||
authors:
|
|
||||||
- Gitea
|
|
||||||
autorequire:
|
|
||||||
bindir: bin
|
|
||||||
cert_chain: []
|
|
||||||
date: 2021-08-23 00:00:00.000000000 Z
|
|
||||||
dependencies:
|
|
||||||
- !ruby/object:Gem::Dependency
|
|
||||||
name: runtime-dep
|
|
||||||
requirement: !ruby/object:Gem::Requirement
|
|
||||||
requirements:
|
|
||||||
- - ">="
|
|
||||||
- !ruby/object:Gem::Version
|
|
||||||
version: 1.2.0
|
|
||||||
- - "<"
|
|
||||||
- !ruby/object:Gem::Version
|
|
||||||
version: '2.0'
|
|
||||||
type: :runtime
|
|
||||||
prerelease: false
|
|
||||||
version_requirements: !ruby/object:Gem::Requirement
|
|
||||||
requirements:
|
|
||||||
- - ">="
|
|
||||||
- !ruby/object:Gem::Version
|
|
||||||
version: 1.2.0
|
|
||||||
- - "<"
|
|
||||||
- !ruby/object:Gem::Version
|
|
||||||
version: '2.0'
|
|
||||||
- !ruby/object:Gem::Dependency
|
|
||||||
name: dev-dep
|
|
||||||
requirement: !ruby/object:Gem::Requirement
|
|
||||||
requirements:
|
|
||||||
- - "~>"
|
|
||||||
- !ruby/object:Gem::Version
|
|
||||||
version: '5.2'
|
|
||||||
type: :development
|
|
||||||
prerelease: false
|
|
||||||
version_requirements: !ruby/object:Gem::Requirement
|
|
||||||
requirements:
|
|
||||||
- - "~>"
|
|
||||||
- !ruby/object:Gem::Version
|
|
||||||
version: '5.2'
|
|
||||||
description: RubyGems package test
|
|
||||||
email: rubygems@gitea.io
|
|
||||||
executables: []
|
|
||||||
extensions: []
|
|
||||||
extra_rdoc_files: []
|
|
||||||
files:
|
|
||||||
- lib/gitea.rb
|
|
||||||
homepage: https://gitea.io/
|
|
||||||
licenses:
|
|
||||||
- MIT
|
|
||||||
metadata: {}
|
|
||||||
post_install_message:
|
|
||||||
rdoc_options: []
|
|
||||||
require_paths:
|
|
||||||
- lib
|
|
||||||
required_ruby_version: !ruby/object:Gem::Requirement
|
|
||||||
requirements:
|
|
||||||
- - ">="
|
|
||||||
- !ruby/object:Gem::Version
|
|
||||||
version: 2.3.0
|
|
||||||
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
||||||
requirements:
|
|
||||||
- - ">="
|
|
||||||
- !ruby/object:Gem::Version
|
|
||||||
version: '1.0'
|
|
||||||
requirements: []
|
|
||||||
rubyforge_project:
|
|
||||||
rubygems_version: 2.7.6.2
|
|
||||||
signing_key:
|
|
||||||
specification_version: 4
|
|
||||||
summary: Gitea package
|
|
||||||
test_files: []
|
|
||||||
`, name, version)
|
|
||||||
|
|
||||||
metadataGz := makeArchiveFileGz([]byte(metadataContent))
|
|
||||||
dataTarGz := makeArchiveFileGz(makeArchiveFileTar([]*tarFile{
|
|
||||||
{
|
|
||||||
Name: "lib/gitea.rb",
|
|
||||||
Data: []byte("class Gitea\nend"),
|
|
||||||
},
|
|
||||||
}))
|
|
||||||
|
|
||||||
checksumsYaml := fmt.Sprintf(`---
|
|
||||||
SHA256:
|
|
||||||
metadata.gz: %x
|
|
||||||
data.tar.gz: %x
|
|
||||||
SHA512:
|
|
||||||
metadata.gz: %x
|
|
||||||
data.tar.gz: %x
|
|
||||||
`, sha256.Sum256(metadataGz), sha256.Sum256(dataTarGz), sha512.Sum512(metadataGz), sha512.Sum512(dataTarGz))
|
|
||||||
|
|
||||||
files := []*tarFile{
|
|
||||||
{
|
|
||||||
Name: "data.tar.gz",
|
|
||||||
Data: dataTarGz,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Name: "metadata.gz",
|
|
||||||
Data: metadataGz,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Name: "checksums.yaml.gz",
|
|
||||||
Data: makeArchiveFileGz([]byte(checksumsYaml)),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
return makeArchiveFileTar(files)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestPackageRubyGems(t *testing.T) {
|
func TestPackageRubyGems(t *testing.T) {
|
||||||
defer tests.PrepareTestEnv(t)()
|
defer tests.PrepareTestEnv(t)()
|
||||||
|
|
||||||
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2})
|
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2})
|
||||||
|
|
||||||
testGemName := "gitea"
|
packageName := "gitea"
|
||||||
testGemVersion := "1.0.5"
|
packageVersion := "1.0.5"
|
||||||
testGemContent := makeRubyGem(testGemName, testGemVersion)
|
packageFilename := "gitea-1.0.5.gem"
|
||||||
testGemContentChecksum := fmt.Sprintf("%x", sha256.Sum256(testGemContent))
|
|
||||||
|
|
||||||
testAnotherGemName := "gitea-another"
|
gemContent, _ := base64.StdEncoding.DecodeString(`bWV0YWRhdGEuZ3oAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
||||||
testAnotherGemVersion := "0.99"
|
AAAAAAAAAAAAAAAAA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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
||||||
|
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
||||||
|
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
||||||
|
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
||||||
|
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
||||||
|
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
||||||
|
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA`)
|
||||||
|
|
||||||
root := fmt.Sprintf("/api/packages/%s/rubygems", user.Name)
|
root := fmt.Sprintf("/api/packages/%s/rubygems", user.Name)
|
||||||
|
|
||||||
uploadFile := func(t *testing.T, content []byte, expectedStatus int) {
|
uploadFile := func(t *testing.T, expectedStatus int) {
|
||||||
req := NewRequestWithBody(t, "POST", fmt.Sprintf("%s/api/v1/gems", root), bytes.NewReader(content)).
|
req := NewRequestWithBody(t, "POST", fmt.Sprintf("%s/api/v1/gems", root), bytes.NewReader(gemContent)).
|
||||||
AddBasicAuth(user.Name)
|
AddBasicAuth(user.Name)
|
||||||
MakeRequest(t, req, expectedStatus)
|
MakeRequest(t, req, expectedStatus)
|
||||||
}
|
}
|
||||||
@ -193,7 +123,7 @@ func TestPackageRubyGems(t *testing.T) {
|
|||||||
t.Run("Upload", func(t *testing.T) {
|
t.Run("Upload", func(t *testing.T) {
|
||||||
defer tests.PrintCurrentTest(t)()
|
defer tests.PrintCurrentTest(t)()
|
||||||
|
|
||||||
uploadFile(t, testGemContent, http.StatusCreated)
|
uploadFile(t, http.StatusCreated)
|
||||||
|
|
||||||
pvs, err := packages.GetVersionsByPackageType(db.DefaultContext, user.ID, packages.TypeRubyGems)
|
pvs, err := packages.GetVersionsByPackageType(db.DefaultContext, user.ID, packages.TypeRubyGems)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
@ -203,33 +133,34 @@ func TestPackageRubyGems(t *testing.T) {
|
|||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.NotNil(t, pd.SemVer)
|
assert.NotNil(t, pd.SemVer)
|
||||||
assert.IsType(t, &rubygems.Metadata{}, pd.Metadata)
|
assert.IsType(t, &rubygems.Metadata{}, pd.Metadata)
|
||||||
assert.Equal(t, testGemName, pd.Package.Name)
|
assert.Equal(t, packageName, pd.Package.Name)
|
||||||
assert.Equal(t, testGemVersion, pd.Version.Version)
|
assert.Equal(t, packageVersion, pd.Version.Version)
|
||||||
|
|
||||||
pfs, err := packages.GetFilesByVersionID(db.DefaultContext, pvs[0].ID)
|
pfs, err := packages.GetFilesByVersionID(db.DefaultContext, pvs[0].ID)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Len(t, pfs, 1)
|
assert.Len(t, pfs, 1)
|
||||||
assert.Equal(t, fmt.Sprintf("%s-%s.gem", testGemName, testGemVersion), pfs[0].Name)
|
assert.Equal(t, packageFilename, pfs[0].Name)
|
||||||
assert.True(t, pfs[0].IsLead)
|
assert.True(t, pfs[0].IsLead)
|
||||||
|
|
||||||
pb, err := packages.GetBlobByID(db.DefaultContext, pfs[0].BlobID)
|
pb, err := packages.GetBlobByID(db.DefaultContext, pfs[0].BlobID)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.EqualValues(t, len(testGemContent), pb.Size)
|
assert.Equal(t, int64(4608), pb.Size)
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("UploadExists", func(t *testing.T) {
|
t.Run("UploadExists", func(t *testing.T) {
|
||||||
defer tests.PrintCurrentTest(t)()
|
defer tests.PrintCurrentTest(t)()
|
||||||
uploadFile(t, testGemContent, http.StatusConflict)
|
|
||||||
|
uploadFile(t, http.StatusConflict)
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("Download", func(t *testing.T) {
|
t.Run("Download", func(t *testing.T) {
|
||||||
defer tests.PrintCurrentTest(t)()
|
defer tests.PrintCurrentTest(t)()
|
||||||
|
|
||||||
req := NewRequest(t, "GET", fmt.Sprintf("%s/gems/%s-%s.gem", root, testGemName, testGemVersion)).
|
req := NewRequest(t, "GET", fmt.Sprintf("%s/gems/%s", root, packageFilename)).
|
||||||
AddBasicAuth(user.Name)
|
AddBasicAuth(user.Name)
|
||||||
resp := MakeRequest(t, req, http.StatusOK)
|
resp := MakeRequest(t, req, http.StatusOK)
|
||||||
|
|
||||||
assert.Equal(t, testGemContent, resp.Body.Bytes())
|
assert.Equal(t, gemContent, resp.Body.Bytes())
|
||||||
|
|
||||||
pvs, err := packages.GetVersionsByPackageType(db.DefaultContext, user.ID, packages.TypeRubyGems)
|
pvs, err := packages.GetVersionsByPackageType(db.DefaultContext, user.ID, packages.TypeRubyGems)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
@ -240,7 +171,7 @@ func TestPackageRubyGems(t *testing.T) {
|
|||||||
t.Run("DownloadGemspec", func(t *testing.T) {
|
t.Run("DownloadGemspec", func(t *testing.T) {
|
||||||
defer tests.PrintCurrentTest(t)()
|
defer tests.PrintCurrentTest(t)()
|
||||||
|
|
||||||
req := NewRequest(t, "GET", fmt.Sprintf("%s/quick/Marshal.4.8/%s-%s.gemspec.rz", root, testGemName, testGemVersion)).
|
req := NewRequest(t, "GET", fmt.Sprintf("%s/quick/Marshal.4.8/%sspec.rz", root, packageFilename)).
|
||||||
AddBasicAuth(user.Name)
|
AddBasicAuth(user.Name)
|
||||||
resp := MakeRequest(t, req, http.StatusOK)
|
resp := MakeRequest(t, req, http.StatusOK)
|
||||||
|
|
||||||
@ -275,63 +206,22 @@ gAAAAP//MS06Gw==`)
|
|||||||
enumeratePackages(t, "prerelease_specs.4.8.gz", b)
|
enumeratePackages(t, "prerelease_specs.4.8.gz", b)
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("UploadAnother", func(t *testing.T) {
|
t.Run("Delete", func(t *testing.T) {
|
||||||
defer tests.PrintCurrentTest(t)()
|
|
||||||
uploadFile(t, makeRubyGem(testAnotherGemName, testAnotherGemVersion), http.StatusCreated)
|
|
||||||
})
|
|
||||||
|
|
||||||
t.Run("PackageInfo", func(t *testing.T) {
|
|
||||||
defer tests.PrintCurrentTest(t)()
|
defer tests.PrintCurrentTest(t)()
|
||||||
|
|
||||||
req := NewRequest(t, "GET", fmt.Sprintf("%s/info/%s", root, testGemName)).AddBasicAuth(user.Name)
|
|
||||||
resp := MakeRequest(t, req, http.StatusOK)
|
|
||||||
expected := fmt.Sprintf(`---
|
|
||||||
1.0.5 runtime-dep:>= 1.2.0&< 2.0|checksum:%s,ruby:>= 2.3.0,rubygems:>= 1.0
|
|
||||||
`, testGemContentChecksum)
|
|
||||||
assert.Equal(t, expected, resp.Body.String())
|
|
||||||
})
|
|
||||||
|
|
||||||
t.Run("Versions", func(t *testing.T) {
|
|
||||||
defer tests.PrintCurrentTest(t)()
|
|
||||||
req := NewRequest(t, "GET", fmt.Sprintf("%s/versions", root)).AddBasicAuth(user.Name)
|
|
||||||
resp := MakeRequest(t, req, http.StatusOK)
|
|
||||||
assert.Equal(t, `---
|
|
||||||
gitea 1.0.5 08843c2dd0ea19910e6b056b98e38f1c
|
|
||||||
gitea-another 0.99 8b639e4048d282941485368ec42609be
|
|
||||||
`, resp.Body.String())
|
|
||||||
})
|
|
||||||
|
|
||||||
deleteGemPackage := func(t *testing.T, packageName, packageVersion string) {
|
|
||||||
body := bytes.Buffer{}
|
body := bytes.Buffer{}
|
||||||
writer := multipart.NewWriter(&body)
|
writer := multipart.NewWriter(&body)
|
||||||
_ = writer.WriteField("gem_name", packageName)
|
writer.WriteField("gem_name", packageName)
|
||||||
_ = writer.WriteField("version", packageVersion)
|
writer.WriteField("version", packageVersion)
|
||||||
_ = writer.Close()
|
writer.Close()
|
||||||
|
|
||||||
req := NewRequestWithBody(t, "DELETE", fmt.Sprintf("%s/api/v1/gems/yank", root), &body).
|
req := NewRequestWithBody(t, "DELETE", fmt.Sprintf("%s/api/v1/gems/yank", root), &body).
|
||||||
SetHeader("Content-Type", writer.FormDataContentType()).
|
SetHeader("Content-Type", writer.FormDataContentType()).
|
||||||
AddBasicAuth(user.Name)
|
AddBasicAuth(user.Name)
|
||||||
MakeRequest(t, req, http.StatusOK)
|
MakeRequest(t, req, http.StatusOK)
|
||||||
}
|
|
||||||
|
|
||||||
t.Run("DeleteAll", func(t *testing.T) {
|
|
||||||
defer tests.PrintCurrentTest(t)()
|
|
||||||
deleteGemPackage(t, testGemName, testGemVersion)
|
|
||||||
deleteGemPackage(t, testAnotherGemName, testAnotherGemVersion)
|
|
||||||
pvs, err := packages.GetVersionsByPackageType(db.DefaultContext, user.ID, packages.TypeRubyGems)
|
pvs, err := packages.GetVersionsByPackageType(db.DefaultContext, user.ID, packages.TypeRubyGems)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Empty(t, pvs)
|
assert.Empty(t, pvs)
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("PackageInfoAfterDelete", func(t *testing.T) {
|
|
||||||
defer tests.PrintCurrentTest(t)()
|
|
||||||
req := NewRequest(t, "GET", fmt.Sprintf("%s/info/%s", root, testGemName)).AddBasicAuth(user.Name)
|
|
||||||
MakeRequest(t, req, http.StatusNotFound)
|
|
||||||
})
|
|
||||||
|
|
||||||
t.Run("VersionsAfterDelete", func(t *testing.T) {
|
|
||||||
defer tests.PrintCurrentTest(t)()
|
|
||||||
req := NewRequest(t, "GET", fmt.Sprintf("%s/versions", root)).AddBasicAuth(user.Name)
|
|
||||||
resp := MakeRequest(t, req, http.StatusOK)
|
|
||||||
assert.Equal(t, "---\n", resp.Body.String())
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
@ -272,7 +272,7 @@ export function initRepoCommentForm() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$list.find('.selected').html(`
|
$list.find('.selected').html(`
|
||||||
<a class="item muted sidebar-item-link" href="${htmlEscape(this.getAttribute('data-href'))}">
|
<a class="item muted sidebar-item-link" href=${htmlEscape(this.getAttribute('href'))}>
|
||||||
${icon}
|
${icon}
|
||||||
${htmlEscape(this.textContent)}
|
${htmlEscape(this.textContent)}
|
||||||
</a>
|
</a>
|
||||||
|
Loading…
Reference in New Issue
Block a user