Skip to content

Commit

Permalink
Merge branch 'master' into easymde
Browse files Browse the repository at this point in the history
  • Loading branch information
zeripath authored Nov 10, 2020
2 parents 47feef6 + 9155f13 commit ce38d9e
Show file tree
Hide file tree
Showing 552 changed files with 96,826 additions and 11,668 deletions.
62 changes: 62 additions & 0 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,28 @@ steps:
exclude:
- pull_request

- name: publish-rootless
pull: always
image: plugins/docker:linux-amd64
settings:
dockerfile: Dockerfile.rootless
auto_tag: true
auto_tag_suffix: linux-amd64-rootless
repo: gitea/gitea
build_args:
- GOPROXY=off
password:
from_secret: docker_password
username:
from_secret: docker_username
environment:
PLUGIN_MIRROR:
from_secret: plugin_mirror
when:
event:
exclude:
- pull_request

---
kind: pipeline
name: docker-linux-arm64-dry-run
Expand Down Expand Up @@ -696,6 +718,9 @@ steps:
tags: linux-arm64
build_args:
- GOPROXY=off
environment:
PLUGIN_MIRROR:
from_secret: plugin_mirror
when:
event:
- pull_request
Expand Down Expand Up @@ -740,6 +765,31 @@ steps:
from_secret: docker_password
username:
from_secret: docker_username
environment:
PLUGIN_MIRROR:
from_secret: plugin_mirror
when:
event:
exclude:
- pull_request

- name: publish-rootless
pull: always
image: plugins/docker:linux-arm64
settings:
dockerfile: Dockerfile.rootless
auto_tag: true
auto_tag_suffix: linux-arm64-rootless
repo: gitea/gitea
build_args:
- GOPROXY=off
password:
from_secret: docker_password
username:
from_secret: docker_username
environment:
PLUGIN_MIRROR:
from_secret: plugin_mirror
when:
event:
exclude:
Expand All @@ -754,6 +804,18 @@ platform:
arch: amd64

steps:
- name: manifest-rootless
pull: always
image: plugins/manifest
settings:
auto_tag: true
ignore_missing: true
spec: docker/manifest.rootless.tmpl
password:
from_secret: docker_password
username:
from_secret: docker_username

- name: manifest
pull: always
image: plugins/manifest
Expand Down
11 changes: 10 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ parserOptions:
plugins:
- eslint-plugin-unicorn
- eslint-plugin-import
- eslint-plugin-vue

extends:
- plugin:vue/recommended

env:
es2021: true
Expand All @@ -24,7 +28,7 @@ globals:
u2fApi: false

overrides:
- files: ["web_src/**/*.js"]
- files: ["web_src/**/*.js", "web_src/**/*.vue"]
env:
browser: true
jquery: true
Expand Down Expand Up @@ -387,6 +391,11 @@ rules:
use-isnan: [2]
valid-typeof: [2, {requireStringLiterals: true}]
vars-on-top: [0]
vue/attributes-order: [0]
vue/component-definition-name-casing: [0]
vue/html-closing-bracket-spacing: [0]
vue/max-attributes-per-line: [0]
vue/one-component-per-file: [0]
wrap-iife: [2, inside]
wrap-regex: [0]
yield-star-spacing: [2, after]
Expand Down
12 changes: 11 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,17 @@ coverage.all
/public/css
/public/fonts
/public/img/webpack
/web_src/fomantic/build
/web_src/fomantic/build/*
!/web_src/fomantic/build/semantic.js
!/web_src/fomantic/build/semantic.css
!/web_src/fomantic/build/themes
/web_src/fomantic/build/themes/*
!/web_src/fomantic/build/themes/default
/web_src/fomantic/build/themes/default/assets/*
!/web_src/fomantic/build/themes/default/assets/fonts
/web_src/fomantic/build/themes/default/assets/fonts/*
!/web_src/fomantic/build/themes/default/assets/fonts/icons.woff2
!/web_src/fomantic/build/themes/default/assets/fonts/outline-icons.woff2
/VERSION
/.air

Expand Down
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ RUN apk --no-cache add \
openssh \
s6 \
sqlite \
socat \
su-exec \
gnupg

Expand Down
68 changes: 68 additions & 0 deletions Dockerfile.rootless
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@

###################################
#Build stage
FROM golang:1.15-alpine3.12 AS build-env

ARG GOPROXY
ENV GOPROXY ${GOPROXY:-direct}

ARG GITEA_VERSION
ARG TAGS="sqlite sqlite_unlock_notify"
ENV TAGS "bindata timetzdata $TAGS"
ARG CGO_EXTRA_CFLAGS

#Build deps
RUN apk --no-cache add build-base git nodejs npm

#Setup repo
COPY . ${GOPATH}/src/code.gitea.io/gitea
WORKDIR ${GOPATH}/src/code.gitea.io/gitea

#Checkout version if set
RUN if [ -n "${GITEA_VERSION}" ]; then git checkout "${GITEA_VERSION}"; fi \
&& make clean-all build

FROM alpine:3.12
LABEL maintainer="maintainers@gitea.io"

EXPOSE 2222 3000

RUN apk --no-cache add \
bash \
ca-certificates \
gettext \
git \
gnupg

RUN addgroup \
-S -g 1000 \
git && \
adduser \
-S -H -D \
-h /var/lib/gitea/git \
-s /bin/bash \
-u 1000 \
-G git \
git && \
echo "git:$(dd if=/dev/urandom bs=24 count=1 status=none | base64)" | chpasswd

RUN mkdir -p /var/lib/gitea /etc/gitea
RUN chown git:git /var/lib/gitea /etc/gitea

COPY docker/rootless /
COPY --from=build-env /go/src/code.gitea.io/gitea/gitea /usr/local/bin/gitea
RUN chown root:root /usr/local/bin/* && chmod 755 /usr/local/bin/*

USER git:git
ENV GITEA_WORK_DIR /var/lib/gitea
ENV GITEA_CUSTOM /var/lib/gitea/custom
ENV GITEA_TEMP /tmp/gitea
#TODO add to docs the ability to define the ini to load (usefull to test and revert a config)
ENV GITEA_APP_INI /etc/gitea/app.ini
ENV HOME "/var/lib/gitea/git"
VOLUME ["/var/lib/gitea", "/etc/gitea"]
WORKDIR /var/lib/gitea

ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
CMD []

12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ FOMANTIC_CONFIGS := semantic.json web_src/fomantic/theme.config.less web_src/fom
FOMANTIC_DEST := web_src/fomantic/build/semantic.js web_src/fomantic/build/semantic.css
FOMANTIC_DEST_DIR := web_src/fomantic/build

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

.PHONY: clean-all
clean-all: clean
rm -rf $(WEBPACK_DEST_ENTRIES) $(FOMANTIC_DEST_DIR)
rm -rf $(WEBPACK_DEST_ENTRIES)

.PHONY: clean
clean:
Expand Down Expand Up @@ -312,8 +312,8 @@ lint: lint-frontend lint-backend

.PHONY: lint-frontend
lint-frontend: node_modules
npx eslint web_src/js build webpack.config.js
npx stylelint web_src/less
npx eslint --max-warnings=0 web_src/js build webpack.config.js
npx stylelint --max-warnings=0 web_src/less

.PHONY: lint-backend
lint-backend: golangci-lint revive vet
Expand All @@ -323,7 +323,7 @@ watch:
bash tools/watch.sh

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

Expand Down Expand Up @@ -541,7 +541,7 @@ install: $(wildcard *.go)
build: frontend backend

.PHONY: frontend
frontend: node-check $(FOMANTIC_DEST) $(WEBPACK_DEST)
frontend: node-check $(WEBPACK_DEST)

.PHONY: backend
backend: go-check generate $(EXECUTABLE)
Expand Down
61 changes: 61 additions & 0 deletions cmd/docs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.

package cmd

import (
"fmt"
"os"
"strings"

"github.com/urfave/cli"
)

// CmdDocs represents the available docs sub-command.
var CmdDocs = cli.Command{
Name: "docs",
Usage: "Output CLI documentation",
Description: "A command to output Gitea's CLI documentation, optionally to a file.",
Action: runDocs,
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "man",
Usage: "Output man pages instead",
},
&cli.StringFlag{
Name: "output, o",
Usage: "Path to output to instead of stdout (will overwrite if exists)",
},
},
}

func runDocs(ctx *cli.Context) error {
docs, err := ctx.App.ToMarkdown()
if ctx.Bool("man") {
docs, err = ctx.App.ToMan()
}
if err != nil {
return err
}

if !ctx.Bool("man") {
// Clean up markdown. The following bug was fixed in v2, but is present in v1.
// It affects markdown output (even though the issue is referring to man pages)
// https://github.com/urfave/cli/issues/1040
docs = docs[strings.Index(docs, "#"):]
}

out := os.Stdout
if ctx.String("output") != "" {
fi, err := os.Create(ctx.String("output"))
if err != nil {
return err
}
defer fi.Close()
out = fi
}

_, err = fmt.Fprintln(out, docs)
return err
}
30 changes: 22 additions & 8 deletions cmd/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ and it takes care of all the other things for you`,
Value: "3000",
Usage: "Temporary port number to prevent conflict",
},
cli.StringFlag{
Name: "install-port",
Value: "3000",
Usage: "Temporary port number to run the install page on to prevent conflict",
},
cli.StringFlag{
Name: "pid, P",
Value: setting.PIDFile,
Expand Down Expand Up @@ -116,16 +121,20 @@ func runWeb(ctx *cli.Context) error {
setting.WritePIDFile = true
}

// Flag for port number in case first time run conflict.
if ctx.IsSet("port") {
if err := setPort(ctx.String("port")); err != nil {
return err
}
}

// Perform pre-initialization
needsInstall := routers.PreInstallInit(graceful.GetManager().HammerContext())
if needsInstall {
// Flag for port number in case first time run conflict
if ctx.IsSet("port") {
if err := setPort(ctx.String("port")); err != nil {
return err
}
}
if ctx.IsSet("install-port") {
if err := setPort(ctx.String("install-port")); err != nil {
return err
}
}
m := routes.NewMacaron()
routes.RegisterInstallRoute(m)
err := listen(m, false)
Expand All @@ -152,6 +161,12 @@ func runWeb(ctx *cli.Context) error {
// Perform global initialization
routers.GlobalInit(graceful.GetManager().HammerContext())

// Override the provided port number within the configuration
if ctx.IsSet("port") {
if err := setPort(ctx.String("port")); err != nil {
return err
}
}
// Set up Macaron
m := routes.NewMacaron()
routes.RegisterRoutes(m)
Expand Down Expand Up @@ -190,7 +205,6 @@ func setPort(port string) error {
defaultLocalURL += ":" + setting.HTTPPort + "/"

cfg.Section("server").Key("LOCAL_ROOT_URL").SetValue(defaultLocalURL)

if err := cfg.SaveTo(setting.CustomConf); err != nil {
return fmt.Errorf("Error saving generated JWT Secret to custom config: %v", err)
}
Expand Down
2 changes: 1 addition & 1 deletion contrib/ide/vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"type": "go",
"request": "launch",
"mode": "debug",
"buildFlags": "-tags=\"sqlite sqlite_unlock_notify\"",
"buildFlags": "-tags='sqlite sqlite_unlock_notify'",
"port": 2345,
"host": "127.0.0.1",
"program": "${workspaceRoot}/main.go",
Expand Down
Loading

0 comments on commit ce38d9e

Please sign in to comment.