mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 00:20:25 +08:00 
			
		
		
		
	format with gofumpt (#18184)
* gofumpt -w -l . * gofumpt -w -l -extra . * Add linter * manual fix * change make fmt
This commit is contained in:
		@@ -56,29 +56,29 @@ type APIInvalidTopicsError struct {
 | 
			
		||||
	InvalidTopics []string `json:"invalidTopics"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//APIEmpty is an empty response
 | 
			
		||||
// APIEmpty is an empty response
 | 
			
		||||
// swagger:response empty
 | 
			
		||||
type APIEmpty struct{}
 | 
			
		||||
 | 
			
		||||
//APIForbiddenError is a forbidden error response
 | 
			
		||||
// APIForbiddenError is a forbidden error response
 | 
			
		||||
// swagger:response forbidden
 | 
			
		||||
type APIForbiddenError struct {
 | 
			
		||||
	APIError
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//APINotFound is a not found empty response
 | 
			
		||||
// APINotFound is a not found empty response
 | 
			
		||||
// swagger:response notFound
 | 
			
		||||
type APINotFound struct{}
 | 
			
		||||
 | 
			
		||||
//APIConflict is a conflict empty response
 | 
			
		||||
// APIConflict is a conflict empty response
 | 
			
		||||
// swagger:response conflict
 | 
			
		||||
type APIConflict struct{}
 | 
			
		||||
 | 
			
		||||
//APIRedirect is a redirect response
 | 
			
		||||
// APIRedirect is a redirect response
 | 
			
		||||
// swagger:response redirect
 | 
			
		||||
type APIRedirect struct{}
 | 
			
		||||
 | 
			
		||||
//APIString is a string response
 | 
			
		||||
// APIString is a string response
 | 
			
		||||
// swagger:response string
 | 
			
		||||
type APIString string
 | 
			
		||||
 | 
			
		||||
@@ -269,13 +269,12 @@ func APIAuth(authMethod auth_service.Method) func(*APIContext) {
 | 
			
		||||
 | 
			
		||||
// APIContexter returns apicontext as middleware
 | 
			
		||||
func APIContexter() func(http.Handler) http.Handler {
 | 
			
		||||
	var csrfOpts = getCsrfOpts()
 | 
			
		||||
	csrfOpts := getCsrfOpts()
 | 
			
		||||
 | 
			
		||||
	return func(next http.Handler) http.Handler {
 | 
			
		||||
 | 
			
		||||
		return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
 | 
			
		||||
			var locale = middleware.Locale(w, req)
 | 
			
		||||
			var ctx = APIContext{
 | 
			
		||||
			locale := middleware.Locale(w, req)
 | 
			
		||||
			ctx := APIContext{
 | 
			
		||||
				Context: &Context{
 | 
			
		||||
					Resp:    NewResponse(w),
 | 
			
		||||
					Data:    map[string]interface{}{},
 | 
			
		||||
@@ -354,7 +353,7 @@ func ReferencesGitRepo(allowEmpty bool) func(ctx *APIContext) (cancel context.Ca
 | 
			
		||||
// NotFound handles 404s for APIContext
 | 
			
		||||
// String will replace message, errors will be added to a slice
 | 
			
		||||
func (ctx *APIContext) NotFound(objs ...interface{}) {
 | 
			
		||||
	var message = ctx.Tr("error.not_found")
 | 
			
		||||
	message := ctx.Tr("error.not_found")
 | 
			
		||||
	var errors []string
 | 
			
		||||
	for _, obj := range objs {
 | 
			
		||||
		// Ignore nil
 | 
			
		||||
 
 | 
			
		||||
@@ -16,7 +16,7 @@ import (
 | 
			
		||||
 | 
			
		||||
func TestGenAPILinks(t *testing.T) {
 | 
			
		||||
	setting.AppURL = "http://localhost:3000/"
 | 
			
		||||
	var kases = map[string][]string{
 | 
			
		||||
	kases := map[string][]string{
 | 
			
		||||
		"api/v1/repos/jerrykan/example-repo/issues?state=all": {
 | 
			
		||||
			`<http://localhost:3000/api/v1/repos/jerrykan/example-repo/issues?page=2&state=all>; rel="next"`,
 | 
			
		||||
			`<http://localhost:3000/api/v1/repos/jerrykan/example-repo/issues?page=5&state=all>; rel="last"`,
 | 
			
		||||
 
 | 
			
		||||
@@ -13,8 +13,10 @@ import (
 | 
			
		||||
	"gitea.com/go-chi/captcha"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
var imageCaptchaOnce sync.Once
 | 
			
		||||
var cpt *captcha.Captcha
 | 
			
		||||
var (
 | 
			
		||||
	imageCaptchaOnce sync.Once
 | 
			
		||||
	cpt              *captcha.Captcha
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// GetImageCaptcha returns global image captcha
 | 
			
		||||
func GetImageCaptcha() *captcha.Captcha {
 | 
			
		||||
 
 | 
			
		||||
@@ -362,7 +362,7 @@ func (ctx *Context) ServeStream(rd io.Reader, name string) {
 | 
			
		||||
 | 
			
		||||
// Error returned an error to web browser
 | 
			
		||||
func (ctx *Context) Error(status int, contents ...string) {
 | 
			
		||||
	var v = http.StatusText(status)
 | 
			
		||||
	v := http.StatusText(status)
 | 
			
		||||
	if len(contents) > 0 {
 | 
			
		||||
		v = contents[0]
 | 
			
		||||
	}
 | 
			
		||||
@@ -606,16 +606,16 @@ func Auth(authMethod auth.Method) func(*Context) {
 | 
			
		||||
 | 
			
		||||
// Contexter initializes a classic context for a request.
 | 
			
		||||
func Contexter() func(next http.Handler) http.Handler {
 | 
			
		||||
	var rnd = templates.HTMLRenderer()
 | 
			
		||||
	var csrfOpts = getCsrfOpts()
 | 
			
		||||
	rnd := templates.HTMLRenderer()
 | 
			
		||||
	csrfOpts := getCsrfOpts()
 | 
			
		||||
 | 
			
		||||
	return func(next http.Handler) http.Handler {
 | 
			
		||||
		return http.HandlerFunc(func(resp http.ResponseWriter, req *http.Request) {
 | 
			
		||||
			var locale = middleware.Locale(resp, req)
 | 
			
		||||
			var startTime = time.Now()
 | 
			
		||||
			var link = setting.AppSubURL + strings.TrimSuffix(req.URL.EscapedPath(), "/")
 | 
			
		||||
			locale := middleware.Locale(resp, req)
 | 
			
		||||
			startTime := time.Now()
 | 
			
		||||
			link := setting.AppSubURL + strings.TrimSuffix(req.URL.EscapedPath(), "/")
 | 
			
		||||
 | 
			
		||||
			var ctx = Context{
 | 
			
		||||
			ctx := Context{
 | 
			
		||||
				Resp:    NewResponse(resp),
 | 
			
		||||
				Cache:   mc.GetCache(),
 | 
			
		||||
				Locale:  locale,
 | 
			
		||||
 
 | 
			
		||||
@@ -57,9 +57,9 @@ type csrf struct {
 | 
			
		||||
	Form string
 | 
			
		||||
	// Cookie name value for setting and getting csrf token.
 | 
			
		||||
	Cookie string
 | 
			
		||||
	//Cookie domain
 | 
			
		||||
	// Cookie domain
 | 
			
		||||
	CookieDomain string
 | 
			
		||||
	//Cookie path
 | 
			
		||||
	// Cookie path
 | 
			
		||||
	CookiePath string
 | 
			
		||||
	// Cookie HttpOnly flag value used for the csrf token.
 | 
			
		||||
	CookieHTTPOnly bool
 | 
			
		||||
 
 | 
			
		||||
@@ -44,9 +44,7 @@ func (ctx *PrivateContext) Err() error {
 | 
			
		||||
	return ctx.Req.Context().Err()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
var (
 | 
			
		||||
	privateContextKey interface{} = "default_private_context"
 | 
			
		||||
)
 | 
			
		||||
var privateContextKey interface{} = "default_private_context"
 | 
			
		||||
 | 
			
		||||
// WithPrivateContext set up private context in request
 | 
			
		||||
func WithPrivateContext(req *http.Request, ctx *PrivateContext) *http.Request {
 | 
			
		||||
 
 | 
			
		||||
@@ -111,7 +111,6 @@ type CanCommitToBranchResults struct {
 | 
			
		||||
//   and branch is not protected for push
 | 
			
		||||
func (r *Repository) CanCommitToBranch(ctx context.Context, doer *user_model.User) (CanCommitToBranchResults, error) {
 | 
			
		||||
	protectedBranch, err := models.GetProtectedBranchBy(r.Repository.ID, r.BranchName)
 | 
			
		||||
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return CanCommitToBranchResults{}, err
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
@@ -17,9 +17,7 @@ type ResponseWriter interface {
 | 
			
		||||
	Size() int
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
var (
 | 
			
		||||
	_ ResponseWriter = &Response{}
 | 
			
		||||
)
 | 
			
		||||
var _ ResponseWriter = &Response{}
 | 
			
		||||
 | 
			
		||||
// Response represents a response
 | 
			
		||||
type Response struct {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user