Skip to content

Commit 8bde829

Browse files
committed
Merge branch 'master' into search_type
2 parents 3f675f6 + 05efb33 commit 8bde829

File tree

355 files changed

+81503
-7992
lines changed

Some content is hidden

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

355 files changed

+81503
-7992
lines changed

.drone.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,25 @@ 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+
when:
685+
event:
686+
exclude:
687+
- pull_request
688+
670689
---
671690
kind: pipeline
672691
name: docker-linux-arm64-dry-run
@@ -745,6 +764,25 @@ steps:
745764
exclude:
746765
- pull_request
747766

767+
- name: publish-rootless
768+
pull: always
769+
image: plugins/docker:linux-arm64
770+
settings:
771+
dockerfile: Dockerfile.rootless
772+
auto_tag: true
773+
auto_tag_suffix: linux-arm64-rootless
774+
repo: gitea/gitea
775+
build_args:
776+
- GOPROXY=off
777+
password:
778+
from_secret: docker_password
779+
username:
780+
from_secret: docker_username
781+
when:
782+
event:
783+
exclude:
784+
- pull_request
785+
748786
---
749787
kind: pipeline
750788
name: docker-manifest
@@ -754,6 +792,18 @@ platform:
754792
arch: amd64
755793

756794
steps:
795+
- name: manifest-rootless
796+
pull: always
797+
image: plugins/manifest
798+
settings:
799+
auto_tag: true
800+
ignore_missing: true
801+
spec: docker/manifest.rootless.tmpl
802+
password:
803+
from_secret: docker_password
804+
username:
805+
from_secret: docker_username
806+
757807
- name: manifest
758808
pull: always
759809
image: plugins/manifest

.gitignore

Lines changed: 11 additions & 1 deletion
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

Lines changed: 0 additions & 1 deletion
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

Lines changed: 68 additions & 0 deletions
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

Lines changed: 4 additions & 4 deletions
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:
@@ -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/admin.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ var (
3434
subcmdRepoSyncReleases,
3535
subcmdRegenerate,
3636
subcmdAuth,
37+
subcmdSendMail,
3738
},
3839
}
3940

@@ -282,6 +283,28 @@ var (
282283
Action: runAddOauth,
283284
Flags: oauthCLIFlags,
284285
}
286+
287+
subcmdSendMail = cli.Command{
288+
Name: "sendmail",
289+
Usage: "Send a message to all users",
290+
Action: runSendMail,
291+
Flags: []cli.Flag{
292+
cli.StringFlag{
293+
Name: "title",
294+
Usage: `a title of a message`,
295+
Value: "",
296+
},
297+
cli.StringFlag{
298+
Name: "content",
299+
Usage: "a content of a message",
300+
Value: "",
301+
},
302+
cli.BoolFlag{
303+
Name: "force,f",
304+
Usage: "A flag to bypass a confirmation step",
305+
},
306+
},
307+
}
285308
)
286309

287310
func runChangePassword(c *cli.Context) error {

cmd/cmd.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ package cmd
99
import (
1010
"errors"
1111
"fmt"
12+
"strings"
1213

1314
"code.gitea.io/gitea/models"
1415
"code.gitea.io/gitea/modules/setting"
@@ -32,6 +33,25 @@ func argsSet(c *cli.Context, args ...string) error {
3233
return nil
3334
}
3435

36+
// confirm waits for user input which confirms an action
37+
func confirm() (bool, error) {
38+
var response string
39+
40+
_, err := fmt.Scanln(&response)
41+
if err != nil {
42+
return false, err
43+
}
44+
45+
switch strings.ToLower(response) {
46+
case "y", "yes":
47+
return true, nil
48+
case "n", "no":
49+
return false, nil
50+
default:
51+
return false, errors.New(response + " isn't a correct confirmation string")
52+
}
53+
}
54+
3555
func initDB() error {
3656
return initDBDisableConsole(false)
3757
}

cmd/mailer.go

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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+
"net/http"
10+
11+
"code.gitea.io/gitea/modules/private"
12+
"code.gitea.io/gitea/modules/setting"
13+
"github.com/urfave/cli"
14+
)
15+
16+
func runSendMail(c *cli.Context) error {
17+
setting.NewContext()
18+
19+
if err := argsSet(c, "title"); err != nil {
20+
return err
21+
}
22+
23+
subject := c.String("title")
24+
confirmSkiped := c.Bool("force")
25+
body := c.String("content")
26+
27+
if !confirmSkiped {
28+
if len(body) == 0 {
29+
fmt.Print("warning: Content is empty")
30+
}
31+
32+
fmt.Print("Proceed with sending email? [Y/n] ")
33+
isConfirmed, err := confirm()
34+
if err != nil {
35+
return err
36+
} else if !isConfirmed {
37+
fmt.Println("The mail was not sent")
38+
return nil
39+
}
40+
}
41+
42+
status, message := private.SendEmail(subject, body, nil)
43+
if status != http.StatusOK {
44+
fmt.Printf("error: %s\n", message)
45+
return nil
46+
}
47+
48+
fmt.Printf("Success: %s\n", message)
49+
50+
return nil
51+
}

cmd/web.go

Lines changed: 22 additions & 8 deletions
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

Lines changed: 1 addition & 1 deletion
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)