Skip to content

Commit db43841

Browse files
committed
Merge branch 'master' of github.com:go-gitea/gitea into template-branch-prot
2 parents b5c7eaa + b2c20b6 commit db43841

File tree

1,984 files changed

+117608
-73201
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,984 files changed

+117608
-73201
lines changed

.drone.yml

Lines changed: 67 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ workspace:
1010
base: /go
1111
path: src/code.gitea.io/gitea
1212

13+
trigger:
14+
event:
15+
- push
16+
- tag
17+
- pull_request
18+
1319
steps:
1420
- name: deps-frontend
1521
pull: always
@@ -63,7 +69,7 @@ steps:
6369

6470
- name: checks-backend
6571
pull: always
66-
image: golang:1.14
72+
image: golang:1.15
6773
commands:
6874
- make checks-backend
6975
depends_on: [lint-backend]
@@ -76,7 +82,7 @@ steps:
7682

7783
- name: build-backend-no-gcc
7884
pull: always
79-
image: golang:1.13 # this step is kept as the lowest version of golang that we support
85+
image: golang:1.14 # this step is kept as the lowest version of golang that we support
8086
environment:
8187
GO111MODULE: on
8288
GOPROXY: off
@@ -131,6 +137,12 @@ platform:
131137
depends_on:
132138
- compliance
133139

140+
trigger:
141+
event:
142+
- push
143+
- tag
144+
- pull_request
145+
134146
workspace:
135147
base: /go
136148
path: src/code.gitea.io/gitea
@@ -164,7 +176,7 @@ services:
164176
image: elasticsearch:7.5.0
165177

166178
- name: minio
167-
image: minio/minio:RELEASE.2020-10-09T22-55-05Z
179+
image: minio/minio:RELEASE.2021-01-16T02-19-44Z
168180
commands:
169181
- minio server /data
170182
environment:
@@ -306,6 +318,12 @@ platform:
306318
depends_on:
307319
- compliance
308320

321+
trigger:
322+
event:
323+
- push
324+
- tag
325+
- pull_request
326+
309327
workspace:
310328
base: /go
311329
path: src/code.gitea.io/gitea
@@ -404,7 +422,7 @@ steps:
404422

405423
- name: update
406424
pull: default
407-
image: alpine:3.12
425+
image: alpine:3.13
408426
commands:
409427
- ./build/update-locales.sh
410428

@@ -433,6 +451,45 @@ steps:
433451
CROWDIN_KEY:
434452
from_secret: crowdin_key
435453

454+
---
455+
kind: pipeline
456+
name: update_gitignore_and_licenses
457+
458+
platform:
459+
os: linux
460+
arch: amd64
461+
462+
workspace:
463+
base: /go
464+
path: src/code.gitea.io/gitea
465+
466+
trigger:
467+
branch:
468+
- master
469+
event:
470+
- cron
471+
cron:
472+
- update_gitignore_and_licenses
473+
474+
steps:
475+
- name: download
476+
image: golang:1.15
477+
commands:
478+
- timeout -s ABRT 40m make generate-license generate-gitignore
479+
480+
- name: push
481+
pull: always
482+
image: appleboy/drone-git-push
483+
settings:
484+
author_email: "[email protected]"
485+
author_name: GiteaBot
486+
commit: true
487+
commit_message: "[skip ci] Updated licenses and gitignores "
488+
remote: "[email protected]:go-gitea/gitea.git"
489+
environment:
490+
GIT_PUSH_SSH_KEY:
491+
from_secret: git_push_ssh_key
492+
436493
---
437494
kind: pipeline
438495
name: release-latest
@@ -623,6 +680,12 @@ platform:
623680
depends_on:
624681
- compliance
625682

683+
trigger:
684+
event:
685+
- push
686+
- tag
687+
- pull_request
688+
626689
steps:
627690
- name: build-docs
628691
pull: always

.github/FUNDING.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
open_collective: gitea
2+
custom: https://www.bountysource.com/teams/gitea

.golangci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ issues:
7070
- path: modules/log/
7171
linters:
7272
- errcheck
73-
- path: routers/routes/macaron.go
73+
- path: routers/routes/web.go
7474
linters:
7575
- dupl
7676
- path: routers/api/v1/repo/issue_subscription.go

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
###################################
33
#Build stage
4-
FROM golang:1.15-alpine3.12 AS build-env
4+
FROM golang:1.15-alpine3.13 AS build-env
55

66
ARG GOPROXY
77
ENV GOPROXY ${GOPROXY:-direct}
@@ -22,7 +22,7 @@ WORKDIR ${GOPATH}/src/code.gitea.io/gitea
2222
RUN if [ -n "${GITEA_VERSION}" ]; then git checkout "${GITEA_VERSION}"; fi \
2323
&& make clean-all build
2424

25-
FROM alpine:3.12
25+
FROM alpine:3.13
2626
LABEL maintainer="[email protected]"
2727

2828
EXPOSE 22 3000

Dockerfile.rootless

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
###################################
33
#Build stage
4-
FROM golang:1.15-alpine3.12 AS build-env
4+
FROM golang:1.15-alpine3.13 AS build-env
55

66
ARG GOPROXY
77
ENV GOPROXY ${GOPROXY:-direct}
@@ -22,7 +22,7 @@ WORKDIR ${GOPATH}/src/code.gitea.io/gitea
2222
RUN if [ -n "${GITEA_VERSION}" ]; then git checkout "${GITEA_VERSION}"; fi \
2323
&& make clean-all build
2424

25-
FROM alpine:3.12
25+
FROM alpine:3.13
2626
LABEL maintainer="[email protected]"
2727

2828
EXPOSE 2222 3000

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ HAS_GO = $(shell hash $(GO) > /dev/null 2>&1 && echo "GO" || echo "NOGO" )
2525
COMMA := ,
2626

2727
XGO_VERSION := go-1.15.x
28-
MIN_GO_VERSION := 001013000
28+
MIN_GO_VERSION := 001014000
2929
MIN_NODE_VERSION := 010013000
3030

3131
DOCKER_IMAGE ?= gitea/gitea
@@ -232,7 +232,7 @@ fmt:
232232
vet:
233233
@echo "Running go vet..."
234234
@$(GO) vet $(GO_PACKAGES)
235-
@$(GO) build -mod=vendor code.gitea.io/gitea-vet
235+
@GOOS= GOARCH= $(GO) build -mod=vendor code.gitea.io/gitea-vet
236236
@$(GO) vet -vettool=gitea-vet $(GO_PACKAGES)
237237

238238
.PHONY: $(TAGS_EVIDENCE)
@@ -709,7 +709,7 @@ pr\#%: clean-all
709709
golangci-lint:
710710
@hash golangci-lint > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
711711
export BINARY="golangci-lint"; \
712-
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(GOPATH)/bin v1.31.0; \
712+
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(GOPATH)/bin v1.35.2; \
713713
fi
714714
golangci-lint run --timeout 10m
715715

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@
4242
<a href="https://www.tickgit.com/browse?repo=github.com/go-gitea/gitea" title="TODOs">
4343
<img src="https://badgen.net/https/api.tickgit.com/badgen/github.com/go-gitea/gitea">
4444
</a>
45+
<a href="https://www.bountysource.com/teams/gitea" title="Bountysource">
46+
<img src="https://img.shields.io/bountysource/team/gitea/activity">
47+
</a>
4548
</p>
4649

4750
<p align="center">

README_ZH.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@
4242
<a href="https://www.tickgit.com/browse?repo=github.com/go-gitea/gitea" title="TODOs">
4343
<img src="https://badgen.net/https/api.tickgit.com/badgen/github.com/go-gitea/gitea">
4444
</a>
45+
<a href="https://img.shields.io/bountysource/team/gitea" title="Bountysource">
46+
<img src="https://img.shields.io/bountysource/team/gitea/activity">
47+
</a>
4548
</p>
4649

4750
<p align="center">

cmd/dump.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
"code.gitea.io/gitea/modules/storage"
2222
"code.gitea.io/gitea/modules/util"
2323

24-
"gitea.com/macaron/session"
24+
"gitea.com/go-chi/session"
2525
archiver "github.com/mholt/archiver/v3"
2626
"github.com/urfave/cli"
2727
)

cmd/serv.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func setup(logPath string, debug bool) {
5858
}
5959
setting.NewContext()
6060
if debug {
61-
setting.ProdMode = false
61+
setting.RunMode = "dev"
6262
}
6363
}
6464

@@ -76,7 +76,7 @@ func fail(userMessage, logMessage string, args ...interface{}) {
7676
fmt.Fprintln(os.Stderr, "Gitea:", userMessage)
7777

7878
if len(logMessage) > 0 {
79-
if !setting.ProdMode {
79+
if !setting.IsProd() {
8080
fmt.Fprintf(os.Stderr, logMessage+"\n", args...)
8181
}
8282
}

cmd/web.go

Lines changed: 3 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import (
2222

2323
context2 "github.com/gorilla/context"
2424
"github.com/urfave/cli"
25-
"golang.org/x/crypto/acme/autocert"
2625
ini "gopkg.in/ini.v1"
2726
)
2827

@@ -72,36 +71,6 @@ func runHTTPRedirector() {
7271
}
7372
}
7473

75-
func runLetsEncrypt(listenAddr, domain, directory, email string, m http.Handler) error {
76-
certManager := autocert.Manager{
77-
Prompt: autocert.AcceptTOS,
78-
HostPolicy: autocert.HostWhitelist(domain),
79-
Cache: autocert.DirCache(directory),
80-
Email: email,
81-
}
82-
go func() {
83-
log.Info("Running Let's Encrypt handler on %s", setting.HTTPAddr+":"+setting.PortToRedirect)
84-
// all traffic coming into HTTP will be redirect to HTTPS automatically (LE HTTP-01 validation happens here)
85-
var err = runHTTP("tcp", setting.HTTPAddr+":"+setting.PortToRedirect, certManager.HTTPHandler(http.HandlerFunc(runLetsEncryptFallbackHandler)))
86-
if err != nil {
87-
log.Fatal("Failed to start the Let's Encrypt handler on port %s: %v", setting.PortToRedirect, err)
88-
}
89-
}()
90-
return runHTTPSWithTLSConfig("tcp", listenAddr, certManager.TLSConfig(), context2.ClearHandler(m))
91-
}
92-
93-
func runLetsEncryptFallbackHandler(w http.ResponseWriter, r *http.Request) {
94-
if r.Method != "GET" && r.Method != "HEAD" {
95-
http.Error(w, "Use HTTPS", http.StatusBadRequest)
96-
return
97-
}
98-
// Remove the trailing slash at the end of setting.AppURL, the request
99-
// URI always contains a leading slash, which would result in a double
100-
// slash
101-
target := strings.TrimSuffix(setting.AppURL, "/") + r.URL.RequestURI()
102-
http.Redirect(w, r, target, http.StatusFound)
103-
}
104-
10574
func runWeb(ctx *cli.Context) error {
10675
managerCtx, cancel := context.WithCancel(context.Background())
10776
graceful.InitManager(managerCtx)
@@ -133,8 +102,7 @@ func runWeb(ctx *cli.Context) error {
133102
return err
134103
}
135104
}
136-
c := routes.NewChi()
137-
routes.RegisterInstallRoute(c)
105+
c := routes.InstallRoutes()
138106
err := listen(c, false)
139107
select {
140108
case <-graceful.GetManager().IsShutdown():
@@ -165,11 +133,9 @@ func runWeb(ctx *cli.Context) error {
165133
return err
166134
}
167135
}
168-
// Set up Chi routes
169-
c := routes.NewChi()
170-
c.Mount("/", routes.NormalRoutes())
171-
routes.DelegateToMacaron(c)
172136

137+
// Set up Chi routes
138+
c := routes.NormalRoutes()
173139
err := listen(c, true)
174140
<-graceful.GetManager().Done()
175141
log.Info("PID: %d Gitea Web Finished", os.Getpid())

cmd/web_letsencrypt.go

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
// Copyright 2020 The Gitea Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
5+
package cmd
6+
7+
import (
8+
"net/http"
9+
"strings"
10+
11+
"code.gitea.io/gitea/modules/log"
12+
"code.gitea.io/gitea/modules/setting"
13+
14+
"github.com/caddyserver/certmagic"
15+
context2 "github.com/gorilla/context"
16+
)
17+
18+
func runLetsEncrypt(listenAddr, domain, directory, email string, m http.Handler) error {
19+
20+
// If HTTP Challenge enabled, needs to be serving on port 80. For TLSALPN needs 443.
21+
// Due to docker port mapping this can't be checked programatically
22+
// TODO: these are placeholders until we add options for each in settings with appropriate warning
23+
enableHTTPChallenge := true
24+
enableTLSALPNChallenge := true
25+
26+
magic := certmagic.NewDefault()
27+
magic.Storage = &certmagic.FileStorage{Path: directory}
28+
myACME := certmagic.NewACMEManager(magic, certmagic.ACMEManager{
29+
Email: email,
30+
Agreed: setting.LetsEncryptTOS,
31+
DisableHTTPChallenge: !enableHTTPChallenge,
32+
DisableTLSALPNChallenge: !enableTLSALPNChallenge,
33+
})
34+
35+
magic.Issuer = myACME
36+
37+
// this obtains certificates or renews them if necessary
38+
err := magic.ManageSync([]string{domain})
39+
if err != nil {
40+
return err
41+
}
42+
43+
tlsConfig := magic.TLSConfig()
44+
45+
if enableHTTPChallenge {
46+
go func() {
47+
log.Info("Running Let's Encrypt handler on %s", setting.HTTPAddr+":"+setting.PortToRedirect)
48+
// all traffic coming into HTTP will be redirect to HTTPS automatically (LE HTTP-01 validation happens here)
49+
var err = runHTTP("tcp", setting.HTTPAddr+":"+setting.PortToRedirect, myACME.HTTPChallengeHandler(http.HandlerFunc(runLetsEncryptFallbackHandler)))
50+
if err != nil {
51+
log.Fatal("Failed to start the Let's Encrypt handler on port %s: %v", setting.PortToRedirect, err)
52+
}
53+
}()
54+
}
55+
56+
return runHTTPSWithTLSConfig("tcp", listenAddr, tlsConfig, context2.ClearHandler(m))
57+
}
58+
59+
func runLetsEncryptFallbackHandler(w http.ResponseWriter, r *http.Request) {
60+
if r.Method != "GET" && r.Method != "HEAD" {
61+
http.Error(w, "Use HTTPS", http.StatusBadRequest)
62+
return
63+
}
64+
// Remove the trailing slash at the end of setting.AppURL, the request
65+
// URI always contains a leading slash, which would result in a double
66+
// slash
67+
target := strings.TrimSuffix(setting.AppURL, "/") + r.URL.RequestURI()
68+
http.Redirect(w, r, target, http.StatusFound)
69+
}

0 commit comments

Comments
 (0)