Skip to content

Commit ce38d9e

Browse files
authored
Merge branch 'master' into easymde
2 parents 47feef6 + 9155f13 commit ce38d9e

File tree

552 files changed

+96826
-11668
lines changed

Some content is hidden

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

552 files changed

+96826
-11668
lines changed

.drone.yml

+62
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,28 @@ steps:
667667
exclude:
668668
- pull_request
669669

670+
- name: publish-rootless
671+
pull: always
672+
image: plugins/docker:linux-amd64
673+
settings:
674+
dockerfile: Dockerfile.rootless
675+
auto_tag: true
676+
auto_tag_suffix: linux-amd64-rootless
677+
repo: gitea/gitea
678+
build_args:
679+
- GOPROXY=off
680+
password:
681+
from_secret: docker_password
682+
username:
683+
from_secret: docker_username
684+
environment:
685+
PLUGIN_MIRROR:
686+
from_secret: plugin_mirror
687+
when:
688+
event:
689+
exclude:
690+
- pull_request
691+
670692
---
671693
kind: pipeline
672694
name: docker-linux-arm64-dry-run
@@ -696,6 +718,9 @@ steps:
696718
tags: linux-arm64
697719
build_args:
698720
- GOPROXY=off
721+
environment:
722+
PLUGIN_MIRROR:
723+
from_secret: plugin_mirror
699724
when:
700725
event:
701726
- pull_request
@@ -740,6 +765,31 @@ steps:
740765
from_secret: docker_password
741766
username:
742767
from_secret: docker_username
768+
environment:
769+
PLUGIN_MIRROR:
770+
from_secret: plugin_mirror
771+
when:
772+
event:
773+
exclude:
774+
- pull_request
775+
776+
- name: publish-rootless
777+
pull: always
778+
image: plugins/docker:linux-arm64
779+
settings:
780+
dockerfile: Dockerfile.rootless
781+
auto_tag: true
782+
auto_tag_suffix: linux-arm64-rootless
783+
repo: gitea/gitea
784+
build_args:
785+
- GOPROXY=off
786+
password:
787+
from_secret: docker_password
788+
username:
789+
from_secret: docker_username
790+
environment:
791+
PLUGIN_MIRROR:
792+
from_secret: plugin_mirror
743793
when:
744794
event:
745795
exclude:
@@ -754,6 +804,18 @@ platform:
754804
arch: amd64
755805

756806
steps:
807+
- name: manifest-rootless
808+
pull: always
809+
image: plugins/manifest
810+
settings:
811+
auto_tag: true
812+
ignore_missing: true
813+
spec: docker/manifest.rootless.tmpl
814+
password:
815+
from_secret: docker_password
816+
username:
817+
from_secret: docker_username
818+
757819
- name: manifest
758820
pull: always
759821
image: plugins/manifest

.eslintrc

+10-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ parserOptions:
1111
plugins:
1212
- eslint-plugin-unicorn
1313
- eslint-plugin-import
14+
- eslint-plugin-vue
15+
16+
extends:
17+
- plugin:vue/recommended
1418

1519
env:
1620
es2021: true
@@ -24,7 +28,7 @@ globals:
2428
u2fApi: false
2529

2630
overrides:
27-
- files: ["web_src/**/*.js"]
31+
- files: ["web_src/**/*.js", "web_src/**/*.vue"]
2832
env:
2933
browser: true
3034
jquery: true
@@ -387,6 +391,11 @@ rules:
387391
use-isnan: [2]
388392
valid-typeof: [2, {requireStringLiterals: true}]
389393
vars-on-top: [0]
394+
vue/attributes-order: [0]
395+
vue/component-definition-name-casing: [0]
396+
vue/html-closing-bracket-spacing: [0]
397+
vue/max-attributes-per-line: [0]
398+
vue/one-component-per-file: [0]
390399
wrap-iife: [2, inside]
391400
wrap-regex: [0]
392401
yield-star-spacing: [2, after]

.gitignore

+11-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,17 @@ coverage.all
8080
/public/css
8181
/public/fonts
8282
/public/img/webpack
83-
/web_src/fomantic/build
83+
/web_src/fomantic/build/*
84+
!/web_src/fomantic/build/semantic.js
85+
!/web_src/fomantic/build/semantic.css
86+
!/web_src/fomantic/build/themes
87+
/web_src/fomantic/build/themes/*
88+
!/web_src/fomantic/build/themes/default
89+
/web_src/fomantic/build/themes/default/assets/*
90+
!/web_src/fomantic/build/themes/default/assets/fonts
91+
/web_src/fomantic/build/themes/default/assets/fonts/*
92+
!/web_src/fomantic/build/themes/default/assets/fonts/icons.woff2
93+
!/web_src/fomantic/build/themes/default/assets/fonts/outline-icons.woff2
8494
/VERSION
8595
/.air
8696

Dockerfile

-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ RUN apk --no-cache add \
3737
openssh \
3838
s6 \
3939
sqlite \
40-
socat \
4140
su-exec \
4241
gnupg
4342

Dockerfile.rootless

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
2+
###################################
3+
#Build stage
4+
FROM golang:1.15-alpine3.12 AS build-env
5+
6+
ARG GOPROXY
7+
ENV GOPROXY ${GOPROXY:-direct}
8+
9+
ARG GITEA_VERSION
10+
ARG TAGS="sqlite sqlite_unlock_notify"
11+
ENV TAGS "bindata timetzdata $TAGS"
12+
ARG CGO_EXTRA_CFLAGS
13+
14+
#Build deps
15+
RUN apk --no-cache add build-base git nodejs npm
16+
17+
#Setup repo
18+
COPY . ${GOPATH}/src/code.gitea.io/gitea
19+
WORKDIR ${GOPATH}/src/code.gitea.io/gitea
20+
21+
#Checkout version if set
22+
RUN if [ -n "${GITEA_VERSION}" ]; then git checkout "${GITEA_VERSION}"; fi \
23+
&& make clean-all build
24+
25+
FROM alpine:3.12
26+
LABEL maintainer="[email protected]"
27+
28+
EXPOSE 2222 3000
29+
30+
RUN apk --no-cache add \
31+
bash \
32+
ca-certificates \
33+
gettext \
34+
git \
35+
gnupg
36+
37+
RUN addgroup \
38+
-S -g 1000 \
39+
git && \
40+
adduser \
41+
-S -H -D \
42+
-h /var/lib/gitea/git \
43+
-s /bin/bash \
44+
-u 1000 \
45+
-G git \
46+
git && \
47+
echo "git:$(dd if=/dev/urandom bs=24 count=1 status=none | base64)" | chpasswd
48+
49+
RUN mkdir -p /var/lib/gitea /etc/gitea
50+
RUN chown git:git /var/lib/gitea /etc/gitea
51+
52+
COPY docker/rootless /
53+
COPY --from=build-env /go/src/code.gitea.io/gitea/gitea /usr/local/bin/gitea
54+
RUN chown root:root /usr/local/bin/* && chmod 755 /usr/local/bin/*
55+
56+
USER git:git
57+
ENV GITEA_WORK_DIR /var/lib/gitea
58+
ENV GITEA_CUSTOM /var/lib/gitea/custom
59+
ENV GITEA_TEMP /tmp/gitea
60+
#TODO add to docs the ability to define the ini to load (usefull to test and revert a config)
61+
ENV GITEA_APP_INI /etc/gitea/app.ini
62+
ENV HOME "/var/lib/gitea/git"
63+
VOLUME ["/var/lib/gitea", "/etc/gitea"]
64+
WORKDIR /var/lib/gitea
65+
66+
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
67+
CMD []
68+

Makefile

+6-6
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ FOMANTIC_CONFIGS := semantic.json web_src/fomantic/theme.config.less web_src/fom
9494
FOMANTIC_DEST := web_src/fomantic/build/semantic.js web_src/fomantic/build/semantic.css
9595
FOMANTIC_DEST_DIR := web_src/fomantic/build
9696

97-
WEBPACK_SOURCES := $(shell find web_src/js web_src/less -type f) $(FOMANTIC_DEST)
97+
WEBPACK_SOURCES := $(shell find web_src/js web_src/less -type f)
9898
WEBPACK_CONFIGS := webpack.config.js
9999
WEBPACK_DEST := public/js/index.js public/css/index.css
100100
WEBPACK_DEST_ENTRIES := public/js public/css public/fonts public/img/webpack public/serviceworker.js
@@ -210,7 +210,7 @@ node-check:
210210

211211
.PHONY: clean-all
212212
clean-all: clean
213-
rm -rf $(WEBPACK_DEST_ENTRIES) $(FOMANTIC_DEST_DIR)
213+
rm -rf $(WEBPACK_DEST_ENTRIES)
214214

215215
.PHONY: clean
216216
clean:
@@ -312,8 +312,8 @@ lint: lint-frontend lint-backend
312312

313313
.PHONY: lint-frontend
314314
lint-frontend: node_modules
315-
npx eslint web_src/js build webpack.config.js
316-
npx stylelint web_src/less
315+
npx eslint --max-warnings=0 web_src/js build webpack.config.js
316+
npx stylelint --max-warnings=0 web_src/less
317317

318318
.PHONY: lint-backend
319319
lint-backend: golangci-lint revive vet
@@ -323,7 +323,7 @@ watch:
323323
bash tools/watch.sh
324324

325325
.PHONY: watch-frontend
326-
watch-frontend: node-check $(FOMANTIC_DEST) node_modules
326+
watch-frontend: node-check node_modules
327327
rm -rf $(WEBPACK_DEST_ENTRIES)
328328
NODE_ENV=development npx webpack --hide-modules --display-entrypoints=false --watch --progress
329329

@@ -541,7 +541,7 @@ install: $(wildcard *.go)
541541
build: frontend backend
542542

543543
.PHONY: frontend
544-
frontend: node-check $(FOMANTIC_DEST) $(WEBPACK_DEST)
544+
frontend: node-check $(WEBPACK_DEST)
545545

546546
.PHONY: backend
547547
backend: go-check generate $(EXECUTABLE)

cmd/docs.go

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
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+
"fmt"
9+
"os"
10+
"strings"
11+
12+
"github.com/urfave/cli"
13+
)
14+
15+
// CmdDocs represents the available docs sub-command.
16+
var CmdDocs = cli.Command{
17+
Name: "docs",
18+
Usage: "Output CLI documentation",
19+
Description: "A command to output Gitea's CLI documentation, optionally to a file.",
20+
Action: runDocs,
21+
Flags: []cli.Flag{
22+
&cli.BoolFlag{
23+
Name: "man",
24+
Usage: "Output man pages instead",
25+
},
26+
&cli.StringFlag{
27+
Name: "output, o",
28+
Usage: "Path to output to instead of stdout (will overwrite if exists)",
29+
},
30+
},
31+
}
32+
33+
func runDocs(ctx *cli.Context) error {
34+
docs, err := ctx.App.ToMarkdown()
35+
if ctx.Bool("man") {
36+
docs, err = ctx.App.ToMan()
37+
}
38+
if err != nil {
39+
return err
40+
}
41+
42+
if !ctx.Bool("man") {
43+
// Clean up markdown. The following bug was fixed in v2, but is present in v1.
44+
// It affects markdown output (even though the issue is referring to man pages)
45+
// https://github.com/urfave/cli/issues/1040
46+
docs = docs[strings.Index(docs, "#"):]
47+
}
48+
49+
out := os.Stdout
50+
if ctx.String("output") != "" {
51+
fi, err := os.Create(ctx.String("output"))
52+
if err != nil {
53+
return err
54+
}
55+
defer fi.Close()
56+
out = fi
57+
}
58+
59+
_, err = fmt.Fprintln(out, docs)
60+
return err
61+
}

cmd/web.go

+22-8
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ and it takes care of all the other things for you`,
4141
Value: "3000",
4242
Usage: "Temporary port number to prevent conflict",
4343
},
44+
cli.StringFlag{
45+
Name: "install-port",
46+
Value: "3000",
47+
Usage: "Temporary port number to run the install page on to prevent conflict",
48+
},
4449
cli.StringFlag{
4550
Name: "pid, P",
4651
Value: setting.PIDFile,
@@ -116,16 +121,20 @@ func runWeb(ctx *cli.Context) error {
116121
setting.WritePIDFile = true
117122
}
118123

119-
// Flag for port number in case first time run conflict.
120-
if ctx.IsSet("port") {
121-
if err := setPort(ctx.String("port")); err != nil {
122-
return err
123-
}
124-
}
125-
126124
// Perform pre-initialization
127125
needsInstall := routers.PreInstallInit(graceful.GetManager().HammerContext())
128126
if needsInstall {
127+
// Flag for port number in case first time run conflict
128+
if ctx.IsSet("port") {
129+
if err := setPort(ctx.String("port")); err != nil {
130+
return err
131+
}
132+
}
133+
if ctx.IsSet("install-port") {
134+
if err := setPort(ctx.String("install-port")); err != nil {
135+
return err
136+
}
137+
}
129138
m := routes.NewMacaron()
130139
routes.RegisterInstallRoute(m)
131140
err := listen(m, false)
@@ -152,6 +161,12 @@ func runWeb(ctx *cli.Context) error {
152161
// Perform global initialization
153162
routers.GlobalInit(graceful.GetManager().HammerContext())
154163

164+
// Override the provided port number within the configuration
165+
if ctx.IsSet("port") {
166+
if err := setPort(ctx.String("port")); err != nil {
167+
return err
168+
}
169+
}
155170
// Set up Macaron
156171
m := routes.NewMacaron()
157172
routes.RegisterRoutes(m)
@@ -190,7 +205,6 @@ func setPort(port string) error {
190205
defaultLocalURL += ":" + setting.HTTPPort + "/"
191206

192207
cfg.Section("server").Key("LOCAL_ROOT_URL").SetValue(defaultLocalURL)
193-
194208
if err := cfg.SaveTo(setting.CustomConf); err != nil {
195209
return fmt.Errorf("Error saving generated JWT Secret to custom config: %v", err)
196210
}

contrib/ide/vscode/launch.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"type": "go",
2020
"request": "launch",
2121
"mode": "debug",
22-
"buildFlags": "-tags=\"sqlite sqlite_unlock_notify\"",
22+
"buildFlags": "-tags='sqlite sqlite_unlock_notify'",
2323
"port": 2345,
2424
"host": "127.0.0.1",
2525
"program": "${workspaceRoot}/main.go",

0 commit comments

Comments
 (0)