Skip to content

Implement private repository limits #12705

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 82 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
a332a56
Add privaterepo limit
mvdkleijn Sep 3, 2020
3efa965
Add error handling reaching max private repo limit
mvdkleijn Sep 3, 2020
767c86d
Add private repo limit to user model
mvdkleijn Sep 3, 2020
ed032bb
Add error handling in repo router
mvdkleijn Sep 4, 2020
26b5f52
Add appropriate strings in en-US and nl-NL locales
mvdkleijn Sep 4, 2020
270e62d
Add admin UI option
mvdkleijn Sep 4, 2020
90d34e0
[BugFix] Fix comment broken issue ref dependence (#12651)
6543 Sep 4, 2020
9092cd6
Changelog for 1.12.4 release (#12687) (#12709)
6543 Sep 4, 2020
33f7a00
Use sugggested comment
mvdkleijn Sep 4, 2020
1d1e1cb
Update options/locale/locale_nl-NL.ini
mvdkleijn Sep 4, 2020
c358e75
fix go1.15 lint error in modules/public/public.go (#12707)
6543 Sep 4, 2020
1bd91fe
Add github api token option to generate-license & generate-gitignore …
zeripath Sep 4, 2020
1ce1a84
Add spent time to referenced issue in commit message (#12220)
lafriks Sep 4, 2020
a215e25
UI: Inform user what meaning hourglass on reviews has (#12713)
6543 Sep 4, 2020
8e92250
Test ignore migration rate limitation error (#12715)
6543 Sep 4, 2020
b07d8b8
[skip ci] Updated translations via Crowdin
GiteaBot Sep 4, 2020
5ca0c03
API: Expose its limitation settings (#12714)
6543 Sep 4, 2020
e095cde
Bump min required golang to 1.13 (#12717)
techknowlogick Sep 4, 2020
5dc3935
Remove async pre-empt hack if go >= 1.15 (#12718)
zeripath Sep 4, 2020
6f3c8cf
Check only if private only
mvdkleijn Sep 4, 2020
9e4c59d
lower private repo count when deleting repo
mvdkleijn Sep 4, 2020
6ba7ecd
Finish up changes to AdminEditUserForm and related
mvdkleijn Sep 6, 2020
e622ab7
Fix counts for create, delete, transfer and checkers
mvdkleijn Sep 6, 2020
5b08e1f
Remove entries for private repo counts
mvdkleijn Sep 6, 2020
904adca
Add details re: Kanban (#12721)
techknowlogick Sep 4, 2020
69d9716
[skip ci] Updated translations via Crowdin
GiteaBot Sep 4, 2020
73a14bb
Add 'make watch' (#12636)
silverwind Sep 5, 2020
54f9eae
Refactor webhook payload convertion (#12310)
lunny Sep 5, 2020
7cfd9a1
Use pre-built hugo binary in release step (#12725)
techknowlogick Sep 5, 2020
ec85863
Expose Attachemnt Settings by API (#12514)
6543 Sep 5, 2020
49c6516
additional data for type StopWatch in swagger api (#12458)
Sep 5, 2020
228859c
[skip ci] Updated translations via Crowdin
GiteaBot Sep 5, 2020
6f3a502
Update to go-org 1.3.2 (#12728)
zeripath Sep 5, 2020
47f8ff5
[Vendor] Switch go-version lib (#12719)
6543 Sep 5, 2020
7db213c
[skip ci] Updated translations via Crowdin
GiteaBot Sep 5, 2020
f8e2efd
Add Created & Updated to Milestone (#12662)
6543 Sep 5, 2020
3ec7b08
[skip ci] Updated translations via Crowdin
GiteaBot Sep 5, 2020
70c1aa4
refactor repo_stats to use os.pipe (#11726)
techknowlogick Sep 5, 2020
ca692f6
[skip ci] Updated translations via Crowdin
GiteaBot Sep 5, 2020
b525574
use assignment in tests (#12734)
zeripath Sep 5, 2020
56428b4
[skip ci] Updated translations via Crowdin
GiteaBot Sep 5, 2020
5ec905c
[Vendor] Fix Version Compare Lib (#12735)
6543 Sep 6, 2020
85deed1
implemet Cache for Stopwatches.APIFormat() (#12730)
6543 Sep 6, 2020
5ab210b
Fix bug on migration 111 (#12736)
lunny Sep 6, 2020
10b989c
[skip ci] Updated translations via Crowdin
GiteaBot Sep 6, 2020
f0cb378
Fix bug of migraition v111 (#12738)
lunny Sep 6, 2020
820de43
[skip ci] Updated translations via Crowdin
GiteaBot Sep 6, 2020
2647344
ui: Show git-pull-request icon for closed pull request (#12742)
a1012112796 Sep 6, 2020
5ddb0f9
[skip ci] Updated translations via Crowdin
GiteaBot Sep 6, 2020
c1a1465
[Vendor] Update xanzy/go-gitlab v0.31.0 => v0.37.0 (#12701)
6543 Sep 6, 2020
6d6a7c6
[skip ci] Updated translations via Crowdin
GiteaBot Sep 6, 2020
c4306ca
Add better Swagger description and a example for GetArchive (#12743)
6543 Sep 6, 2020
7c02c6b
Fix editor.commit_empty_file_text locale string (#12744)
zeripath Sep 6, 2020
3cacb8c
[skip ci] Updated translations via Crowdin
GiteaBot Sep 6, 2020
030b962
Add sanity check to transfer test
mvdkleijn Sep 9, 2020
ccf0057
Add missing i18n string to en-US
mvdkleijn Sep 9, 2020
fdbae4c
Change repo count update
mvdkleijn Sep 9, 2020
9658e18
Fix Avatar Resize (resize algo NearestNeighbor -> Bilinear) (#12745)
6543 Sep 6, 2020
6e18b6f
[skip ci] Updated translations via Crowdin
GiteaBot Sep 6, 2020
1d3bdba
RepoInit Respect AlternateDefaultBranch (#12746)
6543 Sep 6, 2020
338d346
Add command to recreate tables (#12407)
zeripath Sep 6, 2020
caf3e19
Upgrade bleve to v1.0.10 (#12737)
lunny Sep 6, 2020
7e5aa61
Set setting.AppURL as GITEA_ROOT_URL environment variable during push…
zeripath Sep 7, 2020
8c62833
Add queue for code indexer (#10332)
lunny Sep 7, 2020
6126835
[skip ci] Updated translations via Crowdin
GiteaBot Sep 7, 2020
876eee2
gitea dump: include version & Check InstallLock (#12760)
6543 Sep 7, 2020
0ad9c41
[skip ci] Updated translations via Crowdin
GiteaBot Sep 7, 2020
d84a8bd
Compare SSH_DOMAIN when parsing submodule URLs (#12753)
mrsdizzie Sep 8, 2020
76d263b
Removing k8s contrib file (#12761)
techknowlogick Sep 8, 2020
4559240
LFS support to be stored on minio (#12518)
lunny Sep 8, 2020
0b3545f
[skip ci] Updated translations via Crowdin
GiteaBot Sep 8, 2020
7a174b3
Change/remove a branch of an open issue (#9080)
Sep 8, 2020
ca5d5f6
File header tweaks, add CSS helpers (#12635)
silverwind Sep 8, 2020
7f56d16
Upgrade xorm to v1.0.5 (#12765)
lunny Sep 8, 2020
11b0526
Check passwords against HaveIBeenPwned (#12716)
jolheiser Sep 8, 2020
9340c7f
[skip ci] Updated translations via Crowdin
GiteaBot Sep 8, 2020
5a991dc
Fix yet another bug with diff file names (#12771)
zeripath Sep 9, 2020
77777dd
[skip ci] Updated translations via Crowdin
GiteaBot Sep 9, 2020
b1d9902
Add MySQL FAQ section (#12780)
zeripath Sep 9, 2020
945c988
[skip ci] Updated translations via Crowdin
GiteaBot Sep 9, 2020
7a76e81
Add a migrate service type switch page (#12697)
lunny Sep 9, 2020
a185dc2
[skip ci] Updated translations via Crowdin
GiteaBot Sep 9, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ steps:

- name: build-backend-no-gcc
pull: always
image: golang:1.12 # this step is kept as the lowest version of golang that we support
image: golang:1.13 # this step is kept as the lowest version of golang that we support
environment:
GO111MODULE: on
GOPROXY: off
Expand Down
1 change: 1 addition & 0 deletions .stylelintrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ rules:
block-closing-brace-empty-line-before: null
color-hex-length: null
comment-empty-line-before: null
declaration-block-single-line-max-declarations: null
declaration-empty-line-before: null
indentation: 2
no-descending-specificity: null
Expand Down
27 changes: 27 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,33 @@ This changelog goes through all the changes that have been made in each release
without substantial changes to our git log; to see the highlights of what has
been added to each release, please refer to the [blog](https://blog.gitea.io).

## [1.12.4](https://github.com/go-gitea/gitea/releases/tag/v1.12.4) - 2020-09-02

* SECURITY
* Escape provider name in oauth2 provider redirect (#12648) (#12650)
* Escape Email on password reset page (#12610) (#12612)
* When reading expired sessions - expire them (#12686) (#12690)
* ENHANCEMENTS
* StaticRootPath configurable at compile time (#12371) (#12652)
* BUGFIXES
* Fix to show an issue that is related to a deleted issue (#12651) (#12692)
* Expire time acknowledged for cache (#12605) (#12611)
* Fix diff path unquoting (#12554) (#12575)
* Improve HTML escaping helper (#12562)
* models: break out of loop (#12386) (#12561)
* Default empty merger list to those with write permissions (#12535) (#12560)
* Skip SSPI authentication attempts for /api/internal (#12556) (#12559)
* Prevent NPE on commenting on lines with invalidated comments (#12549) (#12550)
* Remove hardcoded ES indexername (#12521) (#12526)
* Fix bug preventing transfer to private organization (#12497) (#12501)
* Keys should not verify revoked email addresses (#12486) (#12495)
* Do not add prefix on http/https submodule links (#12477) (#12479)
* Fix ignored login on compare (#12476) (#12478)
* Fix incorrect error logging in Stats indexer and OAuth2 (#12387) (#12422)
* Upgrade google/go-github to v32.1.0 (#12361) (#12390)
* Render emoji's of Commit message on feed-page (#12373)
* Fix handling of diff on unrelated branches when Git 2.28 used (#12370)

## [1.12.3](https://github.com/go-gitea/gitea/releases/tag/v1.12.3) - 2020-07-28

* BUGFIXES
Expand Down
11 changes: 8 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ HAS_GO = $(shell hash $(GO) > /dev/null 2>&1 && echo "GO" || echo "NOGO" )
COMMA := ,

XGO_VERSION := go-1.15.x
MIN_GO_VERSION := 001012000
MIN_GO_VERSION := 001013000
MIN_NODE_VERSION := 010013000

DOCKER_IMAGE ?= gitea/gitea
Expand Down Expand Up @@ -155,6 +155,7 @@ help:
@echo " - build build everything"
@echo " - frontend build frontend files"
@echo " - backend build backend files"
@echo " - watch watch everything and continuously rebuild"
@echo " - watch-frontend watch frontend files and continuously rebuild"
@echo " - watch-backend watch backend files and continuously rebuild"
@echo " - clean delete backend and integration files"
Expand Down Expand Up @@ -186,7 +187,7 @@ help:
go-check:
$(eval GO_VERSION := $(shell printf "%03d%03d%03d" $(shell go version | grep -Eo '[0-9]+\.[0-9.]+' | tr '.' ' ');))
@if [ "$(GO_VERSION)" -lt "$(MIN_GO_VERSION)" ]; then \
echo "Gitea requires Go 1.12 or greater to build. You can get it at https://golang.org/dl/"; \
echo "Gitea requires Go 1.13 or greater to build. You can get it at https://golang.org/dl/"; \
exit 1; \
fi

Expand Down Expand Up @@ -316,6 +317,10 @@ lint-frontend: node_modules
.PHONY: lint-backend
lint-backend: golangci-lint revive vet

.PHONY: watch
watch:
bash tools/watch.sh

.PHONY: watch-frontend
watch-frontend: node-check $(FOMANTIC_DEST) node_modules
rm -rf $(WEBPACK_DEST_ENTRIES)
Expand Down Expand Up @@ -612,7 +617,7 @@ release-docs: | $(DIST_DIRS) docs
.PHONY: docs
docs:
@hash hugo > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
$(GO) get -u github.com/gohugoio/hugo; \
curl -sL https://github.com/gohugoio/hugo/releases/download/v0.74.3/hugo_0.74.3_Linux-64bit.tar.gz | tar zxf - -C /tmp && mv /tmp/hugo /usr/bin/hugo && chmod +x /usr/bin/hugo; \
fi
cd docs; make trans-copy clean build-offline;

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ or if sqlite support is required:

The `build` target is split into two sub-targets:

- `make backend` which requires [Go 1.12](https://golang.org/dl/) or greater.
- `make backend` which requires [Go 1.13](https://golang.org/dl/) or greater.
- `make frontend` which requires [Node.js 10.13](https://nodejs.org/en/download/) or greater.

If pre-built frontend files are present it is possible to only build the backend:
Expand Down
21 changes: 16 additions & 5 deletions build/generate-gitignores.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,16 @@ import (

func main() {
var (
prefix = "gitea-gitignore"
url = "https://api.github.com/repos/github/gitignore/tarball"
destination = ""
prefix = "gitea-gitignore"
url = "https://api.github.com/repos/github/gitignore/tarball"
githubApiToken = ""
githubUsername = ""
destination = ""
)

flag.StringVar(&destination, "dest", "options/gitignore/", "destination for the gitignores")
flag.StringVar(&githubUsername, "username", "", "github username")
flag.StringVar(&githubApiToken, "token", "", "github api token")
flag.Parse()

file, err := ioutil.TempFile(os.TempDir(), prefix)
Expand All @@ -37,12 +41,19 @@ func main() {

defer util.Remove(file.Name())

resp, err := http.Get(url)

req, err := http.NewRequest("GET", url, nil)
if err != nil {
log.Fatalf("Failed to download archive. %s", err)
}

if len(githubApiToken) > 0 && len(githubUsername) > 0 {
req.SetBasicAuth(githubUsername, githubApiToken)
}

resp, err := http.DefaultClient.Do(req)
if err != nil {
log.Fatalf("Failed to download archive. %s", err)
}
defer resp.Body.Close()

if _, err := io.Copy(file, resp.Body); err != nil {
Expand Down
20 changes: 16 additions & 4 deletions build/generate-licenses.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,16 @@ import (

func main() {
var (
prefix = "gitea-licenses"
url = "https://api.github.com/repos/spdx/license-list-data/tarball"
destination = ""
prefix = "gitea-licenses"
url = "https://api.github.com/repos/spdx/license-list-data/tarball"
githubApiToken = ""
githubUsername = ""
destination = ""
)

flag.StringVar(&destination, "dest", "options/license/", "destination for the licenses")
flag.StringVar(&githubUsername, "username", "", "github username")
flag.StringVar(&githubApiToken, "token", "", "github api token")
flag.Parse()

file, err := ioutil.TempFile(os.TempDir(), prefix)
Expand All @@ -37,8 +41,16 @@ func main() {

defer util.Remove(file.Name())

resp, err := http.Get(url)
req, err := http.NewRequest("GET", url, nil)
if err != nil {
log.Fatalf("Failed to download archive. %s", err)
}

if len(githubApiToken) > 0 && len(githubUsername) > 0 {
req.SetBasicAuth(githubUsername, githubApiToken)
}

resp, err := http.DefaultClient.Do(req)
if err != nil {
log.Fatalf("Failed to download archive. %s", err)
}
Expand Down
8 changes: 8 additions & 0 deletions cmd/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package cmd

import (
"context"
"errors"
"fmt"
"os"
Expand Down Expand Up @@ -265,6 +266,13 @@ func runChangePassword(c *cli.Context) error {
if !pwd.IsComplexEnough(c.String("password")) {
return errors.New("Password does not meet complexity requirements")
}
pwned, err := pwd.IsPwned(context.Background(), c.String("password"))
if err != nil {
return err
}
if pwned {
return errors.New("The password you chose is on a list of stolen passwords previously exposed in public data breaches. Please try again with a different password.\nFor more details, see https://haveibeenpwned.com/Passwords")
}
uname := c.String("username")
user, err := models.GetUserByName(uname)
if err != nil {
Expand Down
63 changes: 63 additions & 0 deletions cmd/doctor.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/util"
"xorm.io/builder"
"xorm.io/xorm"

"github.com/urfave/cli"
)
Expand Down Expand Up @@ -62,6 +63,27 @@ var CmdDoctor = cli.Command{
Usage: `Name of the log file (default: "doctor.log"). Set to "-" to output to stdout, set to "" to disable`,
},
},
Subcommands: []cli.Command{
cmdRecreateTable,
},
}

var cmdRecreateTable = cli.Command{
Name: "recreate-table",
Usage: "Recreate tables from XORM definitions and copy the data.",
ArgsUsage: "[TABLE]... : (TABLEs to recreate - leave blank for all)",
Flags: []cli.Flag{
cli.BoolFlag{
Name: "debug",
Usage: "Print SQL commands sent",
},
},
Description: `The database definitions Gitea uses change across versions, sometimes changing default values and leaving old unused columns.

This command will cause Xorm to recreate tables, copying over the data and deleting the old table.

You should back-up your database before doing this and ensure that your database is up-to-date first.`,
Action: runRecreateTable,
}

type check struct {
Expand Down Expand Up @@ -136,6 +158,47 @@ var checklist = []check{
// more checks please append here
}

func runRecreateTable(ctx *cli.Context) error {
// Redirect the default golog to here
golog.SetFlags(0)
golog.SetPrefix("")
golog.SetOutput(log.NewLoggerAsWriter("INFO", log.GetLogger(log.DEFAULT)))

setting.NewContext()
setting.InitDBConfig()

setting.EnableXORMLog = ctx.Bool("debug")
setting.Database.LogSQL = ctx.Bool("debug")
setting.Cfg.Section("log").Key("XORM").SetValue(",")

setting.NewXORMLogService(!ctx.Bool("debug"))
if err := models.SetEngine(); err != nil {
fmt.Println(err)
fmt.Println("Check if you are using the right config file. You can use a --config directive to specify one.")
return nil
}

args := ctx.Args()
names := make([]string, 0, ctx.NArg())
for i := 0; i < ctx.NArg(); i++ {
names = append(names, args.Get(i))
}

beans, err := models.NamesToBean(names...)
if err != nil {
return err
}
recreateTables := migrations.RecreateTables(beans...)

return models.NewEngine(context.Background(), func(x *xorm.Engine) error {
if err := migrations.EnsureUpToDate(x); err != nil {
return err
}
return recreateTables(x)
})

}

func runDoctor(ctx *cli.Context) error {

// Silence the default loggers
Expand Down
4 changes: 4 additions & 0 deletions cmd/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,10 @@ func runDump(ctx *cli.Context) error {
if _, err := setting.Cfg.Section("log.console").NewKey("STDERR", "true"); err != nil {
fatal("Setting console logger to stderr failed: %v", err)
}
if !setting.InstallLock {
log.Error("Is '%s' really the right config path?\n", setting.CustomConf)
return fmt.Errorf("gitea is not initialized")
}
setting.NewServices() // cannot access session settings otherwise

err := models.SetEngine()
Expand Down
74 changes: 43 additions & 31 deletions cmd/migrate_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@ func migrateAttachments(dstStorage storage.ObjectStorage) error {
})
}

func migrateLFS(dstStorage storage.ObjectStorage) error {
return models.IterateLFS(func(mo *models.LFSMetaObject) error {
_, err := storage.Copy(dstStorage, mo.RelativePath(), storage.LFS, mo.RelativePath())
return err
})
}

func runMigrateStorage(ctx *cli.Context) error {
if err := initDB(); err != nil {
return err
Expand All @@ -103,45 +110,50 @@ func runMigrateStorage(ctx *cli.Context) error {
return err
}

var dstStorage storage.ObjectStorage
var err error
switch ctx.String("store") {
case "local":
p := ctx.String("path")
if p == "" {
log.Fatal("Path must be given when store is loal")
return nil
}
dstStorage, err = storage.NewLocalStorage(p)
case "minio":
dstStorage, err = storage.NewMinioStorage(
context.Background(),
ctx.String("minio-endpoint"),
ctx.String("minio-access-key-id"),
ctx.String("minio-secret-access-key"),
ctx.String("minio-bucket"),
ctx.String("minio-location"),
ctx.String("minio-base-path"),
ctx.Bool("minio-use-ssl"),
)
default:
return fmt.Errorf("Unsupported attachments store type: %s", ctx.String("store"))
}

if err != nil {
return err
}

tp := ctx.String("type")
switch tp {
case "attachments":
var dstStorage storage.ObjectStorage
var err error
switch ctx.String("store") {
case "local":
p := ctx.String("path")
if p == "" {
log.Fatal("Path must be given when store is loal")
return nil
}
dstStorage, err = storage.NewLocalStorage(p)
case "minio":
dstStorage, err = storage.NewMinioStorage(
context.Background(),
ctx.String("minio-endpoint"),
ctx.String("minio-access-key-id"),
ctx.String("minio-secret-access-key"),
ctx.String("minio-bucket"),
ctx.String("minio-location"),
ctx.String("minio-base-path"),
ctx.Bool("minio-use-ssl"),
)
default:
return fmt.Errorf("Unsupported attachments store type: %s", ctx.String("store"))
}

if err != nil {
if err := migrateAttachments(dstStorage); err != nil {
return err
}
if err := migrateAttachments(dstStorage); err != nil {
case "lfs":
if err := migrateLFS(dstStorage); err != nil {
return err
}

log.Warn("All files have been copied to the new placement but old files are still on the orignial placement.")

return nil
default:
return fmt.Errorf("Unsupported storage: %s", ctx.String("type"))
}

log.Warn("All files have been copied to the new placement but old files are still on the orignial placement.")

return nil
}
Loading