Skip to content

Commit

Permalink
Merge branch 'master' into ui-migration-cancel
Browse files Browse the repository at this point in the history
  • Loading branch information
6543 authored Dec 5, 2020
2 parents f7e9022 + d8c2c6c commit cfed3be
Show file tree
Hide file tree
Showing 125 changed files with 1,058 additions and 1,141 deletions.
35 changes: 21 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -223,15 +223,15 @@ clean:

.PHONY: fmt
fmt:
$(GOFMT) -w $(GO_SOURCES_OWN)
@echo "Running go fmt..."
@$(GOFMT) -w $(GO_SOURCES_OWN)

.PHONY: vet
vet:
# Default vet
$(GO) vet $(GO_PACKAGES)
# Custom vet
$(GO) build -mod=vendor code.gitea.io/gitea-vet
$(GO) vet -vettool=gitea-vet $(GO_PACKAGES)
@echo "Running go vet..."
@$(GO) vet $(GO_PACKAGES)
@$(GO) build -mod=vendor code.gitea.io/gitea-vet
@$(GO) vet -vettool=gitea-vet $(GO_PACKAGES)

.PHONY: $(TAGS_EVIDENCE)
$(TAGS_EVIDENCE):
Expand Down Expand Up @@ -268,7 +268,8 @@ errcheck:
@hash errcheck > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
GO111MODULE=off $(GO) get -u github.com/kisielk/errcheck; \
fi
errcheck $(GO_PACKAGES)
@echo "Running errcheck..."
@errcheck $(GO_PACKAGES)

.PHONY: revive
revive:
Expand All @@ -279,14 +280,16 @@ misspell-check:
@hash misspell > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
GO111MODULE=off $(GO) get -u github.com/client9/misspell/cmd/misspell; \
fi
misspell -error -i unknwon,destory $(GO_SOURCES_OWN)
@echo "Running misspell-check..."
@misspell -error -i unknwon,destory $(GO_SOURCES_OWN)

.PHONY: misspell
misspell:
@hash misspell > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
GO111MODULE=off $(GO) get -u github.com/client9/misspell/cmd/misspell; \
fi
misspell -w -i unknwon $(GO_SOURCES_OWN)
@echo "Running go misspell..."
@misspell -w -i unknwon $(GO_SOURCES_OWN)

.PHONY: fmt-check
fmt-check:
Expand Down Expand Up @@ -336,11 +339,12 @@ watch-backend: go-check

.PHONY: test
test:
$(GO) test $(GOTESTFLAGS) -mod=vendor -tags='sqlite sqlite_unlock_notify' $(GO_PACKAGES)
@echo "Running go test..."
@$(GO) test $(GOTESTFLAGS) -mod=vendor -tags='sqlite sqlite_unlock_notify' $(GO_PACKAGES)

.PHONY: test-check
test-check:
@echo "Checking if tests have changed the source tree...";
@echo "Running test-check...";
@diff=$$(git status -s); \
if [ -n "$$diff" ]; then \
echo "make test has changed files in the source tree:"; \
Expand All @@ -352,15 +356,17 @@ test-check:

.PHONY: test\#%
test\#%:
$(GO) test -mod=vendor -tags='sqlite sqlite_unlock_notify' -run $(subst .,/,$*) $(GO_PACKAGES)
@echo "Running go test..."
@$(GO) test -mod=vendor -tags='sqlite sqlite_unlock_notify' -run $(subst .,/,$*) $(GO_PACKAGES)

.PHONY: coverage
coverage:
GO111MODULE=on $(GO) run -mod=vendor build/gocovmerge.go integration.coverage.out $(shell find . -type f -name "coverage.out") > coverage.all

.PHONY: unit-test-coverage
unit-test-coverage:
$(GO) test $(GOTESTFLAGS) -mod=vendor -tags='sqlite sqlite_unlock_notify' -cover -coverprofile coverage.out $(GO_PACKAGES) && echo "\n==>\033[32m Ok\033[m\n" || exit 1
@echo "Running unit-test-coverage..."
@$(GO) test $(GOTESTFLAGS) -mod=vendor -tags='sqlite sqlite_unlock_notify' -cover -coverprofile coverage.out $(GO_PACKAGES) && echo "\n==>\033[32m Ok\033[m\n" || exit 1

.PHONY: vendor
vendor:
Expand Down Expand Up @@ -548,7 +554,8 @@ backend: go-check generate $(EXECUTABLE)

.PHONY: generate
generate: $(TAGS_PREREQ)
CC= GOOS= GOARCH= $(GO) generate -mod=vendor -tags '$(TAGS)' $(GO_PACKAGES)
@echo "Running go generate..."
@CC= GOOS= GOARCH= $(GO) generate -mod=vendor -tags '$(TAGS)' $(GO_PACKAGES)

$(EXECUTABLE): $(GO_SOURCES) $(TAGS_PREREQ)
CGO_CFLAGS="$(CGO_CFLAGS)" $(GO) build -mod=vendor $(GOFLAGS) $(EXTRA_GOFLAGS) -tags '$(TAGS)' -ldflags '-s -w $(LDFLAGS)' -o $@
Expand Down
70 changes: 37 additions & 33 deletions docs/content/doc/help/faq.en-us.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,42 +13,42 @@ menu:
identifier: "faq"
---

# Frequently Asked Questions
# Frequently Asked Questions <!-- omit in toc -->

This page contains some common questions and answers.
Also see [Support Options]({{< relref "doc/help/seek-help.en-us.md" >}})

* [Difference between 1.x and 1.x.x downloads](#difference-between-1-x-and-1-x-x-downloads)
* [How to migrate from Gogs/GitHub/etc. to Gitea](#how-to-migrate-from-gogs-github-etc-to-gitea)
* [Where does Gitea store "x" file](#where-does-gitea-store-x-file)
* [Not seeing a clone URL or the clone URL being incorrect](#not-seeing-a-clone-url-or-the-clone-url-being-incorrect)
* [Custom Templates not loading or working incorrectly](#custom-templates-not-loading-or-working-incorrectly)
* [Active user vs login prohibited user](#active-user-vs-login-prohibited-user)
* [Setting up logging](#setting-up-logging)
* [What is Swagger?](#what-is-swagger)
* [Adjusting your server for public/private use](#adjusting-your-server-for-public-private-use)
* [Preventing spammers](#preventing-spammers)
* [Only allow certain email domains](#only-allow-certain-email-domains)
* [Only allow/block certain OpenID providers](#only-allow-block-certain-openid-providers)
* [Issue only users](#issue-only-users)
* [Restricted users](#restricted-users)
* [Enable Fail2ban](#enable-fail2ban)
* [Adding custom themes](#how-to-add-use-custom-themes)
* [SSHD vs built-in SSH](#sshd-vs-built-in-ssh)
* [Gitea is running slow](#gitea-is-running-slow)
* [Can't create repositories/files](#cant-create-repositories-files)
* [Translation is incorrect/how to add more translations](#translation-is-incorrect-how-to-add-more-translations)
* [Hooks aren't running](#hooks-aren-t-running)
* [SSH Issues](#ssh-issues)
* [SSH Common Errors](#ssh-common-errors)
* [Missing releases after migration repository with tags](#missing-releases-after-migrating-repository-with-tags)
* [LFS Issues](#lfs-issues)
* [How can I create users before starting Gitea](#how-can-i-create-users-before-starting-gitea)
* [How can I enable password reset](#how-can-i-enable-password-reset)
* [How can a user's password be changed](#how-can-a-user-s-password-be-changed)
* [Why is my markdown broken](#why-is-my-markdown-broken)
* [Errors during upgrade on MySQL: Error 1118: Row size too large.](#upgrade-errors-with-mysql)
* [Why are emoji broken on MySQL](#why-are-emoji-broken-on-mysql)
- [Difference between 1.x and 1.x.x downloads](#difference-between-1x-and-1xx-downloads)
- [How to migrate from Gogs/GitHub/etc. to Gitea](#how-to-migrate-from-gogsgithubetc-to-gitea)
- [Where does Gitea store what file](#where-does-gitea-store-what-file)
- [Not seeing a clone URL or the clone URL being incorrect](#not-seeing-a-clone-url-or-the-clone-url-being-incorrect)
- [Custom Templates not loading or working incorrectly](#custom-templates-not-loading-or-working-incorrectly)
- [Active user vs login prohibited user](#active-user-vs-login-prohibited-user)
- [Setting up logging](#setting-up-logging)
- [What is Swagger?](#what-is-swagger)
- [Adjusting your server for public/private use](#adjusting-your-server-for-publicprivate-use)
- [Preventing spammers](#preventing-spammers)
- [Only allow certain email domains](#only-allow-certain-email-domains)
- [Only allow/block certain OpenID providers](#only-allowblock-certain-openid-providers)
- [Issue only users](#issue-only-users)
- [Restricted users](#restricted-users)
- [Enable Fail2ban](#enable-fail2ban)
- [How to add/use custom themes](#how-to-adduse-custom-themes)
- [SSHD vs built-in SSH](#sshd-vs-built-in-ssh)
- [Gitea is running slow](#gitea-is-running-slow)
- [Can't create repositories/files](#cant-create-repositoriesfiles)
- [Translation is incorrect/how to add more translations](#translation-is-incorrecthow-to-add-more-translations)
- [Hooks aren't running](#hooks-arent-running)
- [SSH issues](#ssh-issues)
- [SSH Common Errors](#ssh-common-errors)
- [Missing releases after migrating repository with tags](#missing-releases-after-migrating-repository-with-tags)
- [LFS Issues](#lfs-issues)
- [How can I create users before starting Gitea](#how-can-i-create-users-before-starting-gitea)
- [How can I enable password reset](#how-can-i-enable-password-reset)
- [How can a user's password be changed](#how-can-a-users-password-be-changed)
- [Why is my markdown broken](#why-is-my-markdown-broken)
- [Upgrade errors with MySQL](#upgrade-errors-with-mysql)
- [Why Are Emoji Broken On MySQL](#why-are-emoji-broken-on-mysql)

## Difference between 1.x and 1.x.x downloads
Version 1.7.x will be used for this example.
Expand All @@ -74,7 +74,7 @@ In order to migrate items such as issues, pull requests, etc. you will need to i
To migrate from Gitlab to Gitea, you can use this non-affiliated tool:
https://github.com/loganinak/MigrateGitlabToGogs

## Where does Gitea store "x" file
## Where does Gitea store what file
* WorkPath
* Environment variable `GITEA_WORK_DIR`
* Else binary location
Expand Down Expand Up @@ -336,3 +336,7 @@ for the database_name and run `ALTER TABLE table_name CONVERT TO CHARACTER SET u
for each table in the database.

You will also need to change the app.ini database charset to `CHARSET=utf8mb4`.

## Why are Emoji displaying only as placeholders or in monochrome

Gitea requires the system or browser to have one of the supported Emoji fonts installed, which are Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji and Twemoji Mozilla. Generally, the operating system should already provide one of these fonts, but especially on Linux, it may be necessary to install them manually.
103 changes: 41 additions & 62 deletions docs/content/doc/installation/with-docker.en-us.md
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,8 @@ files; for named volumes, this is done through another container or by direct ac
:exclamation::exclamation: **Make sure you have volumed data to somewhere outside Docker container** :exclamation::exclamation:

To upgrade your installation to the latest release:
```

```bash
# Edit `docker-compose.yml` to update the version, if you have one specified
# Pull new images
docker-compose pull
Expand All @@ -301,88 +302,66 @@ docker-compose up -d

# SSH Container Passthrough

Since SSH is running inside the container, you'll have to pass SSH from the host to the
container if you wish to use SSH support. If you wish to do this without running the container
SSH on a non-standard port (or move your host port to a non-standard port), you can forward
SSH connections destined for the container with a little extra setup.
Since SSH is running inside the container, SSH needs to be passed through from the host to the container if SSH support is desired. One option would be to run the container SSH on a non-standard port (or moving the host port to a non-standard port). Another option which might be more straightforward is to forward SSH connections from the host to the container. This setup is explained in the following.

This guide assumes that you have created a user on the host called `git` which shares the same
UID/GID as the container values `USER_UID`/`USER_GID`. You should also create the directory
`/var/lib/gitea` on the host, owned by the `git` user and mounted in the container, e.g.
This guide assumes that you have created a user on the host called `git` which shares the same `UID`/ `GID` as the container values `USER_UID`/ `USER_GID`. These values can be set as environment variables in the `docker-compose.yml`:

```bash
environment:
- USER_UID=1000
- USER_GID=1000
```
version: "3"

services:
server:
image: gitea/gitea:{{< version >}}
container_name: gitea
environment:
- USER_UID=1000
- USER_GID=1000
restart: always
networks:
- gitea
volumes:
- /var/lib/gitea:/data
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
ports:
- "3000:3000"
- "127.0.0.1:2222:22"
```
Next mount `/home/git/.ssh` of the host into the container. Otherwise the SSH authentication cannot work inside the container.

You can see that we're also exposing the container SSH port to port 2222 on the host, and binding this
to 127.0.0.1 to prevent it being accessible external to the host machine itself.
```bash
volumes:
- /home/git/.ssh/:/data/git/.ssh
```

On the **host**, you should create the file `/app/gitea/gitea` with the following contents and
make it executable (`chmod +x /app/gitea/gitea`):
Now a SSH key pair needs to be created on the host. This key pair will be used to authenticate the `git` user on the host to the container.

```bash
sudo -u git ssh-keygen -t rsa -b 4096 -C "Gitea Host Key"
```
#!/bin/sh

In the next step a file named `/app/gitea/gitea` (with executable permissions) needs to be created on the host. This file will issue the SSH forwarding from the host to the container. Add the following contents to `/app/gitea/gitea`:

```bash
ssh -p 2222 -o StrictHostKeyChecking=no git@127.0.0.1 "SSH_ORIGINAL_COMMAND=\"$SSH_ORIGINAL_COMMAND\" $0 $@"
```

Your `git` user needs to have an SSH key generated:
To make the forwarding work, the SSH port of the container (22) needs to be mapped to the host port 2222 in `docker-compose.yml` . Since this port does not need to be exposed to the outside world, it can be mapped to the `localhost` of the host machine:

```bash
ports:
# [...]
- "127.0.0.1:2222:22"
```
sudo -u git ssh-keygen -t rsa -b 4096 -C "Gitea Host Key"
```

Now, proceed with one of the points given below:

- symlink the container `.ssh/authorized_keys` file to your git user `.ssh/authorized_keys`.
This can be done on the host as the `/var/lib/gitea` directory is mounted inside the container under `/data`:
In addition, `/home/git/.ssh/authorized_keys` on the host needs to be modified. It needs to act in the same way as `authorized_keys` within the Gitea container. Therefore add

```
ln -s /var/lib/gitea/git/.ssh/authorized_keys /home/git/.ssh/authorized_keys
```bash
command="/app/gitea/gitea --config=/data/gitea/conf/app.ini serv key-1",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty ssh-rsa <YOUR_SSH_PUBKEY>
```

Then echo the `git` user SSH key into the authorized_keys file so the host can talk to the container over SSH:
and replace `<YOUR_SSH_PUBKEY>` with a valid SSH public key of yours.

```
echo "no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty $(cat /home/git/.ssh/id_rsa.pub)" >> /var/lib/gitea/git/.ssh/authorized_keys
```
In addition the public key of the `git` user on the host needs to be added to `/home/git/.ssh/authorized_keys` so authentication against the container can succeed: `echo "$(cat /home/git/.ssh/id_rsa.pub)" >> /home/git/.ssh/authorized_keys`.

Lastly, Gitea makes `authorized_keys` backups by default. This could be a problem
as the symbolic link made to `authorized_keys` previously could end up pointing
to an old backup. To resolve this, please put the following into your Gitea
config:
Here is a detailed explanation what is happening when a SSH request is made:

```
[ssh]
SSH_AUTHORIZED_KEYS_BACKUP=false
```
1. A SSH request is made against the host using the `git` user, e.g. `git clone git@domain:user/repo.git`.
2. In `/home/git/.ssh/authorized_keys` , the command executes the `/app/gitea/gitea` script.
3. `/app/gitea/gitea` forwards the SSH request to port 2222 which is mapped to the SSH port (22) of the container.
4. Due to the existence of the public key of the `git` user in `/home/git/.ssh/authorized_keys` the authentication host → container succeeds and the SSH request get forwarded to Gitea running in the docker container.

- mount your `.ssh` directory directly into the container i.e. add the
following to the `volumes` section of your Docker container config:
If a new SSH key is added in the Gitea web interface, it will be appended to `.ssh/authorized_keys` in the same way as the already existing key.

```
- /home/git/.ssh/:/data/git/.ssh/
```
**Notes**

Now you should be able to use Git over SSH to your container without disrupting SSH access to the host.
SSH container passthrough will work only if

Please note: SSH container passthrough will work only if using opensshd in container, and will not work if
`AuthorizedKeysCommand` is used in combination with setting `SSH_CREATE_AUTHORIZED_KEYS_FILE=false` to disable
authorized files key generation.
- `opensshd` is used in the container
- if `AuthorizedKeysCommand` is _not used_ in combination with `SSH_CREATE_AUTHORIZED_KEYS_FILE=false` to disable authorized files key generation
- `LOCAL_ROOT_URL` is not changed
2 changes: 1 addition & 1 deletion integrations/privateactivity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func testPrivateActivityHelperEnablePrivateActivity(t *testing.T) {
"_csrf": GetCSRF(t, session, "/user/settings"),
"name": privateActivityTestUser,
"email": privateActivityTestUser + "@example.com",
"language": "en-us",
"language": "en-US",
"keep_activity_private": "1",
})
session.MakeRequest(t, req, http.StatusFound)
Expand Down
4 changes: 2 additions & 2 deletions integrations/user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func TestRenameUsername(t *testing.T) {
"_csrf": GetCSRF(t, session, "/user/settings"),
"name": "newUsername",
"email": "user2@example.com",
"language": "en-us",
"language": "en-US",
})
session.MakeRequest(t, req, http.StatusFound)

Expand Down Expand Up @@ -100,7 +100,7 @@ func TestRenameReservedUsername(t *testing.T) {
"_csrf": GetCSRF(t, session, "/user/settings"),
"name": reservedUsername,
"email": "user2@example.com",
"language": "en-us",
"language": "en-US",
})
resp := session.MakeRequest(t, req, http.StatusFound)

Expand Down
2 changes: 1 addition & 1 deletion integrations/xss_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func TestXSSUserFullName(t *testing.T) {
"name": user.Name,
"full_name": fullName,
"email": user.Email,
"language": "en-us",
"language": "en-US",
})
session.MakeRequest(t, req, http.StatusFound)

Expand Down
6 changes: 0 additions & 6 deletions models/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,6 @@ func (a *Action) GetDisplayNameTitle() string {
return a.GetActFullName()
}

// GetActAvatar the action's user's avatar link
func (a *Action) GetActAvatar() string {
a.loadActUser()
return a.ActUser.RelAvatarLink()
}

// GetRepoUserName returns the name of the action repository owner.
func (a *Action) GetRepoUserName() string {
a.loadRepo()
Expand Down
Loading

0 comments on commit cfed3be

Please sign in to comment.