mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-31 11:52:10 +00:00
Simplify parameter types (#18006)
Remove repeated type declarations in function definitions.
This commit is contained in:
parent
25677cdc5b
commit
ff2fd08228
59 changed files with 115 additions and 116 deletions
|
@ -16,10 +16,10 @@ var (
|
|||
blocks = []blockFunc{b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15, b16, b17, b18, b19, b20, b21, b22, b23, b24, b25, b26, b27}
|
||||
)
|
||||
|
||||
type blockFunc func(img *image.Paletted, x, y, size int, angle int)
|
||||
type blockFunc func(img *image.Paletted, x, y, size, angle int)
|
||||
|
||||
// draw a polygon by points, and the polygon is rotated by angle.
|
||||
func drawBlock(img *image.Paletted, x, y, size int, angle int, points []int) {
|
||||
func drawBlock(img *image.Paletted, x, y, size, angle int, points []int) {
|
||||
if angle != 0 {
|
||||
m := size / 2
|
||||
rotate(points, m, m, angle)
|
||||
|
@ -41,7 +41,7 @@ func drawBlock(img *image.Paletted, x, y, size int, angle int, points []int) {
|
|||
// | |
|
||||
// | |
|
||||
// --------
|
||||
func b0(img *image.Paletted, x, y, size int, angle int) {}
|
||||
func b0(img *image.Paletted, x, y, size, angle int) {}
|
||||
|
||||
// full-filled
|
||||
//
|
||||
|
@ -50,7 +50,7 @@ func b0(img *image.Paletted, x, y, size int, angle int) {}
|
|||
// |######|
|
||||
// |######|
|
||||
// --------
|
||||
func b1(img *image.Paletted, x, y, size int, angle int) {
|
||||
func b1(img *image.Paletted, x, y, size, angle int) {
|
||||
for i := x; i < x+size; i++ {
|
||||
for j := y; j < y+size; j++ {
|
||||
img.SetColorIndex(i, j, 1)
|
||||
|
@ -65,7 +65,7 @@ func b1(img *image.Paletted, x, y, size int, angle int) {
|
|||
// | #### |
|
||||
// | |
|
||||
// ----------
|
||||
func b2(img *image.Paletted, x, y, size int, angle int) {
|
||||
func b2(img *image.Paletted, x, y, size, angle int) {
|
||||
l := size / 4
|
||||
x += l
|
||||
y += l
|
||||
|
@ -88,7 +88,7 @@ func b2(img *image.Paletted, x, y, size int, angle int) {
|
|||
// | ### |
|
||||
// | # |
|
||||
// ---------
|
||||
func b3(img *image.Paletted, x, y, size int, angle int) {
|
||||
func b3(img *image.Paletted, x, y, size, angle int) {
|
||||
m := size / 2
|
||||
drawBlock(img, x, y, size, 0, []int{
|
||||
m, 0,
|
||||
|
@ -108,7 +108,7 @@ func b3(img *image.Paletted, x, y, size int, angle int) {
|
|||
// |## |
|
||||
// |# |
|
||||
// |------
|
||||
func b4(img *image.Paletted, x, y, size int, angle int) {
|
||||
func b4(img *image.Paletted, x, y, size, angle int) {
|
||||
drawBlock(img, x, y, size, angle, []int{
|
||||
0, 0,
|
||||
size, 0,
|
||||
|
@ -124,7 +124,7 @@ func b4(img *image.Paletted, x, y, size int, angle int) {
|
|||
// | ### |
|
||||
// | ##### |
|
||||
// |#######|
|
||||
func b5(img *image.Paletted, x, y, size int, angle int) {
|
||||
func b5(img *image.Paletted, x, y, size, angle int) {
|
||||
m := size / 2
|
||||
drawBlock(img, x, y, size, angle, []int{
|
||||
m, 0,
|
||||
|
@ -141,7 +141,7 @@ func b5(img *image.Paletted, x, y, size int, angle int) {
|
|||
// |### |
|
||||
// |### |
|
||||
// --------
|
||||
func b6(img *image.Paletted, x, y, size int, angle int) {
|
||||
func b6(img *image.Paletted, x, y, size, angle int) {
|
||||
m := size / 2
|
||||
drawBlock(img, x, y, size, angle, []int{
|
||||
0, 0,
|
||||
|
@ -160,7 +160,7 @@ func b6(img *image.Paletted, x, y, size int, angle int) {
|
|||
// | #####|
|
||||
// | ####|
|
||||
// |--------
|
||||
func b7(img *image.Paletted, x, y, size int, angle int) {
|
||||
func b7(img *image.Paletted, x, y, size, angle int) {
|
||||
m := size / 2
|
||||
drawBlock(img, x, y, size, angle, []int{
|
||||
0, 0,
|
||||
|
@ -181,7 +181,7 @@ func b7(img *image.Paletted, x, y, size int, angle int) {
|
|||
// | ### ### |
|
||||
// |#########|
|
||||
// -----------
|
||||
func b8(img *image.Paletted, x, y, size int, angle int) {
|
||||
func b8(img *image.Paletted, x, y, size, angle int) {
|
||||
m := size / 2
|
||||
mm := m / 2
|
||||
|
||||
|
@ -219,7 +219,7 @@ func b8(img *image.Paletted, x, y, size int, angle int) {
|
|||
// | #### |
|
||||
// | # |
|
||||
// ---------
|
||||
func b9(img *image.Paletted, x, y, size int, angle int) {
|
||||
func b9(img *image.Paletted, x, y, size, angle int) {
|
||||
m := size / 2
|
||||
drawBlock(img, x, y, size, angle, []int{
|
||||
0, 0,
|
||||
|
@ -241,7 +241,7 @@ func b9(img *image.Paletted, x, y, size int, angle int) {
|
|||
// |## |
|
||||
// |# |
|
||||
// ----------
|
||||
func b10(img *image.Paletted, x, y, size int, angle int) {
|
||||
func b10(img *image.Paletted, x, y, size, angle int) {
|
||||
m := size / 2
|
||||
drawBlock(img, x, y, size, angle, []int{
|
||||
m, 0,
|
||||
|
@ -267,7 +267,7 @@ func b10(img *image.Paletted, x, y, size int, angle int) {
|
|||
// | |
|
||||
// | |
|
||||
// ----------
|
||||
func b11(img *image.Paletted, x, y, size int, angle int) {
|
||||
func b11(img *image.Paletted, x, y, size, angle int) {
|
||||
m := size / 2
|
||||
drawBlock(img, x, y, size, angle, []int{
|
||||
0, 0,
|
||||
|
@ -287,7 +287,7 @@ func b11(img *image.Paletted, x, y, size int, angle int) {
|
|||
// | ##### |
|
||||
// | # |
|
||||
// -----------
|
||||
func b12(img *image.Paletted, x, y, size int, angle int) {
|
||||
func b12(img *image.Paletted, x, y, size, angle int) {
|
||||
m := size / 2
|
||||
drawBlock(img, x, y, size, angle, []int{
|
||||
0, m,
|
||||
|
@ -306,7 +306,7 @@ func b12(img *image.Paletted, x, y, size int, angle int) {
|
|||
// | ##### |
|
||||
// |#########|
|
||||
// -----------
|
||||
func b13(img *image.Paletted, x, y, size int, angle int) {
|
||||
func b13(img *image.Paletted, x, y, size, angle int) {
|
||||
m := size / 2
|
||||
drawBlock(img, x, y, size, angle, []int{
|
||||
m, m,
|
||||
|
@ -325,7 +325,7 @@ func b13(img *image.Paletted, x, y, size int, angle int) {
|
|||
// | |
|
||||
// | |
|
||||
// ---------
|
||||
func b14(img *image.Paletted, x, y, size int, angle int) {
|
||||
func b14(img *image.Paletted, x, y, size, angle int) {
|
||||
m := size / 2
|
||||
drawBlock(img, x, y, size, angle, []int{
|
||||
m, 0,
|
||||
|
@ -344,7 +344,7 @@ func b14(img *image.Paletted, x, y, size int, angle int) {
|
|||
// | |
|
||||
// | |
|
||||
// ----------
|
||||
func b15(img *image.Paletted, x, y, size int, angle int) {
|
||||
func b15(img *image.Paletted, x, y, size, angle int) {
|
||||
m := size / 2
|
||||
drawBlock(img, x, y, size, angle, []int{
|
||||
0, 0,
|
||||
|
@ -364,7 +364,7 @@ func b15(img *image.Paletted, x, y, size int, angle int) {
|
|||
// | ##### |
|
||||
// |#######|
|
||||
// ---------
|
||||
func b16(img *image.Paletted, x, y, size int, angle int) {
|
||||
func b16(img *image.Paletted, x, y, size, angle int) {
|
||||
m := size / 2
|
||||
drawBlock(img, x, y, size, angle, []int{
|
||||
m, 0,
|
||||
|
@ -390,7 +390,7 @@ func b16(img *image.Paletted, x, y, size int, angle int) {
|
|||
// | ##|
|
||||
// | ##|
|
||||
// ----------
|
||||
func b17(img *image.Paletted, x, y, size int, angle int) {
|
||||
func b17(img *image.Paletted, x, y, size, angle int) {
|
||||
m := size / 2
|
||||
|
||||
drawBlock(img, x, y, size, angle, []int{
|
||||
|
@ -419,7 +419,7 @@ func b17(img *image.Paletted, x, y, size int, angle int) {
|
|||
// |## |
|
||||
// |# |
|
||||
// ----------
|
||||
func b18(img *image.Paletted, x, y, size int, angle int) {
|
||||
func b18(img *image.Paletted, x, y, size, angle int) {
|
||||
m := size / 2
|
||||
|
||||
drawBlock(img, x, y, size, angle, []int{
|
||||
|
@ -439,7 +439,7 @@ func b18(img *image.Paletted, x, y, size int, angle int) {
|
|||
// |### ###|
|
||||
// |########|
|
||||
// ----------
|
||||
func b19(img *image.Paletted, x, y, size int, angle int) {
|
||||
func b19(img *image.Paletted, x, y, size, angle int) {
|
||||
m := size / 2
|
||||
|
||||
drawBlock(img, x, y, size, angle, []int{
|
||||
|
@ -480,7 +480,7 @@ func b19(img *image.Paletted, x, y, size int, angle int) {
|
|||
// |## |
|
||||
// |# |
|
||||
// ----------
|
||||
func b20(img *image.Paletted, x, y, size int, angle int) {
|
||||
func b20(img *image.Paletted, x, y, size, angle int) {
|
||||
m := size / 2
|
||||
q := size / 4
|
||||
|
||||
|
@ -501,7 +501,7 @@ func b20(img *image.Paletted, x, y, size int, angle int) {
|
|||
// |## |
|
||||
// |# |
|
||||
// ----------
|
||||
func b21(img *image.Paletted, x, y, size int, angle int) {
|
||||
func b21(img *image.Paletted, x, y, size, angle int) {
|
||||
m := size / 2
|
||||
q := size / 4
|
||||
|
||||
|
@ -529,7 +529,7 @@ func b21(img *image.Paletted, x, y, size int, angle int) {
|
|||
// |## ##|
|
||||
// |# #|
|
||||
// ----------
|
||||
func b22(img *image.Paletted, x, y, size int, angle int) {
|
||||
func b22(img *image.Paletted, x, y, size, angle int) {
|
||||
m := size / 2
|
||||
q := size / 4
|
||||
|
||||
|
@ -557,7 +557,7 @@ func b22(img *image.Paletted, x, y, size int, angle int) {
|
|||
// |## |
|
||||
// |# |
|
||||
// ----------
|
||||
func b23(img *image.Paletted, x, y, size int, angle int) {
|
||||
func b23(img *image.Paletted, x, y, size, angle int) {
|
||||
m := size / 2
|
||||
q := size / 4
|
||||
|
||||
|
@ -585,7 +585,7 @@ func b23(img *image.Paletted, x, y, size int, angle int) {
|
|||
// |## ## |
|
||||
// |# # |
|
||||
// ----------
|
||||
func b24(img *image.Paletted, x, y, size int, angle int) {
|
||||
func b24(img *image.Paletted, x, y, size, angle int) {
|
||||
m := size / 2
|
||||
q := size / 4
|
||||
|
||||
|
@ -613,7 +613,7 @@ func b24(img *image.Paletted, x, y, size int, angle int) {
|
|||
// |###### |
|
||||
// |#### |
|
||||
// ----------
|
||||
func b25(img *image.Paletted, x, y, size int, angle int) {
|
||||
func b25(img *image.Paletted, x, y, size, angle int) {
|
||||
m := size / 2
|
||||
q := size / 4
|
||||
|
||||
|
@ -641,7 +641,7 @@ func b25(img *image.Paletted, x, y, size int, angle int) {
|
|||
// |### ###|
|
||||
// |# #|
|
||||
// ----------
|
||||
func b26(img *image.Paletted, x, y, size int, angle int) {
|
||||
func b26(img *image.Paletted, x, y, size, angle int) {
|
||||
m := size / 2
|
||||
q := size / 4
|
||||
|
||||
|
@ -683,7 +683,7 @@ func b26(img *image.Paletted, x, y, size int, angle int) {
|
|||
// |### ##|
|
||||
// |########|
|
||||
// ----------
|
||||
func b27(img *image.Paletted, x, y, size int, angle int) {
|
||||
func b27(img *image.Paletted, x, y, size, angle int) {
|
||||
m := size / 2
|
||||
q := size / 4
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ var (
|
|||
|
||||
// rotate the points by center point (x,y)
|
||||
// angle: [0,1,2,3] means [0,90,180,270] degree
|
||||
func rotate(points []int, x, y int, angle int) {
|
||||
func rotate(points []int, x, y, angle int) {
|
||||
// the angle is only used internally, and it has been guaranteed to be 0/1/2/3, so we do not check it again
|
||||
for i := 0; i < len(points); i += 2 {
|
||||
px, py := points[i]-x, points[i+1]-y
|
||||
|
|
|
@ -149,7 +149,7 @@ func PrettyNumber(v int64) string {
|
|||
}
|
||||
|
||||
// Subtract deals with subtraction of all types of number.
|
||||
func Subtract(left interface{}, right interface{}) interface{} {
|
||||
func Subtract(left, right interface{}) interface{} {
|
||||
var rleft, rright int64
|
||||
var fleft, fright float64
|
||||
var isInt = true
|
||||
|
|
|
@ -261,14 +261,14 @@ func TestDetectEncoding(t *testing.T) {
|
|||
assert.Error(t, err)
|
||||
}
|
||||
|
||||
func stringMustStartWith(t *testing.T, expected string, value string) {
|
||||
func stringMustStartWith(t *testing.T, expected, value string) {
|
||||
assert.Equal(t, expected, string(value[:len(expected)]))
|
||||
}
|
||||
|
||||
func stringMustEndWith(t *testing.T, expected string, value string) {
|
||||
func stringMustEndWith(t *testing.T, expected, value string) {
|
||||
assert.Equal(t, expected, string(value[len(value)-len(expected):]))
|
||||
}
|
||||
|
||||
func bytesMustStartWith(t *testing.T, expected []byte, value []byte) {
|
||||
func bytesMustStartWith(t *testing.T, expected, value []byte) {
|
||||
assert.Equal(t, expected, value[:len(expected)])
|
||||
}
|
||||
|
|
|
@ -20,14 +20,14 @@ type Pagination struct {
|
|||
}
|
||||
|
||||
// NewPagination creates a new instance of the Pagination struct
|
||||
func NewPagination(total int, page int, issueNum int, numPages int) *Pagination {
|
||||
func NewPagination(total, page, issueNum, numPages int) *Pagination {
|
||||
p := &Pagination{}
|
||||
p.Paginater = paginater.New(total, page, issueNum, numPages)
|
||||
return p
|
||||
}
|
||||
|
||||
// AddParam adds a value from context identified by ctxKey as link param under a given paramKey
|
||||
func (p *Pagination) AddParam(ctx *Context, paramKey string, ctxKey string) {
|
||||
func (p *Pagination) AddParam(ctx *Context, paramKey, ctxKey string) {
|
||||
_, exists := ctx.Data[ctxKey]
|
||||
if !exists {
|
||||
return
|
||||
|
@ -38,7 +38,7 @@ func (p *Pagination) AddParam(ctx *Context, paramKey string, ctxKey string) {
|
|||
}
|
||||
|
||||
// AddParamString adds a string parameter directly
|
||||
func (p *Pagination) AddParamString(key string, value string) {
|
||||
func (p *Pagination) AddParamString(key, value string) {
|
||||
urlParam := fmt.Sprintf("%s=%v", url.QueryEscape(key), url.QueryEscape(value))
|
||||
p.urlParams = append(p.urlParams, urlParam)
|
||||
}
|
||||
|
|
|
@ -180,7 +180,7 @@ func (r *Repository) GetCommitsCount() (int64, error) {
|
|||
}
|
||||
|
||||
// GetCommitGraphsCount returns cached commit count for current view
|
||||
func (r *Repository) GetCommitGraphsCount(hidePRRefs bool, branches []string, files []string) (int64, error) {
|
||||
func (r *Repository) GetCommitGraphsCount(hidePRRefs bool, branches, files []string) (int64, error) {
|
||||
cacheKey := fmt.Sprintf("commits-count-%d-graph-%t-%s-%s", r.Repository.ID, hidePRRefs, branches, files)
|
||||
|
||||
return cache.GetInt64(cacheKey, func() (int64, error) {
|
||||
|
@ -206,7 +206,7 @@ func (r *Repository) BranchNameSubURL() string {
|
|||
}
|
||||
|
||||
// FileExists returns true if a file exists in the given repo branch
|
||||
func (r *Repository) FileExists(path string, branch string) (bool, error) {
|
||||
func (r *Repository) FileExists(path, branch string) (bool, error) {
|
||||
if branch == "" {
|
||||
branch = r.Repository.DefaultBranch
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ import (
|
|||
"code.gitea.io/gitea/modules/json"
|
||||
)
|
||||
|
||||
func wrapNewlines(w io.Writer, prefix []byte, value []byte) (sum int64, err error) {
|
||||
func wrapNewlines(w io.Writer, prefix, value []byte) (sum int64, err error) {
|
||||
if len(value) == 0 {
|
||||
return
|
||||
}
|
||||
|
|
|
@ -386,7 +386,7 @@ type DivergeObject struct {
|
|||
Behind int
|
||||
}
|
||||
|
||||
func checkDivergence(repoPath string, baseBranch string, targetBranch string) (int, error) {
|
||||
func checkDivergence(repoPath, baseBranch, targetBranch string) (int, error) {
|
||||
branches := fmt.Sprintf("%s..%s", baseBranch, targetBranch)
|
||||
cmd := NewCommand("rev-list", "--count", branches)
|
||||
stdout, err := cmd.RunInDir(repoPath)
|
||||
|
@ -401,7 +401,7 @@ func checkDivergence(repoPath string, baseBranch string, targetBranch string) (i
|
|||
}
|
||||
|
||||
// GetDivergingCommits returns the number of commits a targetBranch is ahead or behind a baseBranch
|
||||
func GetDivergingCommits(repoPath string, baseBranch string, targetBranch string) (DivergeObject, error) {
|
||||
func GetDivergingCommits(repoPath, baseBranch, targetBranch string) (DivergeObject, error) {
|
||||
// $(git rev-list --count master..feature) commits ahead of master
|
||||
ahead, errorAhead := checkDivergence(repoPath, baseBranch, targetBranch)
|
||||
if errorAhead != nil {
|
||||
|
|
|
@ -264,7 +264,7 @@ func (repo *Repository) FilesCountBetween(startCommitID, endCommitID string) (in
|
|||
|
||||
// CommitsBetween returns a list that contains commits between [before, last).
|
||||
// If before is detached (removed by reset + push) it is not included.
|
||||
func (repo *Repository) CommitsBetween(last *Commit, before *Commit) ([]*Commit, error) {
|
||||
func (repo *Repository) CommitsBetween(last, before *Commit) ([]*Commit, error) {
|
||||
var stdout []byte
|
||||
var err error
|
||||
if before == nil {
|
||||
|
@ -284,7 +284,7 @@ func (repo *Repository) CommitsBetween(last *Commit, before *Commit) ([]*Commit,
|
|||
}
|
||||
|
||||
// CommitsBetweenLimit returns a list that contains at most limit commits skipping the first skip commits between [before, last)
|
||||
func (repo *Repository) CommitsBetweenLimit(last *Commit, before *Commit, limit, skip int) ([]*Commit, error) {
|
||||
func (repo *Repository) CommitsBetweenLimit(last, before *Commit, limit, skip int) ([]*Commit, error) {
|
||||
var stdout []byte
|
||||
var err error
|
||||
if before == nil {
|
||||
|
|
|
@ -27,7 +27,7 @@ type CompareInfo struct {
|
|||
}
|
||||
|
||||
// GetMergeBase checks and returns merge base of two branches and the reference used as base.
|
||||
func (repo *Repository) GetMergeBase(tmpRemote string, base, head string) (string, string, error) {
|
||||
func (repo *Repository) GetMergeBase(tmpRemote, base, head string) (string, string, error) {
|
||||
if tmpRemote == "" {
|
||||
tmpRemote = "origin"
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ type CommitTreeOpts struct {
|
|||
}
|
||||
|
||||
// CommitTree creates a commit from a given tree id for the user with provided message
|
||||
func (repo *Repository) CommitTree(author *Signature, committer *Signature, tree *Tree, opts CommitTreeOpts) (SHA1, error) {
|
||||
func (repo *Repository) CommitTree(author, committer *Signature, tree *Tree, opts CommitTreeOpts) (SHA1, error) {
|
||||
err := LoadGitVersion()
|
||||
if err != nil {
|
||||
return SHA1{}, err
|
||||
|
|
|
@ -125,7 +125,7 @@ func SplitRefName(refStr string) (string, string) {
|
|||
// 0 is false, true
|
||||
// Any other integer is true, true
|
||||
// Anything else will return false, false
|
||||
func ParseBool(value string) (result bool, valid bool) {
|
||||
func ParseBool(value string) (result, valid bool) {
|
||||
// Empty strings are true but invalid
|
||||
if len(value) == 0 {
|
||||
return true, false
|
||||
|
|
|
@ -17,7 +17,7 @@ import (
|
|||
)
|
||||
|
||||
// GetCommitGraph return a list of commit (GraphItems) from all branches
|
||||
func GetCommitGraph(r *git.Repository, page int, maxAllowedColors int, hidePRRefs bool, branches, files []string) (*Graph, error) {
|
||||
func GetCommitGraph(r *git.Repository, page, maxAllowedColors int, hidePRRefs bool, branches, files []string) (*Graph, error) {
|
||||
format := "DATA:%D|%H|%ad|%h|%s"
|
||||
|
||||
if page == 0 {
|
||||
|
|
|
@ -39,7 +39,7 @@ func isBuiltin(s string) bool {
|
|||
}
|
||||
|
||||
// ParseHostMatchList parses the host list HostMatchList
|
||||
func ParseHostMatchList(settingKeyHint string, hostList string) *HostMatchList {
|
||||
func ParseHostMatchList(settingKeyHint, hostList string) *HostMatchList {
|
||||
hl := &HostMatchList{SettingKeyHint: settingKeyHint, SettingValue: hostList}
|
||||
for _, s := range strings.Split(hostList, ",") {
|
||||
s = strings.ToLower(strings.TrimSpace(s))
|
||||
|
@ -59,7 +59,7 @@ func ParseHostMatchList(settingKeyHint string, hostList string) *HostMatchList {
|
|||
}
|
||||
|
||||
// ParseSimpleMatchList parse a simple matchlist (no built-in networks, no CIDR support, only wildcard pattern match)
|
||||
func ParseSimpleMatchList(settingKeyHint string, matchList string) *HostMatchList {
|
||||
func ParseSimpleMatchList(settingKeyHint, matchList string) *HostMatchList {
|
||||
hl := &HostMatchList{
|
||||
SettingKeyHint: settingKeyHint,
|
||||
SettingValue: matchList,
|
||||
|
|
|
@ -13,7 +13,7 @@ import (
|
|||
)
|
||||
|
||||
// NewDialContext returns a DialContext for Transport, the DialContext will do allow/block list check
|
||||
func NewDialContext(usage string, allowList *HostMatchList, blockList *HostMatchList) func(ctx context.Context, network, addr string) (net.Conn, error) {
|
||||
func NewDialContext(usage string, allowList, blockList *HostMatchList) func(ctx context.Context, network, addr string) (net.Conn, error) {
|
||||
// How Go HTTP Client works with redirection:
|
||||
// transport.RoundTrip URL=http://domain.com, Host=domain.com
|
||||
// transport.DialContext addrOrHost=domain.com:80
|
||||
|
|
|
@ -80,7 +80,7 @@ func (l *MultiChannelledLogger) Log(skip int, level Level, format string, v ...i
|
|||
}
|
||||
|
||||
// SendLog sends a log event at the provided level with the information given
|
||||
func (l *MultiChannelledLogger) SendLog(level Level, caller, filename string, line int, msg string, stack string) error {
|
||||
func (l *MultiChannelledLogger) SendLog(level Level, caller, filename string, line int, msg, stack string) error {
|
||||
if l.GetLevel() > level {
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ func (logger *WriterLogger) GetStacktraceLevel() Level {
|
|||
}
|
||||
|
||||
// Copy of cheap integer to fixed-width decimal to ascii from logger.
|
||||
func itoa(buf *[]byte, i int, wid int) {
|
||||
func itoa(buf *[]byte, i, wid int) {
|
||||
var logger [20]byte
|
||||
bp := len(logger) - 1
|
||||
for i >= 10 || wid > 1 {
|
||||
|
|
|
@ -229,7 +229,7 @@ func (p *prefixedIDs) Generate(value []byte, kind ast.NodeKind) []byte {
|
|||
}
|
||||
|
||||
// Generate generates a new element id.
|
||||
func (p *prefixedIDs) GenerateWithDefault(value []byte, dft []byte) []byte {
|
||||
func (p *prefixedIDs) GenerateWithDefault(value, dft []byte) []byte {
|
||||
result := common.CleanValue(value)
|
||||
if len(result) == 0 {
|
||||
result = dft
|
||||
|
|
|
@ -179,7 +179,7 @@ func (a *actionNotifier) NotifyTransferRepository(doer *user_model.User, repo *r
|
|||
}
|
||||
}
|
||||
|
||||
func (a *actionNotifier) NotifyCreateRepository(doer *user_model.User, u *user_model.User, repo *repo_model.Repository) {
|
||||
func (a *actionNotifier) NotifyCreateRepository(doer, u *user_model.User, repo *repo_model.Repository) {
|
||||
if err := models.NotifyWatchers(&models.Action{
|
||||
ActUserID: doer.ID,
|
||||
ActUser: doer,
|
||||
|
|
|
@ -122,7 +122,7 @@ func (*NullNotifier) NotifyIssueChangeLabels(doer *user_model.User, issue *model
|
|||
}
|
||||
|
||||
// NotifyCreateRepository places a place holder function
|
||||
func (*NullNotifier) NotifyCreateRepository(doer *user_model.User, u *user_model.User, repo *repo_model.Repository) {
|
||||
func (*NullNotifier) NotifyCreateRepository(doer, u *user_model.User, repo *repo_model.Repository) {
|
||||
}
|
||||
|
||||
// NotifyDeleteRepository places a place holder function
|
||||
|
@ -134,7 +134,7 @@ func (*NullNotifier) NotifyForkRepository(doer *user_model.User, oldRepo, repo *
|
|||
}
|
||||
|
||||
// NotifyMigrateRepository places a place holder function
|
||||
func (*NullNotifier) NotifyMigrateRepository(doer *user_model.User, u *user_model.User, repo *repo_model.Repository) {
|
||||
func (*NullNotifier) NotifyMigrateRepository(doer, u *user_model.User, repo *repo_model.Repository) {
|
||||
}
|
||||
|
||||
// NotifyPushCommits notifies commits pushed to notifiers
|
||||
|
|
|
@ -115,7 +115,7 @@ func (r *indexerNotifier) NotifyDeleteRepository(doer *user_model.User, repo *re
|
|||
}
|
||||
}
|
||||
|
||||
func (r *indexerNotifier) NotifyMigrateRepository(doer *user_model.User, u *user_model.User, repo *repo_model.Repository) {
|
||||
func (r *indexerNotifier) NotifyMigrateRepository(doer, u *user_model.User, repo *repo_model.Repository) {
|
||||
issue_indexer.UpdateRepoIndexer(repo)
|
||||
if setting.Indexer.RepoIndexerEnabled && !repo.IsEmpty {
|
||||
code_indexer.UpdateRepoIndexer(repo)
|
||||
|
|
|
@ -210,14 +210,14 @@ func NotifyIssueChangeLabels(doer *user_model.User, issue *models.Issue,
|
|||
}
|
||||
|
||||
// NotifyCreateRepository notifies create repository to notifiers
|
||||
func NotifyCreateRepository(doer *user_model.User, u *user_model.User, repo *repo_model.Repository) {
|
||||
func NotifyCreateRepository(doer, u *user_model.User, repo *repo_model.Repository) {
|
||||
for _, notifier := range notifiers {
|
||||
notifier.NotifyCreateRepository(doer, u, repo)
|
||||
}
|
||||
}
|
||||
|
||||
// NotifyMigrateRepository notifies create repository to notifiers
|
||||
func NotifyMigrateRepository(doer *user_model.User, u *user_model.User, repo *repo_model.Repository) {
|
||||
func NotifyMigrateRepository(doer, u *user_model.User, repo *repo_model.Repository) {
|
||||
for _, notifier := range notifiers {
|
||||
notifier.NotifyMigrateRepository(doer, u, repo)
|
||||
}
|
||||
|
|
|
@ -102,7 +102,7 @@ func (m *webhookNotifier) NotifyForkRepository(doer *user_model.User, oldRepo, r
|
|||
}
|
||||
}
|
||||
|
||||
func (m *webhookNotifier) NotifyCreateRepository(doer *user_model.User, u *user_model.User, repo *repo_model.Repository) {
|
||||
func (m *webhookNotifier) NotifyCreateRepository(doer, u *user_model.User, repo *repo_model.Repository) {
|
||||
// Add to hook queue for created repo after session commit.
|
||||
if err := webhook_services.PrepareWebhooks(repo, webhook.HookEventRepository, &api.RepositoryPayload{
|
||||
Action: api.HookRepoCreated,
|
||||
|
@ -127,7 +127,7 @@ func (m *webhookNotifier) NotifyDeleteRepository(doer *user_model.User, repo *re
|
|||
}
|
||||
}
|
||||
|
||||
func (m *webhookNotifier) NotifyMigrateRepository(doer *user_model.User, u *user_model.User, repo *repo_model.Repository) {
|
||||
func (m *webhookNotifier) NotifyMigrateRepository(doer, u *user_model.User, repo *repo_model.Repository) {
|
||||
// Add to hook queue for created repo after session commit.
|
||||
if err := webhook_services.PrepareWebhooks(repo, webhook.HookEventRepository, &api.RepositoryPayload{
|
||||
Action: api.HookRepoCreated,
|
||||
|
|
|
@ -151,7 +151,7 @@ func newKeywords() {
|
|||
})
|
||||
}
|
||||
|
||||
func doNewKeywords(close []string, reopen []string) {
|
||||
func doNewKeywords(close, reopen []string) {
|
||||
issueCloseKeywordsPat = makeKeywordsPat(close)
|
||||
issueReopenKeywordsPat = makeKeywordsPat(reopen)
|
||||
}
|
||||
|
@ -467,7 +467,7 @@ func findAllIssueReferencesBytes(content []byte, links []string) []*rawReference
|
|||
return ret
|
||||
}
|
||||
|
||||
func getCrossReference(content []byte, start, end int, fromLink bool, prOnly bool) *rawReference {
|
||||
func getCrossReference(content []byte, start, end int, fromLink, prOnly bool) *rawReference {
|
||||
sep := bytes.IndexAny(content[start:end], "#!")
|
||||
if sep < 0 {
|
||||
return nil
|
||||
|
@ -537,7 +537,7 @@ func findActionKeywords(content []byte, start int) (XRefAction, *RefSpan) {
|
|||
}
|
||||
|
||||
// IsXrefActionable returns true if the xref action is actionable (i.e. produces a result when resolved)
|
||||
func IsXrefActionable(ref *RenderizableReference, extTracker bool, alphaNum bool) bool {
|
||||
func IsXrefActionable(ref *RenderizableReference, extTracker, alphaNum bool) bool {
|
||||
if extTracker {
|
||||
// External issues cannot be automatically closed
|
||||
return false
|
||||
|
|
|
@ -65,7 +65,7 @@ func AesDecrypt(key, text []byte) ([]byte, error) {
|
|||
}
|
||||
|
||||
// EncryptSecret encrypts a string with given key into a hex string
|
||||
func EncryptSecret(key string, str string) (string, error) {
|
||||
func EncryptSecret(key, str string) (string, error) {
|
||||
keyHash := sha256.Sum256([]byte(key))
|
||||
plaintext := []byte(str)
|
||||
ciphertext, err := AesEncrypt(keyHash[:], plaintext)
|
||||
|
@ -76,7 +76,7 @@ func EncryptSecret(key string, str string) (string, error) {
|
|||
}
|
||||
|
||||
// DecryptSecret decrypts a previously encrypted hex string
|
||||
func DecryptSecret(key string, cipherhex string) (string, error) {
|
||||
func DecryptSecret(key, cipherhex string) (string, error) {
|
||||
keyHash := sha256.Sum256([]byte(key))
|
||||
ciphertext, err := hex.DecodeString(cipherhex)
|
||||
if err != nil {
|
||||
|
|
|
@ -67,7 +67,7 @@ func AddSubLogDescription(key string, subLogDescription SubLogDescription) bool
|
|||
}
|
||||
|
||||
// RemoveSubLogDescription removes a sub log description
|
||||
func RemoveSubLogDescription(key string, name string) bool {
|
||||
func RemoveSubLogDescription(key, name string) bool {
|
||||
descriptionLock.Lock()
|
||||
defer descriptionLock.Unlock()
|
||||
desc, ok := logDescriptions[key]
|
||||
|
@ -119,7 +119,7 @@ func getLogLevel(section *ini.Section, key string, defaultValue log.Level) log.L
|
|||
return log.FromString(value)
|
||||
}
|
||||
|
||||
func getStacktraceLogLevel(section *ini.Section, key string, defaultValue string) string {
|
||||
func getStacktraceLogLevel(section *ini.Section, key, defaultValue string) string {
|
||||
value := section.Key(key).MustString(defaultValue)
|
||||
return log.FromString(value).String()
|
||||
}
|
||||
|
|
|
@ -1115,7 +1115,7 @@ func generateSaveInternalToken() {
|
|||
}
|
||||
|
||||
// MakeAbsoluteAssetURL returns the absolute asset url prefix without a trailing slash
|
||||
func MakeAbsoluteAssetURL(appURL string, staticURLPrefix string) string {
|
||||
func MakeAbsoluteAssetURL(appURL, staticURLPrefix string) string {
|
||||
parsedPrefix, err := url.Parse(strings.TrimSuffix(staticURLPrefix, "/"))
|
||||
if err != nil {
|
||||
log.Fatal("Unable to parse STATIC_URL_PREFIX: %v", err)
|
||||
|
@ -1134,7 +1134,7 @@ func MakeAbsoluteAssetURL(appURL string, staticURLPrefix string) string {
|
|||
}
|
||||
|
||||
// MakeManifestData generates web app manifest JSON
|
||||
func MakeManifestData(appName string, appURL string, absoluteAssetURL string) []byte {
|
||||
func MakeManifestData(appName, appURL, absoluteAssetURL string) []byte {
|
||||
type manifestIcon struct {
|
||||
Src string `json:"src"`
|
||||
Type string `json:"type"`
|
||||
|
|
|
@ -263,7 +263,7 @@ func sshConnectionFailed(conn net.Conn, err error) {
|
|||
}
|
||||
|
||||
// Listen starts a SSH server listens on given port.
|
||||
func Listen(host string, port int, ciphers []string, keyExchanges []string, macs []string) {
|
||||
func Listen(host string, port int, ciphers, keyExchanges, macs []string) {
|
||||
srv := ssh.Server{
|
||||
Addr: net.JoinHostPort(host, strconv.Itoa(port)),
|
||||
PublicKeyHandler: publicKeyHandler,
|
||||
|
|
|
@ -524,7 +524,7 @@ func parseOthers(defaultSize int, defaultClass string, others ...interface{}) (i
|
|||
}
|
||||
|
||||
// AvatarHTML creates the HTML for an avatar
|
||||
func AvatarHTML(src string, size int, class string, name string) template.HTML {
|
||||
func AvatarHTML(src string, size int, class, name string) template.HTML {
|
||||
sizeStr := fmt.Sprintf(`%d`, size)
|
||||
|
||||
if name == "" {
|
||||
|
@ -594,7 +594,7 @@ func RepoAvatar(repo *repo_model.Repository, others ...interface{}) template.HTM
|
|||
}
|
||||
|
||||
// AvatarByEmail renders avatars by email address. args: email, name, size (int), class (string)
|
||||
func AvatarByEmail(email string, name string, others ...interface{}) template.HTML {
|
||||
func AvatarByEmail(email, name string, others ...interface{}) template.HTML {
|
||||
size, class := parseOthers(avatars.DefaultAvatarPixelSize, "ui avatar image", others...)
|
||||
src := avatars.GenerateEmailAvatarFastLink(email, size*setting.Avatar.RenderedSizeFactor)
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ func (err ErrFileTypeForbidden) Error() string {
|
|||
var wildcardTypeRe = regexp.MustCompile(`^[a-z]+/\*$`)
|
||||
|
||||
// Verify validates whether a file is allowed to be uploaded.
|
||||
func Verify(buf []byte, fileName string, allowedTypesStr string) error {
|
||||
func Verify(buf []byte, fileName, allowedTypesStr string) error {
|
||||
allowedTypesStr = strings.ReplaceAll(allowedTypesStr, "|", ",") // compat for old config format
|
||||
|
||||
allowedTypes := []string{}
|
||||
|
|
|
@ -71,7 +71,7 @@ func IsInt64InSlice(target int64, slice []int64) bool {
|
|||
}
|
||||
|
||||
// IsEqualSlice returns true if slices are equal.
|
||||
func IsEqualSlice(target []string, source []string) bool {
|
||||
func IsEqualSlice(target, source []string) bool {
|
||||
if len(target) != len(source) {
|
||||
return false
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ import (
|
|||
|
||||
// EnsureAbsolutePath ensure that a path is absolute, making it
|
||||
// relative to absoluteBase if necessary
|
||||
func EnsureAbsolutePath(path string, absoluteBase string) string {
|
||||
func EnsureAbsolutePath(path, absoluteBase string) string {
|
||||
if filepath.IsAbs(path) {
|
||||
return path
|
||||
}
|
||||
|
|
|
@ -119,7 +119,7 @@ func DeleteCSRFCookie(resp http.ResponseWriter) {
|
|||
|
||||
// SetCookie set the cookies
|
||||
// TODO: Copied from gitea.com/macaron/macaron and should be improved after macaron removed.
|
||||
func SetCookie(resp http.ResponseWriter, name string, value string, others ...interface{}) {
|
||||
func SetCookie(resp http.ResponseWriter, name, value string, others ...interface{}) {
|
||||
cookie := http.Cookie{}
|
||||
cookie.Name = name
|
||||
cookie.Value = url.QueryEscape(value)
|
||||
|
|
|
@ -251,7 +251,7 @@ func (r *Route) Any(pattern string, h ...interface{}) {
|
|||
}
|
||||
|
||||
// Route delegate special methods
|
||||
func (r *Route) Route(pattern string, methods string, h ...interface{}) {
|
||||
func (r *Route) Route(pattern, methods string, h ...interface{}) {
|
||||
p := r.getPattern(pattern)
|
||||
ms := strings.Split(methods, ",")
|
||||
var middlewares = r.getMiddlewares(h)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue