Skip to content

Commit

Permalink
Update documentation for the go module era
Browse files Browse the repository at this point in the history
use go env instead of $GOPATH

Update instructions to just use git clone

Slight update to readme

Signed-off-by: Andrew Thornton <[email protected]>
  • Loading branch information
zeripath committed Jan 13, 2020
1 parent 1751d5f commit 4d4dea4
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 28 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,6 @@ pr:
golangci-lint:
@hash golangci-lint > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
export BINARY="golangci-lint"; \
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(GOPATH)/bin v1.20.0; \
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $($(GO) env GOPATH)/bin v1.20.0; \
fi
golangci-lint run --timeout 5m
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ From the root of the source tree, run:

TAGS="bindata" make build

or if sqlite support is required:

TAGS="bindata sqlite sqlite_unlock_notify" make build

More info: https://docs.gitea.io/en-us/install-from-source/

## Using
Expand Down
34 changes: 15 additions & 19 deletions docs/content/doc/advanced/hacking-on-gitea.en-us.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,31 +50,26 @@ is the relevant line - but this may change.)

## Downloading and cloning the Gitea source code

Go is quite opinionated about where it expects its source code, and simply
cloning the Gitea repository to an arbitrary path is likely to lead to
problems - the fixing of which is out of scope for this document. Further, some
internal packages are referenced using their respective GitHub URL and at
present we use `vendor/` directories.

The recommended method of obtaining the source code is by using the `go get` command:
The recommended method of obtaining the source code is by using `git clone`.

```bash
go get -d code.gitea.io/gitea
cd "$GOPATH/src/code.gitea.io/gitea"
# from within your src directory
cd "$HOME"/src
git clone https://github.com/go-gitea/gitea
```

This will clone the Gitea source code to: `"$GOPATH/src/code.gitea.io/gitea"`, or if `$GOPATH`
is not set `"$HOME/go/src/code.gitea.io/gitea"`.
(Since the advent of go modules, it is no longer necessary to build go projects
from within the `$GOPATH`, hence the `go get` approach is no longer recommended.)

## Forking Gitea

As stated above, you cannot clone Gitea to an arbitrary path. Download the master Gitea source
code as above. Then, fork the [Gitea repository](https://github.com/go-gitea/gitea) on GitHub,
Download the master Gitea source code as above. Then, fork the
[Gitea repository](https://github.com/go-gitea/gitea) on GitHub,
and either switch the git remote origin for your fork or add your fork as another remote:

```bash
# Rename original Gitea origin to upstream
cd "$GOPATH/src/code.gitea.io/gitea"
cd "$HOME/src/gitea"
git remote rename origin upstream
git remote add origin "[email protected]:$GITHUB_USERNAME/gitea.git"
git fetch --all --prune
Expand All @@ -84,7 +79,7 @@ or:

```bash
# Add new remote for our fork
cd "$GOPATH/src/code.gitea.io/gitea"
cd "$HOME/src/gitea"
git remote add "$FORK_NAME" "[email protected]:$GITHUB_USERNAME/gitea.git"
git fetch --all --prune
```
Expand Down Expand Up @@ -114,7 +109,7 @@ how our continuous integration works.

### Formatting, code analysis and spell check

Our continous integration will reject PRs that are not properly formatted, fail
Our continuous integration will reject PRs that are not properly formatted, fail
code analysis or spell check.

You should format your code with `go fmt` using:
Expand Down Expand Up @@ -240,8 +235,9 @@ have written integration tests; however, these are database dependent.
TAGS="bindata sqlite sqlite_unlock_notify" make build test-sqlite
```

will run the integration tests in an sqlite environment. Other database tests
are available but may need adjustment to the local environment.
will run the integration tests in an sqlite environment. Integration tests
require `git lfs` to be installed. Other database tests are available but
may need adjustment to the local environment.

Look at
[`integrations/README.md`](https://github.com/go-gitea/gitea/blob/master/integrations/README.md)
Expand All @@ -260,7 +256,7 @@ Documentation for the website is found in `docs/`. If you change this you
can test your changes to ensure that they pass continuous integration using:

```bash
cd "$GOPATH/src/code.gitea.io/gitea/docs"
cd "$HOME/src/gitea/docs"
make trans-copy clean build
```

Expand Down
29 changes: 21 additions & 8 deletions docs/content/doc/installation/from-source.en-us.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,18 @@ required to build the JavaScript and CSS files. The minimum supported Node.js
version is 10 and the latest LTS version is recommended.

**Note**: When executing make tasks that require external tools, like
`make misspell-check`, Gitea will automatically download and build these as
`ma
The easiest way is to use the Go tool. Use the
following commands to fetch the source and switch into the source directory.
Go is quite opinionated about where it expects its source code, and simply
cloning the Gitea repository to an arbitrary path is likely to lead to
problems - the fixing of which is out of scope for this document.

```bash
go get -d -u code.gitea.io/gitea
cd "$GOPATH/src/code.gitea.io/gitea"
```
ke misspell-check`, Gitea will automatically download and build these as
necessary. To be able to use these, you must have the `"$GOPATH/bin"` directory
on the executable path. If you don't add the go bin directory to the
executable path, you will have to manage this yourself.
Expand All @@ -38,17 +49,19 @@ Gitea</a>

## Download

First, retrieve the source code. The easiest way is to use the Go tool. Use the
following commands to fetch the source and switch into the source directory.
Go is quite opinionated about where it expects its source code, and simply
cloning the Gitea repository to an arbitrary path is likely to lead to
problems - the fixing of which is out of scope for this document.
First, we must retrieve the source code. Since, the advent of go modules, the
simplest way of doing this is to use git directly as we no longer have to have
gitea built from within the GOPATH.

```bash
go get -d -u code.gitea.io/gitea
cd "$GOPATH/src/code.gitea.io/gitea"
# From within your src directory
cd "$HOME"/src
git clone https://github.com/go-gitea/gitea
```

(Previous versions of this document recommended using `go get`. This is
no longer necessary.)

Decide which version of Gitea to build and install. Currently, there are
multiple options to choose from. The `master` branch represents the current
development version. To build with master, skip to the [build section](#build).
Expand Down

0 comments on commit 4d4dea4

Please sign in to comment.