// Copyright 2017 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 repo import ( "context" "fmt" "strings" "code.gitea.io/gitea/models/db" ) // ErrRedirectNotExist represents a "RedirectNotExist" kind of error. type ErrRedirectNotExist struct { OwnerID int64 RepoName string } // IsErrRedirectNotExist check if an error is an ErrRepoRedirectNotExist. func IsErrRedirectNotExist(err error) bool { _, ok := err.(ErrRedirectNotExist) return ok } func (err ErrRedirectNotExist) Error() string { return fmt.Sprintf("repository redirect does not exist [uid: %d, name: %s]", err.OwnerID, err.RepoName) } // Redirect represents that a repo name should be redirected to another type Redirect struct { ID int64 `xorm:"pk autoincr"` OwnerID int64 `xorm:"UNIQUE(s)"` LowerName string `xorm:"UNIQUE(s) INDEX NOT NULL"` RedirectRepoID int64 // repoID to redirect to } // TableName represents real table name in database func (Redirect) TableName() string { return "repo_redirect" } func init() { db.RegisterModel(new(Redirect)) } // LookupRedirect look up if a repository has a redirect name func LookupRedirect(ownerID int64, repoName string) (int64, error) { repoName = strings.ToLower(repoName) redirect := &Redirect{OwnerID: ownerID, LowerName: repoName} if has, err := db.GetEngine(db.DefaultContext).Get(redirect); err != nil { return 0, err } else if !has { return 0, ErrRedirectNotExist{OwnerID: ownerID, RepoName: repoName} } return redirect.RedirectRepoID, nil } // NewRedirect create a new repo redirect func NewRedirect(ctx context.Context, ownerID, repoID int64, oldRepoName, newRepoName string) error { oldRepoName = strings.ToLower(oldRepoName) newRepoName = strings.ToLower(newRepoName) if err := DeleteRedirect(ctx, ownerID, newRepoName); err != nil { return err } return db.Insert(ctx, &Redirect{ OwnerID: ownerID, LowerName: oldRepoName, RedirectRepoID: repoID, }) } // DeleteRedirect delete any redirect from the specified repo name to // anything else func DeleteRedirect(ctx context.Context, ownerID int64, repoName string) error { repoName = strings.ToLower(repoName) _, err := db.GetEngine(ctx).Delete(&Redirect{OwnerID: ownerID, LowerName: repoName}) return err } tive' href='/gitea.git/tree/build.go?h=v1.20.0-rc0&id=cce006b857e273c58fc66b1aba20a9f719c7adef'>treecommitdiffstats
path: root/build.go
blob: ab57fb1d9a0e00f8e57a11faadfd841ccbf4e3c8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// 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.

//+build vendor

package main

// Libraries that are included to vendor utilities used during build.
// These libraries will not be included in a normal compilation.

import (
	// for lint
	_ "github.com/mgechev/dots"
	_ "github.com/mgechev/revive/formatter"
	_ "github.com/mgechev/revive/lint"
	_ "github.com/mgechev/revive/rule"
	_ "github.com/mitchellh/go-homedir"
	_ "github.com/pelletier/go-toml"

	// for embed
	_ "github.com/shurcooL/vfsgen"

	// for cover merge
	_ "golang.org/x/tools/cover"

	// for vet
	_ "code.gitea.io/gitea-vet"

	// for swagger
	_ "github.com/go-swagger/go-swagger/cmd/swagger"
)