mirror of
https://github.com/gogs/gogs.git
synced 2025-12-21 07:39:59 +01:00
internal: move packages under this directory (#5836)
* Rename pkg -> internal * Rename routes -> route * Move route -> internal/route * Rename models -> db * Move db -> internal/db * Fix route2 -> route * Move cmd -> internal/cmd * Bump version
This commit is contained in:
10
Makefile
10
Makefile
@@ -1,9 +1,9 @@
|
||||
LDFLAGS += -X "github.com/gogs/gogs/pkg/setting.BuildTime=$(shell date -u '+%Y-%m-%d %I:%M:%S %Z')"
|
||||
LDFLAGS += -X "github.com/gogs/gogs/pkg/setting.BuildGitHash=$(shell git rev-parse HEAD)"
|
||||
LDFLAGS += -X "gogs.io/gogs/internal/setting.BuildTime=$(shell date -u '+%Y-%m-%d %I:%M:%S %Z')"
|
||||
LDFLAGS += -X "gogs.io/gogs/internal/setting.BuildGitHash=$(shell git rev-parse HEAD)"
|
||||
|
||||
DATA_FILES := $(shell find conf | sed 's/ /\\ /g')
|
||||
LESS_FILES := $(wildcard public/less/gogs.less public/less/_*.less)
|
||||
GENERATED := pkg/bindata/bindata.go public/css/gogs.css
|
||||
GENERATED := internal/bindata/bindata.go public/css/gogs.css
|
||||
|
||||
OS := $(shell uname)
|
||||
|
||||
@@ -51,9 +51,9 @@ pack:
|
||||
|
||||
release: build pack
|
||||
|
||||
bindata: pkg/bindata/bindata.go
|
||||
bindata: internal/bindata/bindata.go
|
||||
|
||||
pkg/bindata/bindata.go: $(DATA_FILES)
|
||||
internal/bindata/bindata.go: $(DATA_FILES)
|
||||
go-bindata -o=$@ -ignore="\\.DS_Store|README.md|TRANSLATORS|auth.d" -pkg=bindata conf/...
|
||||
|
||||
less: public/css/gogs.css
|
||||
|
||||
6
gogs.go
6
gogs.go
@@ -12,11 +12,11 @@ import (
|
||||
|
||||
"github.com/urfave/cli"
|
||||
|
||||
"gogs.io/gogs/cmd"
|
||||
"gogs.io/gogs/pkg/setting"
|
||||
"gogs.io/gogs/internal/cmd"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
)
|
||||
|
||||
const Version = "0.11.95.1023"
|
||||
const Version = "0.11.95.1024"
|
||||
|
||||
func init() {
|
||||
setting.AppVer = Version
|
||||
|
||||
@@ -13,10 +13,10 @@ import (
|
||||
log "gopkg.in/clog.v1"
|
||||
"gopkg.in/macaron.v1"
|
||||
|
||||
"gogs.io/gogs/models"
|
||||
"gogs.io/gogs/models/errors"
|
||||
"gogs.io/gogs/pkg/setting"
|
||||
"gogs.io/gogs/pkg/tool"
|
||||
"gogs.io/gogs/internal/db"
|
||||
"gogs.io/gogs/internal/db/errors"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
"gogs.io/gogs/internal/tool"
|
||||
)
|
||||
|
||||
func IsAPIPath(url string) bool {
|
||||
@@ -26,7 +26,7 @@ func IsAPIPath(url string) bool {
|
||||
// SignedInID returns the id of signed in user, along with one bool value which indicates whether user uses token
|
||||
// authentication.
|
||||
func SignedInID(c *macaron.Context, sess session.Store) (_ int64, isTokenAuth bool) {
|
||||
if !models.HasEngine {
|
||||
if !db.HasEngine {
|
||||
return 0, false
|
||||
}
|
||||
|
||||
@@ -49,15 +49,15 @@ func SignedInID(c *macaron.Context, sess session.Store) (_ int64, isTokenAuth bo
|
||||
|
||||
// Let's see if token is valid.
|
||||
if len(tokenSHA) > 0 {
|
||||
t, err := models.GetAccessTokenBySHA(tokenSHA)
|
||||
t, err := db.GetAccessTokenBySHA(tokenSHA)
|
||||
if err != nil {
|
||||
if !models.IsErrAccessTokenNotExist(err) && !models.IsErrAccessTokenEmpty(err) {
|
||||
if !db.IsErrAccessTokenNotExist(err) && !db.IsErrAccessTokenEmpty(err) {
|
||||
log.Error(2, "GetAccessTokenBySHA: %v", err)
|
||||
}
|
||||
return 0, false
|
||||
}
|
||||
t.Updated = time.Now()
|
||||
if err = models.UpdateAccessToken(t); err != nil {
|
||||
if err = db.UpdateAccessToken(t); err != nil {
|
||||
log.Error(2, "UpdateAccessToken: %v", err)
|
||||
}
|
||||
return t.UID, true
|
||||
@@ -69,7 +69,7 @@ func SignedInID(c *macaron.Context, sess session.Store) (_ int64, isTokenAuth bo
|
||||
return 0, false
|
||||
}
|
||||
if id, ok := uid.(int64); ok {
|
||||
if _, err := models.GetUserByID(id); err != nil {
|
||||
if _, err := db.GetUserByID(id); err != nil {
|
||||
if !errors.IsUserNotExist(err) {
|
||||
log.Error(2, "GetUserByID: %v", err)
|
||||
}
|
||||
@@ -82,8 +82,8 @@ func SignedInID(c *macaron.Context, sess session.Store) (_ int64, isTokenAuth bo
|
||||
|
||||
// SignedInUser returns the user object of signed in user, along with two bool values,
|
||||
// which indicate whether user uses HTTP Basic Authentication or token authentication respectively.
|
||||
func SignedInUser(ctx *macaron.Context, sess session.Store) (_ *models.User, isBasicAuth bool, isTokenAuth bool) {
|
||||
if !models.HasEngine {
|
||||
func SignedInUser(ctx *macaron.Context, sess session.Store) (_ *db.User, isBasicAuth bool, isTokenAuth bool) {
|
||||
if !db.HasEngine {
|
||||
return nil, false, false
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ func SignedInUser(ctx *macaron.Context, sess session.Store) (_ *models.User, isB
|
||||
if setting.Service.EnableReverseProxyAuth {
|
||||
webAuthUser := ctx.Req.Header.Get(setting.ReverseProxyAuthUser)
|
||||
if len(webAuthUser) > 0 {
|
||||
u, err := models.GetUserByName(webAuthUser)
|
||||
u, err := db.GetUserByName(webAuthUser)
|
||||
if err != nil {
|
||||
if !errors.IsUserNotExist(err) {
|
||||
log.Error(2, "GetUserByName: %v", err)
|
||||
@@ -102,13 +102,13 @@ func SignedInUser(ctx *macaron.Context, sess session.Store) (_ *models.User, isB
|
||||
|
||||
// Check if enabled auto-registration.
|
||||
if setting.Service.EnableReverseProxyAutoRegister {
|
||||
u := &models.User{
|
||||
u := &db.User{
|
||||
Name: webAuthUser,
|
||||
Email: gouuid.NewV4().String() + "@localhost",
|
||||
Passwd: webAuthUser,
|
||||
IsActive: true,
|
||||
}
|
||||
if err = models.CreateUser(u); err != nil {
|
||||
if err = db.CreateUser(u); err != nil {
|
||||
// FIXME: should I create a system notice?
|
||||
log.Error(2, "CreateUser: %v", err)
|
||||
return nil, false, false
|
||||
@@ -128,7 +128,7 @@ func SignedInUser(ctx *macaron.Context, sess session.Store) (_ *models.User, isB
|
||||
if len(auths) == 2 && auths[0] == "Basic" {
|
||||
uname, passwd, _ := tool.BasicAuthDecode(auths[1])
|
||||
|
||||
u, err := models.UserLogin(uname, passwd, -1)
|
||||
u, err := db.UserLogin(uname, passwd, -1)
|
||||
if err != nil {
|
||||
if !errors.IsUserNotExist(err) {
|
||||
log.Error(2, "UserLogin: %v", err)
|
||||
@@ -142,7 +142,7 @@ func SignedInUser(ctx *macaron.Context, sess session.Store) (_ *models.User, isB
|
||||
return nil, false, false
|
||||
}
|
||||
|
||||
u, err := models.GetUserByID(uid)
|
||||
u, err := db.GetUserByID(uid)
|
||||
if err != nil {
|
||||
log.Error(2, "GetUserByID: %v", err)
|
||||
return nil, false, false
|
||||
@@ -11,8 +11,8 @@ import (
|
||||
|
||||
"github.com/urfave/cli"
|
||||
|
||||
"gogs.io/gogs/models"
|
||||
"gogs.io/gogs/pkg/setting"
|
||||
"gogs.io/gogs/internal/db"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -50,7 +50,7 @@ to make automatic initialization process more smoothly`,
|
||||
Name: "delete-inactive-users",
|
||||
Usage: "Delete all inactive accounts",
|
||||
Action: adminDashboardOperation(
|
||||
models.DeleteInactivateUsers,
|
||||
db.DeleteInactivateUsers,
|
||||
"All inactivate accounts have been deleted successfully",
|
||||
),
|
||||
Flags: []cli.Flag{
|
||||
@@ -62,7 +62,7 @@ to make automatic initialization process more smoothly`,
|
||||
Name: "delete-repository-archives",
|
||||
Usage: "Delete all repositories archives",
|
||||
Action: adminDashboardOperation(
|
||||
models.DeleteRepositoryArchives,
|
||||
db.DeleteRepositoryArchives,
|
||||
"All repositories archives have been deleted successfully",
|
||||
),
|
||||
Flags: []cli.Flag{
|
||||
@@ -74,7 +74,7 @@ to make automatic initialization process more smoothly`,
|
||||
Name: "delete-missing-repositories",
|
||||
Usage: "Delete all repository records that lost Git files",
|
||||
Action: adminDashboardOperation(
|
||||
models.DeleteMissingRepositories,
|
||||
db.DeleteMissingRepositories,
|
||||
"All repositories archives have been deleted successfully",
|
||||
),
|
||||
Flags: []cli.Flag{
|
||||
@@ -86,7 +86,7 @@ to make automatic initialization process more smoothly`,
|
||||
Name: "collect-garbage",
|
||||
Usage: "Do garbage collection on repositories",
|
||||
Action: adminDashboardOperation(
|
||||
models.GitGcRepos,
|
||||
db.GitGcRepos,
|
||||
"All repositories have done garbage collection successfully",
|
||||
),
|
||||
Flags: []cli.Flag{
|
||||
@@ -98,7 +98,7 @@ to make automatic initialization process more smoothly`,
|
||||
Name: "rewrite-authorized-keys",
|
||||
Usage: "Rewrite '.ssh/authorized_keys' file (caution: non-Gogs keys will be lost)",
|
||||
Action: adminDashboardOperation(
|
||||
models.RewriteAuthorizedKeys,
|
||||
db.RewriteAuthorizedKeys,
|
||||
"All public keys have been rewritten successfully",
|
||||
),
|
||||
Flags: []cli.Flag{
|
||||
@@ -110,7 +110,7 @@ to make automatic initialization process more smoothly`,
|
||||
Name: "resync-hooks",
|
||||
Usage: "Resync pre-receive, update and post-receive hooks",
|
||||
Action: adminDashboardOperation(
|
||||
models.SyncRepositoryHooks,
|
||||
db.SyncRepositoryHooks,
|
||||
"All repositories' pre-receive, update and post-receive hooks have been resynced successfully",
|
||||
),
|
||||
Flags: []cli.Flag{
|
||||
@@ -122,7 +122,7 @@ to make automatic initialization process more smoothly`,
|
||||
Name: "reinit-missing-repositories",
|
||||
Usage: "Reinitialize all repository records that lost Git files",
|
||||
Action: adminDashboardOperation(
|
||||
models.ReinitMissingRepositories,
|
||||
db.ReinitMissingRepositories,
|
||||
"All repository records that lost Git files have been reinitialized successfully",
|
||||
),
|
||||
Flags: []cli.Flag{
|
||||
@@ -145,10 +145,10 @@ func runCreateUser(c *cli.Context) error {
|
||||
}
|
||||
|
||||
setting.NewContext()
|
||||
models.LoadConfigs()
|
||||
models.SetEngine()
|
||||
db.LoadConfigs()
|
||||
db.SetEngine()
|
||||
|
||||
if err := models.CreateUser(&models.User{
|
||||
if err := db.CreateUser(&db.User{
|
||||
Name: c.String("name"),
|
||||
Email: c.String("email"),
|
||||
Passwd: c.String("password"),
|
||||
@@ -169,8 +169,8 @@ func adminDashboardOperation(operation func() error, successMessage string) func
|
||||
}
|
||||
|
||||
setting.NewContext()
|
||||
models.LoadConfigs()
|
||||
models.SetEngine()
|
||||
db.LoadConfigs()
|
||||
db.SetEngine()
|
||||
|
||||
if err := operation(); err != nil {
|
||||
functionName := runtime.FuncForPC(reflect.ValueOf(operation).Pointer()).Name()
|
||||
@@ -17,8 +17,8 @@ import (
|
||||
log "gopkg.in/clog.v1"
|
||||
"gopkg.in/ini.v1"
|
||||
|
||||
"gogs.io/gogs/models"
|
||||
"gogs.io/gogs/pkg/setting"
|
||||
"gogs.io/gogs/internal/db"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
)
|
||||
|
||||
var Backup = cli.Command{
|
||||
@@ -48,8 +48,8 @@ func runBackup(c *cli.Context) error {
|
||||
setting.CustomConf = c.String("config")
|
||||
}
|
||||
setting.NewContext()
|
||||
models.LoadConfigs()
|
||||
models.SetEngine()
|
||||
db.LoadConfigs()
|
||||
db.SetEngine()
|
||||
|
||||
tmpDir := c.String("tempdir")
|
||||
if !com.IsExist(tmpDir) {
|
||||
@@ -84,7 +84,7 @@ func runBackup(c *cli.Context) error {
|
||||
|
||||
// Database
|
||||
dbDir := path.Join(rootDir, "db")
|
||||
if err = models.DumpDatabase(dbDir); err != nil {
|
||||
if err = db.DumpDatabase(dbDir); err != nil {
|
||||
log.Fatal(0, "Fail to dump database: %v", err)
|
||||
}
|
||||
if err = z.AddDir(_ARCHIVE_ROOT_DIR+"/db", dbDir); err != nil {
|
||||
@@ -21,12 +21,12 @@ import (
|
||||
|
||||
"github.com/gogs/git-module"
|
||||
|
||||
"gogs.io/gogs/models"
|
||||
"gogs.io/gogs/models/errors"
|
||||
"gogs.io/gogs/pkg/httplib"
|
||||
"gogs.io/gogs/pkg/mailer"
|
||||
"gogs.io/gogs/pkg/setting"
|
||||
"gogs.io/gogs/pkg/template"
|
||||
"gogs.io/gogs/internal/db"
|
||||
"gogs.io/gogs/internal/db/errors"
|
||||
"gogs.io/gogs/internal/httplib"
|
||||
"gogs.io/gogs/internal/mailer"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
"gogs.io/gogs/internal/template"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -70,7 +70,7 @@ func runHookPreReceive(c *cli.Context) error {
|
||||
}
|
||||
setup(c, "hooks/pre-receive.log", true)
|
||||
|
||||
isWiki := strings.Contains(os.Getenv(models.ENV_REPO_CUSTOM_HOOKS_PATH), ".wiki.git/")
|
||||
isWiki := strings.Contains(os.Getenv(db.ENV_REPO_CUSTOM_HOOKS_PATH), ".wiki.git/")
|
||||
|
||||
buf := bytes.NewBuffer(nil)
|
||||
scanner := bufio.NewScanner(os.Stdin)
|
||||
@@ -91,8 +91,8 @@ func runHookPreReceive(c *cli.Context) error {
|
||||
branchName := strings.TrimPrefix(string(fields[2]), git.BRANCH_PREFIX)
|
||||
|
||||
// Branch protection
|
||||
repoID := com.StrTo(os.Getenv(models.ENV_REPO_ID)).MustInt64()
|
||||
protectBranch, err := models.GetProtectBranchOfRepoByName(repoID, branchName)
|
||||
repoID := com.StrTo(os.Getenv(db.ENV_REPO_ID)).MustInt64()
|
||||
protectBranch, err := db.GetProtectBranchOfRepoByName(repoID, branchName)
|
||||
if err != nil {
|
||||
if errors.IsErrBranchNotExist(err) {
|
||||
continue
|
||||
@@ -107,9 +107,9 @@ func runHookPreReceive(c *cli.Context) error {
|
||||
bypassRequirePullRequest := false
|
||||
|
||||
// Check if user is in whitelist when enabled
|
||||
userID := com.StrTo(os.Getenv(models.ENV_AUTH_USER_ID)).MustInt64()
|
||||
userID := com.StrTo(os.Getenv(db.ENV_AUTH_USER_ID)).MustInt64()
|
||||
if protectBranch.EnableWhitelist {
|
||||
if !models.IsUserInProtectBranchWhitelist(repoID, userID, branchName) {
|
||||
if !db.IsUserInProtectBranchWhitelist(repoID, userID, branchName) {
|
||||
fail(fmt.Sprintf("Branch '%s' is protected and you are not in the push whitelist", branchName), "")
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ func runHookPreReceive(c *cli.Context) error {
|
||||
|
||||
// Check force push
|
||||
output, err := git.NewCommand("rev-list", "--max-count=1", oldCommitID, "^"+newCommitID).
|
||||
RunInDir(models.RepoPath(os.Getenv(models.ENV_REPO_OWNER_NAME), os.Getenv(models.ENV_REPO_NAME)))
|
||||
RunInDir(db.RepoPath(os.Getenv(db.ENV_REPO_OWNER_NAME), os.Getenv(db.ENV_REPO_NAME)))
|
||||
if err != nil {
|
||||
fail("Internal error", "Fail to detect force push: %v", err)
|
||||
} else if len(output) > 0 {
|
||||
@@ -136,7 +136,7 @@ func runHookPreReceive(c *cli.Context) error {
|
||||
}
|
||||
}
|
||||
|
||||
customHooksPath := filepath.Join(os.Getenv(models.ENV_REPO_CUSTOM_HOOKS_PATH), "pre-receive")
|
||||
customHooksPath := filepath.Join(os.Getenv(db.ENV_REPO_CUSTOM_HOOKS_PATH), "pre-receive")
|
||||
if !com.IsFile(customHooksPath) {
|
||||
return nil
|
||||
}
|
||||
@@ -147,7 +147,7 @@ func runHookPreReceive(c *cli.Context) error {
|
||||
} else {
|
||||
hookCmd = exec.Command(customHooksPath)
|
||||
}
|
||||
hookCmd.Dir = models.RepoPath(os.Getenv(models.ENV_REPO_OWNER_NAME), os.Getenv(models.ENV_REPO_NAME))
|
||||
hookCmd.Dir = db.RepoPath(os.Getenv(db.ENV_REPO_OWNER_NAME), os.Getenv(db.ENV_REPO_NAME))
|
||||
hookCmd.Stdout = os.Stdout
|
||||
hookCmd.Stdin = buf
|
||||
hookCmd.Stderr = os.Stderr
|
||||
@@ -170,7 +170,7 @@ func runHookUpdate(c *cli.Context) error {
|
||||
fail("First argument 'refName' is empty", "First argument 'refName' is empty")
|
||||
}
|
||||
|
||||
customHooksPath := filepath.Join(os.Getenv(models.ENV_REPO_CUSTOM_HOOKS_PATH), "update")
|
||||
customHooksPath := filepath.Join(os.Getenv(db.ENV_REPO_CUSTOM_HOOKS_PATH), "update")
|
||||
if !com.IsFile(customHooksPath) {
|
||||
return nil
|
||||
}
|
||||
@@ -181,7 +181,7 @@ func runHookUpdate(c *cli.Context) error {
|
||||
} else {
|
||||
hookCmd = exec.Command(customHooksPath, args...)
|
||||
}
|
||||
hookCmd.Dir = models.RepoPath(os.Getenv(models.ENV_REPO_OWNER_NAME), os.Getenv(models.ENV_REPO_NAME))
|
||||
hookCmd.Dir = db.RepoPath(os.Getenv(db.ENV_REPO_OWNER_NAME), os.Getenv(db.ENV_REPO_NAME))
|
||||
hookCmd.Stdout = os.Stdout
|
||||
hookCmd.Stdin = os.Stdin
|
||||
hookCmd.Stderr = os.Stderr
|
||||
@@ -204,7 +204,7 @@ func runHookPostReceive(c *cli.Context) error {
|
||||
mailer.InitMailRender(path.Join(setting.StaticRootPath, "templates/mail"),
|
||||
path.Join(setting.CustomPath, "templates/mail"), template.NewFuncMap())
|
||||
|
||||
isWiki := strings.Contains(os.Getenv(models.ENV_REPO_CUSTOM_HOOKS_PATH), ".wiki.git/")
|
||||
isWiki := strings.Contains(os.Getenv(db.ENV_REPO_CUSTOM_HOOKS_PATH), ".wiki.git/")
|
||||
|
||||
buf := bytes.NewBuffer(nil)
|
||||
scanner := bufio.NewScanner(os.Stdin)
|
||||
@@ -222,24 +222,24 @@ func runHookPostReceive(c *cli.Context) error {
|
||||
continue
|
||||
}
|
||||
|
||||
options := models.PushUpdateOptions{
|
||||
options := db.PushUpdateOptions{
|
||||
OldCommitID: string(fields[0]),
|
||||
NewCommitID: string(fields[1]),
|
||||
RefFullName: string(fields[2]),
|
||||
PusherID: com.StrTo(os.Getenv(models.ENV_AUTH_USER_ID)).MustInt64(),
|
||||
PusherName: os.Getenv(models.ENV_AUTH_USER_NAME),
|
||||
RepoUserName: os.Getenv(models.ENV_REPO_OWNER_NAME),
|
||||
RepoName: os.Getenv(models.ENV_REPO_NAME),
|
||||
PusherID: com.StrTo(os.Getenv(db.ENV_AUTH_USER_ID)).MustInt64(),
|
||||
PusherName: os.Getenv(db.ENV_AUTH_USER_NAME),
|
||||
RepoUserName: os.Getenv(db.ENV_REPO_OWNER_NAME),
|
||||
RepoName: os.Getenv(db.ENV_REPO_NAME),
|
||||
}
|
||||
if err := models.PushUpdate(options); err != nil {
|
||||
if err := db.PushUpdate(options); err != nil {
|
||||
log.Error(2, "PushUpdate: %v", err)
|
||||
}
|
||||
|
||||
// Ask for running deliver hook and test pull request tasks
|
||||
reqURL := setting.LocalURL + options.RepoUserName + "/" + options.RepoName + "/tasks/trigger?branch=" +
|
||||
template.EscapePound(strings.TrimPrefix(options.RefFullName, git.BRANCH_PREFIX)) +
|
||||
"&secret=" + os.Getenv(models.ENV_REPO_OWNER_SALT_MD5) +
|
||||
"&pusher=" + os.Getenv(models.ENV_AUTH_USER_ID)
|
||||
"&secret=" + os.Getenv(db.ENV_REPO_OWNER_SALT_MD5) +
|
||||
"&pusher=" + os.Getenv(db.ENV_AUTH_USER_ID)
|
||||
log.Trace("Trigger task: %s", reqURL)
|
||||
|
||||
resp, err := httplib.Head(reqURL).SetTLSClientConfig(&tls.Config{
|
||||
@@ -255,7 +255,7 @@ func runHookPostReceive(c *cli.Context) error {
|
||||
}
|
||||
}
|
||||
|
||||
customHooksPath := filepath.Join(os.Getenv(models.ENV_REPO_CUSTOM_HOOKS_PATH), "post-receive")
|
||||
customHooksPath := filepath.Join(os.Getenv(db.ENV_REPO_CUSTOM_HOOKS_PATH), "post-receive")
|
||||
if !com.IsFile(customHooksPath) {
|
||||
return nil
|
||||
}
|
||||
@@ -266,7 +266,7 @@ func runHookPostReceive(c *cli.Context) error {
|
||||
} else {
|
||||
hookCmd = exec.Command(customHooksPath)
|
||||
}
|
||||
hookCmd.Dir = models.RepoPath(os.Getenv(models.ENV_REPO_OWNER_NAME), os.Getenv(models.ENV_REPO_NAME))
|
||||
hookCmd.Dir = db.RepoPath(os.Getenv(db.ENV_REPO_OWNER_NAME), os.Getenv(db.ENV_REPO_NAME))
|
||||
hookCmd.Stdout = os.Stdout
|
||||
hookCmd.Stdin = buf
|
||||
hookCmd.Stderr = os.Stderr
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
"github.com/unknwon/com"
|
||||
"github.com/urfave/cli"
|
||||
|
||||
"gogs.io/gogs/pkg/setting"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -8,15 +8,15 @@ import (
|
||||
"os"
|
||||
"path"
|
||||
|
||||
"github.com/mcuadros/go-version"
|
||||
"github.com/unknwon/cae/zip"
|
||||
"github.com/unknwon/com"
|
||||
"github.com/mcuadros/go-version"
|
||||
"github.com/urfave/cli"
|
||||
log "gopkg.in/clog.v1"
|
||||
"gopkg.in/ini.v1"
|
||||
|
||||
"gogs.io/gogs/models"
|
||||
"gogs.io/gogs/pkg/setting"
|
||||
"gogs.io/gogs/internal/db"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
)
|
||||
|
||||
var Restore = cli.Command{
|
||||
@@ -91,12 +91,12 @@ func runRestore(c *cli.Context) error {
|
||||
setting.CustomConf = configFile
|
||||
}
|
||||
setting.NewContext()
|
||||
models.LoadConfigs()
|
||||
models.SetEngine()
|
||||
db.LoadConfigs()
|
||||
db.SetEngine()
|
||||
|
||||
// Database
|
||||
dbDir := path.Join(archivePath, "db")
|
||||
if err = models.ImportDatabase(dbDir, c.Bool("verbose")); err != nil {
|
||||
if err = db.ImportDatabase(dbDir, c.Bool("verbose")); err != nil {
|
||||
log.Fatal(0, "Failed to import database: %v", err)
|
||||
}
|
||||
|
||||
@@ -16,9 +16,9 @@ import (
|
||||
"github.com/urfave/cli"
|
||||
log "gopkg.in/clog.v1"
|
||||
|
||||
"gogs.io/gogs/models"
|
||||
"gogs.io/gogs/models/errors"
|
||||
"gogs.io/gogs/pkg/setting"
|
||||
"gogs.io/gogs/internal/db"
|
||||
"gogs.io/gogs/internal/db/errors"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -76,14 +76,14 @@ func setup(c *cli.Context, logPath string, connectDB bool) {
|
||||
return
|
||||
}
|
||||
|
||||
models.LoadConfigs()
|
||||
db.LoadConfigs()
|
||||
|
||||
if setting.UseSQLite3 {
|
||||
workDir, _ := setting.WorkDir()
|
||||
os.Chdir(workDir)
|
||||
}
|
||||
|
||||
if err := models.SetEngine(); err != nil {
|
||||
if err := db.SetEngine(); err != nil {
|
||||
fail("Internal error", "SetEngine: %v", err)
|
||||
}
|
||||
}
|
||||
@@ -96,29 +96,29 @@ func parseSSHCmd(cmd string) (string, string) {
|
||||
return ss[0], strings.Replace(ss[1], "'/", "'", 1)
|
||||
}
|
||||
|
||||
func checkDeployKey(key *models.PublicKey, repo *models.Repository) {
|
||||
func checkDeployKey(key *db.PublicKey, repo *db.Repository) {
|
||||
// Check if this deploy key belongs to current repository.
|
||||
if !models.HasDeployKey(key.ID, repo.ID) {
|
||||
if !db.HasDeployKey(key.ID, repo.ID) {
|
||||
fail("Key access denied", "Deploy key access denied: [key_id: %d, repo_id: %d]", key.ID, repo.ID)
|
||||
}
|
||||
|
||||
// Update deploy key activity.
|
||||
deployKey, err := models.GetDeployKeyByRepo(key.ID, repo.ID)
|
||||
deployKey, err := db.GetDeployKeyByRepo(key.ID, repo.ID)
|
||||
if err != nil {
|
||||
fail("Internal error", "GetDeployKey: %v", err)
|
||||
}
|
||||
|
||||
deployKey.Updated = time.Now()
|
||||
if err = models.UpdateDeployKey(deployKey); err != nil {
|
||||
if err = db.UpdateDeployKey(deployKey); err != nil {
|
||||
fail("Internal error", "UpdateDeployKey: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
var (
|
||||
allowedCommands = map[string]models.AccessMode{
|
||||
"git-upload-pack": models.ACCESS_MODE_READ,
|
||||
"git-upload-archive": models.ACCESS_MODE_READ,
|
||||
"git-receive-pack": models.ACCESS_MODE_WRITE,
|
||||
allowedCommands = map[string]db.AccessMode{
|
||||
"git-upload-pack": db.ACCESS_MODE_READ,
|
||||
"git-upload-archive": db.ACCESS_MODE_READ,
|
||||
"git-receive-pack": db.ACCESS_MODE_WRITE,
|
||||
}
|
||||
)
|
||||
|
||||
@@ -151,7 +151,7 @@ func runServ(c *cli.Context) error {
|
||||
repoName := strings.TrimSuffix(strings.ToLower(repoFields[1]), ".git")
|
||||
repoName = strings.TrimSuffix(repoName, ".wiki")
|
||||
|
||||
owner, err := models.GetUserByName(ownerName)
|
||||
owner, err := db.GetUserByName(ownerName)
|
||||
if err != nil {
|
||||
if errors.IsUserNotExist(err) {
|
||||
fail("Repository owner does not exist", "Unregistered owner: %s", ownerName)
|
||||
@@ -159,7 +159,7 @@ func runServ(c *cli.Context) error {
|
||||
fail("Internal error", "Fail to get repository owner '%s': %v", ownerName, err)
|
||||
}
|
||||
|
||||
repo, err := models.GetRepositoryByName(owner.ID, repoName)
|
||||
repo, err := db.GetRepositoryByName(owner.ID, repoName)
|
||||
if err != nil {
|
||||
if errors.IsRepoNotExist(err) {
|
||||
fail(_ACCESS_DENIED_MESSAGE, "Repository does not exist: %s/%s", owner.Name, repoName)
|
||||
@@ -174,19 +174,19 @@ func runServ(c *cli.Context) error {
|
||||
}
|
||||
|
||||
// Prohibit push to mirror repositories.
|
||||
if requestMode > models.ACCESS_MODE_READ && repo.IsMirror {
|
||||
if requestMode > db.ACCESS_MODE_READ && repo.IsMirror {
|
||||
fail("Mirror repository is read-only", "")
|
||||
}
|
||||
|
||||
// Allow anonymous (user is nil) clone for public repositories.
|
||||
var user *models.User
|
||||
var user *db.User
|
||||
|
||||
key, err := models.GetPublicKeyByID(com.StrTo(strings.TrimPrefix(c.Args()[0], "key-")).MustInt64())
|
||||
key, err := db.GetPublicKeyByID(com.StrTo(strings.TrimPrefix(c.Args()[0], "key-")).MustInt64())
|
||||
if err != nil {
|
||||
fail("Invalid key ID", "Invalid key ID '%s': %v", c.Args()[0], err)
|
||||
}
|
||||
|
||||
if requestMode == models.ACCESS_MODE_WRITE || repo.IsPrivate {
|
||||
if requestMode == db.ACCESS_MODE_WRITE || repo.IsPrivate {
|
||||
// Check deploy key or user key.
|
||||
if key.IsDeployKey() {
|
||||
if key.Mode < requestMode {
|
||||
@@ -194,19 +194,19 @@ func runServ(c *cli.Context) error {
|
||||
}
|
||||
checkDeployKey(key, repo)
|
||||
} else {
|
||||
user, err = models.GetUserByKeyID(key.ID)
|
||||
user, err = db.GetUserByKeyID(key.ID)
|
||||
if err != nil {
|
||||
fail("Internal error", "Fail to get user by key ID '%d': %v", key.ID, err)
|
||||
}
|
||||
|
||||
mode, err := models.UserAccessMode(user.ID, repo)
|
||||
mode, err := db.UserAccessMode(user.ID, repo)
|
||||
if err != nil {
|
||||
fail("Internal error", "Fail to check access: %v", err)
|
||||
}
|
||||
|
||||
if mode < requestMode {
|
||||
clientMessage := _ACCESS_DENIED_MESSAGE
|
||||
if mode >= models.ACCESS_MODE_READ {
|
||||
if mode >= db.ACCESS_MODE_READ {
|
||||
clientMessage = "You do not have sufficient authorization for this action"
|
||||
}
|
||||
fail(clientMessage,
|
||||
@@ -227,13 +227,13 @@ func runServ(c *cli.Context) error {
|
||||
|
||||
// Update user key activity.
|
||||
if key.ID > 0 {
|
||||
key, err := models.GetPublicKeyByID(key.ID)
|
||||
key, err := db.GetPublicKeyByID(key.ID)
|
||||
if err != nil {
|
||||
fail("Internal error", "GetPublicKeyByID: %v", err)
|
||||
}
|
||||
|
||||
key.Updated = time.Now()
|
||||
if err = models.UpdatePublicKey(key); err != nil {
|
||||
if err = db.UpdatePublicKey(key); err != nil {
|
||||
fail("Internal error", "UpdatePublicKey: %v", err)
|
||||
}
|
||||
}
|
||||
@@ -250,8 +250,8 @@ func runServ(c *cli.Context) error {
|
||||
} else {
|
||||
gitCmd = exec.Command(verb, repoFullName)
|
||||
}
|
||||
if requestMode == models.ACCESS_MODE_WRITE {
|
||||
gitCmd.Env = append(os.Environ(), models.ComposeHookEnvs(models.ComposeHookEnvsOptions{
|
||||
if requestMode == db.ACCESS_MODE_WRITE {
|
||||
gitCmd.Env = append(os.Environ(), db.ComposeHookEnvs(db.ComposeHookEnvsOptions{
|
||||
AuthUser: user,
|
||||
OwnerName: owner.Name,
|
||||
OwnerSalt: owner.Salt,
|
||||
@@ -15,7 +15,6 @@ import (
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
"github.com/unknwon/com"
|
||||
"github.com/go-macaron/binding"
|
||||
"github.com/go-macaron/cache"
|
||||
"github.com/go-macaron/captcha"
|
||||
@@ -26,24 +25,25 @@ import (
|
||||
"github.com/go-macaron/toolbox"
|
||||
"github.com/mcuadros/go-version"
|
||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||
"github.com/unknwon/com"
|
||||
"github.com/urfave/cli"
|
||||
log "gopkg.in/clog.v1"
|
||||
"gopkg.in/macaron.v1"
|
||||
|
||||
"gogs.io/gogs/models"
|
||||
"gogs.io/gogs/pkg/bindata"
|
||||
"gogs.io/gogs/pkg/context"
|
||||
"gogs.io/gogs/pkg/form"
|
||||
"gogs.io/gogs/pkg/mailer"
|
||||
"gogs.io/gogs/pkg/setting"
|
||||
"gogs.io/gogs/pkg/template"
|
||||
"gogs.io/gogs/routes"
|
||||
"gogs.io/gogs/routes/admin"
|
||||
apiv1 "gogs.io/gogs/routes/api/v1"
|
||||
"gogs.io/gogs/routes/dev"
|
||||
"gogs.io/gogs/routes/org"
|
||||
"gogs.io/gogs/routes/repo"
|
||||
"gogs.io/gogs/routes/user"
|
||||
"gogs.io/gogs/internal/bindata"
|
||||
"gogs.io/gogs/internal/context"
|
||||
"gogs.io/gogs/internal/db"
|
||||
"gogs.io/gogs/internal/form"
|
||||
"gogs.io/gogs/internal/mailer"
|
||||
"gogs.io/gogs/internal/route"
|
||||
"gogs.io/gogs/internal/route/admin"
|
||||
apiv1 "gogs.io/gogs/internal/route/api/v1"
|
||||
"gogs.io/gogs/internal/route/dev"
|
||||
"gogs.io/gogs/internal/route/org"
|
||||
"gogs.io/gogs/internal/route/repo"
|
||||
"gogs.io/gogs/internal/route/user"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
"gogs.io/gogs/internal/template"
|
||||
)
|
||||
|
||||
var Web = cli.Command{
|
||||
@@ -97,14 +97,14 @@ func newMacaron() *macaron.Macaron {
|
||||
m.Use(macaron.Static(
|
||||
setting.AvatarUploadPath,
|
||||
macaron.StaticOptions{
|
||||
Prefix: models.USER_AVATAR_URL_PREFIX,
|
||||
Prefix: db.USER_AVATAR_URL_PREFIX,
|
||||
SkipLogging: setting.DisableRouterLog,
|
||||
},
|
||||
))
|
||||
m.Use(macaron.Static(
|
||||
setting.RepositoryAvatarUploadPath,
|
||||
macaron.StaticOptions{
|
||||
Prefix: models.REPO_AVATAR_URL_PREFIX,
|
||||
Prefix: db.REPO_AVATAR_URL_PREFIX,
|
||||
SkipLogging: setting.DisableRouterLog,
|
||||
},
|
||||
))
|
||||
@@ -156,7 +156,7 @@ func newMacaron() *macaron.Macaron {
|
||||
HealthCheckFuncs: []*toolbox.HealthCheckFuncDesc{
|
||||
&toolbox.HealthCheckFuncDesc{
|
||||
Desc: "Database connection",
|
||||
Func: models.Ping,
|
||||
Func: db.Ping,
|
||||
},
|
||||
},
|
||||
}))
|
||||
@@ -168,7 +168,7 @@ func runWeb(c *cli.Context) error {
|
||||
if c.IsSet("config") {
|
||||
setting.CustomConf = c.String("config")
|
||||
}
|
||||
routes.GlobalInit()
|
||||
route.GlobalInit()
|
||||
checkVersion()
|
||||
|
||||
m := newMacaron()
|
||||
@@ -182,20 +182,20 @@ func runWeb(c *cli.Context) error {
|
||||
|
||||
m.SetAutoHead(true)
|
||||
|
||||
// FIXME: not all routes need go through same middlewares.
|
||||
// FIXME: not all route need go through same middlewares.
|
||||
// Especially some AJAX requests, we can reduce middleware number to improve performance.
|
||||
// Routers.
|
||||
m.Get("/", ignSignIn, routes.Home)
|
||||
m.Get("/", ignSignIn, route.Home)
|
||||
m.Group("/explore", func() {
|
||||
m.Get("", func(c *context.Context) {
|
||||
c.Redirect(setting.AppSubURL + "/explore/repos")
|
||||
})
|
||||
m.Get("/repos", routes.ExploreRepos)
|
||||
m.Get("/users", routes.ExploreUsers)
|
||||
m.Get("/organizations", routes.ExploreOrganizations)
|
||||
m.Get("/repos", route.ExploreRepos)
|
||||
m.Get("/users", route.ExploreUsers)
|
||||
m.Get("/organizations", route.ExploreOrganizations)
|
||||
}, ignSignIn)
|
||||
m.Combo("/install", routes.InstallInit).Get(routes.Install).
|
||||
Post(bindIgnErr(form.Install{}), routes.InstallPost)
|
||||
m.Combo("/install", route.InstallInit).Get(route.Install).
|
||||
Post(bindIgnErr(form.Install{}), route.InstallPost)
|
||||
m.Get("/^:type(issues|pulls)$", reqSignIn, user.Issues)
|
||||
|
||||
// ***** START: User *****
|
||||
@@ -311,9 +311,9 @@ func runWeb(c *cli.Context) error {
|
||||
}, context.InjectParamsUser())
|
||||
|
||||
m.Get("/attachments/:uuid", func(c *context.Context) {
|
||||
attach, err := models.GetAttachmentByUUID(c.Params(":uuid"))
|
||||
attach, err := db.GetAttachmentByUUID(c.Params(":uuid"))
|
||||
if err != nil {
|
||||
c.NotFoundOrServerError("GetAttachmentByUUID", models.IsErrAttachmentNotExist, err)
|
||||
c.NotFoundOrServerError("GetAttachmentByUUID", db.IsErrAttachmentNotExist, err)
|
||||
return
|
||||
} else if !com.IsFile(attach.LocalPath()) {
|
||||
c.NotFound()
|
||||
@@ -644,7 +644,7 @@ func runWeb(c *cli.Context) error {
|
||||
m.Head("/tasks/trigger", repo.TriggerTask)
|
||||
})
|
||||
// Use the regexp to match the repository name
|
||||
// Duplicated routes to enable different ways of accessing same set of URLs,
|
||||
// Duplicated route to enable different ways of accessing same set of URLs,
|
||||
// e.g. with or without ".git" suffix.
|
||||
m.Group("/:reponame([\\d\\w-_\\.]+\\.git$)", func() {
|
||||
m.Get("", ignSignIn, context.RepoAssignment(), context.RepoRef(), repo.Home)
|
||||
@@ -682,7 +682,7 @@ func runWeb(c *cli.Context) error {
|
||||
})
|
||||
|
||||
// Not found handler.
|
||||
m.NotFound(routes.NotFound)
|
||||
m.NotFound(route.NotFound)
|
||||
|
||||
// Flag for port number in case first time run conflict.
|
||||
if c.IsSet("port") {
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
log "gopkg.in/clog.v1"
|
||||
"gopkg.in/macaron.v1"
|
||||
|
||||
"gogs.io/gogs/pkg/setting"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
)
|
||||
|
||||
type APIContext struct {
|
||||
@@ -5,10 +5,10 @@
|
||||
package context
|
||||
|
||||
import (
|
||||
"gogs.io/gogs/models"
|
||||
"gogs.io/gogs/internal/db"
|
||||
)
|
||||
|
||||
type APIOrganization struct {
|
||||
Organization *models.User
|
||||
Team *models.Team
|
||||
Organization *db.User
|
||||
Team *db.Team
|
||||
}
|
||||
@@ -12,9 +12,9 @@ import (
|
||||
"github.com/go-macaron/csrf"
|
||||
"gopkg.in/macaron.v1"
|
||||
|
||||
"gogs.io/gogs/pkg/auth"
|
||||
"gogs.io/gogs/pkg/setting"
|
||||
"gogs.io/gogs/pkg/tool"
|
||||
"gogs.io/gogs/internal/auth"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
"gogs.io/gogs/internal/tool"
|
||||
)
|
||||
|
||||
type ToggleOptions struct {
|
||||
@@ -12,20 +12,20 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/unknwon/com"
|
||||
"github.com/go-macaron/cache"
|
||||
"github.com/go-macaron/csrf"
|
||||
"github.com/go-macaron/i18n"
|
||||
"github.com/go-macaron/session"
|
||||
"github.com/unknwon/com"
|
||||
log "gopkg.in/clog.v1"
|
||||
"gopkg.in/macaron.v1"
|
||||
|
||||
"gogs.io/gogs/models"
|
||||
"gogs.io/gogs/models/errors"
|
||||
"gogs.io/gogs/pkg/auth"
|
||||
"gogs.io/gogs/pkg/form"
|
||||
"gogs.io/gogs/pkg/setting"
|
||||
"gogs.io/gogs/pkg/template"
|
||||
"gogs.io/gogs/internal/auth"
|
||||
"gogs.io/gogs/internal/db"
|
||||
"gogs.io/gogs/internal/db/errors"
|
||||
"gogs.io/gogs/internal/form"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
"gogs.io/gogs/internal/template"
|
||||
)
|
||||
|
||||
// Context represents context of a request.
|
||||
@@ -37,7 +37,7 @@ type Context struct {
|
||||
Session session.Store
|
||||
|
||||
Link string // Current request URL
|
||||
User *models.User
|
||||
User *db.User
|
||||
IsLogged bool
|
||||
IsBasicAuth bool
|
||||
IsTokenAuth bool
|
||||
@@ -252,13 +252,13 @@ func Contexter() macaron.Handler {
|
||||
repoName := c.Params(":reponame")
|
||||
branchName := "master"
|
||||
|
||||
owner, err := models.GetUserByName(ownerName)
|
||||
owner, err := db.GetUserByName(ownerName)
|
||||
if err != nil {
|
||||
c.NotFoundOrServerError("GetUserByName", errors.IsUserNotExist, err)
|
||||
return
|
||||
}
|
||||
|
||||
repo, err := models.GetRepositoryByName(owner.ID, repoName)
|
||||
repo, err := db.GetRepositoryByName(owner.ID, repoName)
|
||||
if err == nil && len(repo.DefaultBranch) > 0 {
|
||||
branchName = repo.DefaultBranch
|
||||
}
|
||||
@@ -280,7 +280,7 @@ func Contexter() macaron.Handler {
|
||||
</html>
|
||||
`, map[string]string{
|
||||
"GoGetImport": path.Join(setting.HostAddress, setting.AppSubURL, repo.FullName()),
|
||||
"CloneLink": models.ComposeHTTPSCloneURL(ownerName, repoName),
|
||||
"CloneLink": db.ComposeHTTPSCloneURL(ownerName, repoName),
|
||||
"GoDocDirectory": prefix + "{/dir}",
|
||||
"GoDocFile": prefix + "{/dir}/{file}#L{line}",
|
||||
"InsecureFlag": insecureFlag,
|
||||
@@ -11,9 +11,9 @@ import (
|
||||
"github.com/unknwon/com"
|
||||
log "gopkg.in/clog.v1"
|
||||
|
||||
"gogs.io/gogs/pkg/markup"
|
||||
"gogs.io/gogs/pkg/setting"
|
||||
"gogs.io/gogs/pkg/tool"
|
||||
"gogs.io/gogs/internal/markup"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
"gogs.io/gogs/internal/tool"
|
||||
)
|
||||
|
||||
// renderNoticeBanner checks if a notice banner file exists and loads the message to display
|
||||
@@ -9,9 +9,9 @@ import (
|
||||
|
||||
"gopkg.in/macaron.v1"
|
||||
|
||||
"gogs.io/gogs/models"
|
||||
"gogs.io/gogs/models/errors"
|
||||
"gogs.io/gogs/pkg/setting"
|
||||
"gogs.io/gogs/internal/db"
|
||||
"gogs.io/gogs/internal/db/errors"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
)
|
||||
|
||||
type Organization struct {
|
||||
@@ -19,10 +19,10 @@ type Organization struct {
|
||||
IsMember bool
|
||||
IsTeamMember bool // Is member of team.
|
||||
IsTeamAdmin bool // In owner team or team that has admin permission level.
|
||||
Organization *models.User
|
||||
Organization *db.User
|
||||
OrgLink string
|
||||
|
||||
Team *models.Team
|
||||
Team *db.Team
|
||||
}
|
||||
|
||||
func HandleOrgAssignment(c *Context, args ...bool) {
|
||||
@@ -48,7 +48,7 @@ func HandleOrgAssignment(c *Context, args ...bool) {
|
||||
orgName := c.Params(":org")
|
||||
|
||||
var err error
|
||||
c.Org.Organization, err = models.GetUserByName(orgName)
|
||||
c.Org.Organization, err = db.GetUserByName(orgName)
|
||||
if err != nil {
|
||||
c.NotFoundOrServerError("GetUserByName", errors.IsUserNotExist, err)
|
||||
return
|
||||
@@ -81,7 +81,7 @@ func HandleOrgAssignment(c *Context, args ...bool) {
|
||||
}
|
||||
} else {
|
||||
// Fake data.
|
||||
c.Data["SignedUser"] = &models.User{}
|
||||
c.Data["SignedUser"] = &db.User{}
|
||||
}
|
||||
if (requireMember && !c.Org.IsMember) ||
|
||||
(requireOwner && !c.Org.IsOwner) {
|
||||
@@ -134,7 +134,7 @@ func HandleOrgAssignment(c *Context, args ...bool) {
|
||||
return
|
||||
}
|
||||
|
||||
c.Org.IsTeamAdmin = c.Org.Team.IsOwnerTeam() || c.Org.Team.Authorize >= models.ACCESS_MODE_ADMIN
|
||||
c.Org.IsTeamAdmin = c.Org.Team.IsOwnerTeam() || c.Org.Team.Authorize >= db.ACCESS_MODE_ADMIN
|
||||
c.Data["IsTeamAdmin"] = c.Org.IsTeamAdmin
|
||||
if requireTeamAdmin && !c.Org.IsTeamAdmin {
|
||||
c.Handle(404, "OrgAssignment", err)
|
||||
@@ -14,26 +14,26 @@ import (
|
||||
|
||||
"github.com/gogs/git-module"
|
||||
|
||||
"gogs.io/gogs/models"
|
||||
"gogs.io/gogs/models/errors"
|
||||
"gogs.io/gogs/pkg/setting"
|
||||
"gogs.io/gogs/internal/db"
|
||||
"gogs.io/gogs/internal/db/errors"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
)
|
||||
|
||||
type PullRequest struct {
|
||||
BaseRepo *models.Repository
|
||||
BaseRepo *db.Repository
|
||||
Allowed bool
|
||||
SameRepo bool
|
||||
HeadInfo string // [<user>:]<branch>
|
||||
}
|
||||
|
||||
type Repository struct {
|
||||
AccessMode models.AccessMode
|
||||
AccessMode db.AccessMode
|
||||
IsWatching bool
|
||||
IsViewBranch bool
|
||||
IsViewTag bool
|
||||
IsViewCommit bool
|
||||
Repository *models.Repository
|
||||
Owner *models.User
|
||||
Repository *db.Repository
|
||||
Owner *db.User
|
||||
Commit *git.Commit
|
||||
Tag *git.Tag
|
||||
GitRepo *git.Repository
|
||||
@@ -42,31 +42,31 @@ type Repository struct {
|
||||
TreePath string
|
||||
CommitID string
|
||||
RepoLink string
|
||||
CloneLink models.CloneLink
|
||||
CloneLink db.CloneLink
|
||||
CommitsCount int64
|
||||
Mirror *models.Mirror
|
||||
Mirror *db.Mirror
|
||||
|
||||
PullRequest *PullRequest
|
||||
}
|
||||
|
||||
// IsOwner returns true if current user is the owner of repository.
|
||||
func (r *Repository) IsOwner() bool {
|
||||
return r.AccessMode >= models.ACCESS_MODE_OWNER
|
||||
return r.AccessMode >= db.ACCESS_MODE_OWNER
|
||||
}
|
||||
|
||||
// IsAdmin returns true if current user has admin or higher access of repository.
|
||||
func (r *Repository) IsAdmin() bool {
|
||||
return r.AccessMode >= models.ACCESS_MODE_ADMIN
|
||||
return r.AccessMode >= db.ACCESS_MODE_ADMIN
|
||||
}
|
||||
|
||||
// IsWriter returns true if current user has write or higher access of repository.
|
||||
func (r *Repository) IsWriter() bool {
|
||||
return r.AccessMode >= models.ACCESS_MODE_WRITE
|
||||
return r.AccessMode >= db.ACCESS_MODE_WRITE
|
||||
}
|
||||
|
||||
// HasAccess returns true if the current user has at least read access for this repository
|
||||
func (r *Repository) HasAccess() bool {
|
||||
return r.AccessMode >= models.ACCESS_MODE_READ
|
||||
return r.AccessMode >= db.ACCESS_MODE_READ
|
||||
}
|
||||
|
||||
// CanEnableEditor returns true if repository is editable and user has proper access level.
|
||||
@@ -110,7 +110,7 @@ func (r *Repository) PullRequestURL(baseBranch, headBranch string) string {
|
||||
func RepoAssignment(pages ...bool) macaron.Handler {
|
||||
return func(c *Context) {
|
||||
var (
|
||||
owner *models.User
|
||||
owner *db.User
|
||||
err error
|
||||
isIssuesPage bool
|
||||
isWikiPage bool
|
||||
@@ -134,7 +134,7 @@ func RepoAssignment(pages ...bool) macaron.Handler {
|
||||
if c.IsLogged && c.User.LowerName == strings.ToLower(ownerName) {
|
||||
owner = c.User
|
||||
} else {
|
||||
owner, err = models.GetUserByName(ownerName)
|
||||
owner, err = db.GetUserByName(ownerName)
|
||||
if err != nil {
|
||||
c.NotFoundOrServerError("GetUserByName", errors.IsUserNotExist, err)
|
||||
return
|
||||
@@ -143,7 +143,7 @@ func RepoAssignment(pages ...bool) macaron.Handler {
|
||||
c.Repo.Owner = owner
|
||||
c.Data["Username"] = c.Repo.Owner.Name
|
||||
|
||||
repo, err := models.GetRepositoryByName(owner.ID, repoName)
|
||||
repo, err := db.GetRepositoryByName(owner.ID, repoName)
|
||||
if err != nil {
|
||||
c.NotFoundOrServerError("GetRepositoryByName", errors.IsRepoNotExist, err)
|
||||
return
|
||||
@@ -158,9 +158,9 @@ func RepoAssignment(pages ...bool) macaron.Handler {
|
||||
|
||||
// Admin has super access.
|
||||
if c.IsLogged && c.User.IsAdmin {
|
||||
c.Repo.AccessMode = models.ACCESS_MODE_OWNER
|
||||
c.Repo.AccessMode = db.ACCESS_MODE_OWNER
|
||||
} else {
|
||||
mode, err := models.UserAccessMode(c.UserID(), repo)
|
||||
mode, err := db.UserAccessMode(c.UserID(), repo)
|
||||
if err != nil {
|
||||
c.ServerError("UserAccessMode", err)
|
||||
return
|
||||
@@ -169,7 +169,7 @@ func RepoAssignment(pages ...bool) macaron.Handler {
|
||||
}
|
||||
|
||||
// Check access
|
||||
if c.Repo.AccessMode == models.ACCESS_MODE_NONE {
|
||||
if c.Repo.AccessMode == db.ACCESS_MODE_NONE {
|
||||
// Redirect to any accessible page if not yet on it
|
||||
if repo.IsPartialPublic() &&
|
||||
(!(isIssuesPage || isWikiPage) ||
|
||||
@@ -199,7 +199,7 @@ func RepoAssignment(pages ...bool) macaron.Handler {
|
||||
}
|
||||
|
||||
if repo.IsMirror {
|
||||
c.Repo.Mirror, err = models.GetMirrorByRepoID(repo.ID)
|
||||
c.Repo.Mirror, err = db.GetMirrorByRepoID(repo.ID)
|
||||
if err != nil {
|
||||
c.ServerError("GetMirror", err)
|
||||
return
|
||||
@@ -209,7 +209,7 @@ func RepoAssignment(pages ...bool) macaron.Handler {
|
||||
c.Data["Mirror"] = c.Repo.Mirror
|
||||
}
|
||||
|
||||
gitRepo, err := git.OpenRepository(models.RepoPath(ownerName, repoName))
|
||||
gitRepo, err := git.OpenRepository(db.RepoPath(ownerName, repoName))
|
||||
if err != nil {
|
||||
c.ServerError(fmt.Sprintf("RepoAssignment Invalid repo '%s'", c.Repo.Repository.RepoPath()), err)
|
||||
return
|
||||
@@ -237,8 +237,8 @@ func RepoAssignment(pages ...bool) macaron.Handler {
|
||||
c.Data["WikiCloneLink"] = repo.WikiCloneLink()
|
||||
|
||||
if c.IsLogged {
|
||||
c.Data["IsWatchingRepo"] = models.IsWatching(c.User.ID, repo.ID)
|
||||
c.Data["IsStaringRepo"] = models.IsStaring(c.User.ID, repo.ID)
|
||||
c.Data["IsWatchingRepo"] = db.IsWatching(c.User.ID, repo.ID)
|
||||
c.Data["IsStaringRepo"] = db.IsStaring(c.User.ID, repo.ID)
|
||||
}
|
||||
|
||||
// repo is bare and display enable
|
||||
@@ -286,7 +286,7 @@ func RepoRef() macaron.Handler {
|
||||
|
||||
// For API calls.
|
||||
if c.Repo.GitRepo == nil {
|
||||
repoPath := models.RepoPath(c.Repo.Owner.Name, c.Repo.Repository.Name)
|
||||
repoPath := db.RepoPath(c.Repo.Owner.Name, c.Repo.Repository.Name)
|
||||
c.Repo.GitRepo, err = git.OpenRepository(repoPath)
|
||||
if err != nil {
|
||||
c.Handle(500, "RepoRef Invalid repo "+repoPath, err)
|
||||
@@ -7,20 +7,20 @@ package context
|
||||
import (
|
||||
"gopkg.in/macaron.v1"
|
||||
|
||||
"gogs.io/gogs/models"
|
||||
"gogs.io/gogs/models/errors"
|
||||
"gogs.io/gogs/internal/db"
|
||||
"gogs.io/gogs/internal/db/errors"
|
||||
)
|
||||
|
||||
// ParamsUser is the wrapper type of the target user defined by URL parameter, namely ':username'.
|
||||
type ParamsUser struct {
|
||||
*models.User
|
||||
*db.User
|
||||
}
|
||||
|
||||
// InjectParamsUser returns a handler that retrieves target user based on URL parameter ':username',
|
||||
// and injects it as *ParamsUser.
|
||||
func InjectParamsUser() macaron.Handler {
|
||||
return func(c *Context) {
|
||||
user, err := models.GetUserByName(c.Params(":username"))
|
||||
user, err := db.GetUserByName(c.Params(":username"))
|
||||
if err != nil {
|
||||
c.NotFoundOrServerError("GetUserByName", errors.IsUserNotExist, err)
|
||||
return
|
||||
@@ -11,8 +11,8 @@ import (
|
||||
|
||||
"github.com/gogs/cron"
|
||||
|
||||
"gogs.io/gogs/models"
|
||||
"gogs.io/gogs/pkg/setting"
|
||||
"gogs.io/gogs/internal/db"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
)
|
||||
|
||||
var c = cron.New()
|
||||
@@ -23,47 +23,47 @@ func NewContext() {
|
||||
err error
|
||||
)
|
||||
if setting.Cron.UpdateMirror.Enabled {
|
||||
entry, err = c.AddFunc("Update mirrors", setting.Cron.UpdateMirror.Schedule, models.MirrorUpdate)
|
||||
entry, err = c.AddFunc("Update mirrors", setting.Cron.UpdateMirror.Schedule, db.MirrorUpdate)
|
||||
if err != nil {
|
||||
log.Fatal(2, "Cron.(update mirrors): %v", err)
|
||||
}
|
||||
if setting.Cron.UpdateMirror.RunAtStart {
|
||||
entry.Prev = time.Now()
|
||||
entry.ExecTimes++
|
||||
go models.MirrorUpdate()
|
||||
go db.MirrorUpdate()
|
||||
}
|
||||
}
|
||||
if setting.Cron.RepoHealthCheck.Enabled {
|
||||
entry, err = c.AddFunc("Repository health check", setting.Cron.RepoHealthCheck.Schedule, models.GitFsck)
|
||||
entry, err = c.AddFunc("Repository health check", setting.Cron.RepoHealthCheck.Schedule, db.GitFsck)
|
||||
if err != nil {
|
||||
log.Fatal(2, "Cron.(repository health check): %v", err)
|
||||
}
|
||||
if setting.Cron.RepoHealthCheck.RunAtStart {
|
||||
entry.Prev = time.Now()
|
||||
entry.ExecTimes++
|
||||
go models.GitFsck()
|
||||
go db.GitFsck()
|
||||
}
|
||||
}
|
||||
if setting.Cron.CheckRepoStats.Enabled {
|
||||
entry, err = c.AddFunc("Check repository statistics", setting.Cron.CheckRepoStats.Schedule, models.CheckRepoStats)
|
||||
entry, err = c.AddFunc("Check repository statistics", setting.Cron.CheckRepoStats.Schedule, db.CheckRepoStats)
|
||||
if err != nil {
|
||||
log.Fatal(2, "Cron.(check repository statistics): %v", err)
|
||||
}
|
||||
if setting.Cron.CheckRepoStats.RunAtStart {
|
||||
entry.Prev = time.Now()
|
||||
entry.ExecTimes++
|
||||
go models.CheckRepoStats()
|
||||
go db.CheckRepoStats()
|
||||
}
|
||||
}
|
||||
if setting.Cron.RepoArchiveCleanup.Enabled {
|
||||
entry, err = c.AddFunc("Repository archive cleanup", setting.Cron.RepoArchiveCleanup.Schedule, models.DeleteOldRepositoryArchives)
|
||||
entry, err = c.AddFunc("Repository archive cleanup", setting.Cron.RepoArchiveCleanup.Schedule, db.DeleteOldRepositoryArchives)
|
||||
if err != nil {
|
||||
log.Fatal(2, "Cron.(repository archive cleanup): %v", err)
|
||||
}
|
||||
if setting.Cron.RepoArchiveCleanup.RunAtStart {
|
||||
entry.Prev = time.Now()
|
||||
entry.ExecTimes++
|
||||
go models.DeleteOldRepositoryArchives()
|
||||
go db.DeleteOldRepositoryArchives()
|
||||
}
|
||||
}
|
||||
c.Start()
|
||||
@@ -2,14 +2,14 @@
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package models
|
||||
package db
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
log "gopkg.in/clog.v1"
|
||||
|
||||
"gogs.io/gogs/models/errors"
|
||||
"gogs.io/gogs/internal/db/errors"
|
||||
)
|
||||
|
||||
type AccessMode int
|
||||
@@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package models
|
||||
package db
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -12,17 +12,17 @@ import (
|
||||
"time"
|
||||
"unicode"
|
||||
|
||||
"github.com/unknwon/com"
|
||||
"xorm.io/xorm"
|
||||
"github.com/json-iterator/go"
|
||||
"github.com/unknwon/com"
|
||||
log "gopkg.in/clog.v1"
|
||||
"xorm.io/xorm"
|
||||
|
||||
"github.com/gogs/git-module"
|
||||
api "github.com/gogs/go-gogs-client"
|
||||
|
||||
"gogs.io/gogs/models/errors"
|
||||
"gogs.io/gogs/pkg/setting"
|
||||
"gogs.io/gogs/pkg/tool"
|
||||
"gogs.io/gogs/internal/db/errors"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
"gogs.io/gogs/internal/tool"
|
||||
)
|
||||
|
||||
type ActionType int
|
||||
@@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package models
|
||||
package db
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -11,10 +11,10 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/unknwon/com"
|
||||
"xorm.io/xorm"
|
||||
log "gopkg.in/clog.v1"
|
||||
"xorm.io/xorm"
|
||||
|
||||
"gogs.io/gogs/pkg/tool"
|
||||
"gogs.io/gogs/internal/tool"
|
||||
)
|
||||
|
||||
type NoticeType int
|
||||
@@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package models
|
||||
package db
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -12,10 +12,10 @@ import (
|
||||
"path"
|
||||
"time"
|
||||
|
||||
"xorm.io/xorm"
|
||||
gouuid "github.com/satori/go.uuid"
|
||||
"xorm.io/xorm"
|
||||
|
||||
"gogs.io/gogs/pkg/setting"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
)
|
||||
|
||||
// Attachment represent a attachment of issue/comment/release.
|
||||
@@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package models
|
||||
package db
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -10,13 +10,13 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/unknwon/com"
|
||||
"xorm.io/xorm"
|
||||
log "gopkg.in/clog.v1"
|
||||
"xorm.io/xorm"
|
||||
|
||||
api "github.com/gogs/go-gogs-client"
|
||||
|
||||
"gogs.io/gogs/models/errors"
|
||||
"gogs.io/gogs/pkg/markup"
|
||||
"gogs.io/gogs/internal/db/errors"
|
||||
"gogs.io/gogs/internal/markup"
|
||||
)
|
||||
|
||||
// CommentType defines whether a comment is just a simple comment, an action (like close) or a reference.
|
||||
@@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package models
|
||||
package db
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package models
|
||||
package db
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
@@ -17,9 +17,9 @@ import (
|
||||
|
||||
"github.com/gogs/git-module"
|
||||
|
||||
"gogs.io/gogs/pkg/setting"
|
||||
"gogs.io/gogs/pkg/template/highlight"
|
||||
"gogs.io/gogs/pkg/tool"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
"gogs.io/gogs/internal/template/highlight"
|
||||
"gogs.io/gogs/internal/tool"
|
||||
)
|
||||
|
||||
type DiffSection struct {
|
||||
@@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package models
|
||||
package db
|
||||
|
||||
import (
|
||||
"html/template"
|
||||
@@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package models
|
||||
package db
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -10,14 +10,14 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/unknwon/com"
|
||||
"xorm.io/xorm"
|
||||
log "gopkg.in/clog.v1"
|
||||
"xorm.io/xorm"
|
||||
|
||||
api "github.com/gogs/go-gogs-client"
|
||||
|
||||
"gogs.io/gogs/models/errors"
|
||||
"gogs.io/gogs/pkg/setting"
|
||||
"gogs.io/gogs/pkg/tool"
|
||||
"gogs.io/gogs/internal/db/errors"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
"gogs.io/gogs/internal/tool"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package models
|
||||
package db
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
|
||||
api "github.com/gogs/go-gogs-client"
|
||||
|
||||
"gogs.io/gogs/pkg/tool"
|
||||
"gogs.io/gogs/internal/tool"
|
||||
)
|
||||
|
||||
var labelColorPattern = regexp.MustCompile("#([a-fA-F0-9]{6})")
|
||||
@@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package models
|
||||
package db
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -10,9 +10,9 @@ import (
|
||||
"github.com/unknwon/com"
|
||||
log "gopkg.in/clog.v1"
|
||||
|
||||
"gogs.io/gogs/pkg/mailer"
|
||||
"gogs.io/gogs/pkg/markup"
|
||||
"gogs.io/gogs/pkg/setting"
|
||||
"gogs.io/gogs/internal/mailer"
|
||||
"gogs.io/gogs/internal/markup"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
)
|
||||
|
||||
func (issue *Issue) MailSubject() string {
|
||||
@@ -3,7 +3,7 @@
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// FIXME: Put this file into its own package and separate into different files based on login sources.
|
||||
package models
|
||||
package db
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
@@ -24,11 +24,11 @@ import (
|
||||
"xorm.io/core"
|
||||
"xorm.io/xorm"
|
||||
|
||||
"gogs.io/gogs/models/errors"
|
||||
"gogs.io/gogs/pkg/auth/github"
|
||||
"gogs.io/gogs/pkg/auth/ldap"
|
||||
"gogs.io/gogs/pkg/auth/pam"
|
||||
"gogs.io/gogs/pkg/setting"
|
||||
"gogs.io/gogs/internal/auth/github"
|
||||
"gogs.io/gogs/internal/auth/ldap"
|
||||
"gogs.io/gogs/internal/auth/pam"
|
||||
"gogs.io/gogs/internal/db/errors"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
)
|
||||
|
||||
type LoginType int
|
||||
@@ -10,10 +10,10 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/unknwon/com"
|
||||
"xorm.io/xorm"
|
||||
log "gopkg.in/clog.v1"
|
||||
"xorm.io/xorm"
|
||||
|
||||
"gogs.io/gogs/pkg/tool"
|
||||
"gogs.io/gogs/internal/tool"
|
||||
)
|
||||
|
||||
const _MIN_DB_VER = 10
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
"xorm.io/xorm"
|
||||
log "gopkg.in/clog.v1"
|
||||
|
||||
"gogs.io/gogs/pkg/setting"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
)
|
||||
|
||||
func generateAndMigrateGitHooks(x *xorm.Engine) (err error) {
|
||||
@@ -14,7 +14,7 @@ import (
|
||||
|
||||
"github.com/gogs/git-module"
|
||||
|
||||
"gogs.io/gogs/pkg/setting"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
)
|
||||
|
||||
func updateRepositorySizes(x *xorm.Engine) (err error) {
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
|
||||
"xorm.io/xorm"
|
||||
|
||||
"gogs.io/gogs/pkg/setting"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
)
|
||||
|
||||
func updateRepositoryDescriptionField(x *xorm.Engine) error {
|
||||
@@ -2,18 +2,18 @@
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package models
|
||||
package db
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"xorm.io/xorm"
|
||||
log "gopkg.in/clog.v1"
|
||||
"xorm.io/xorm"
|
||||
|
||||
api "github.com/gogs/go-gogs-client"
|
||||
|
||||
"gogs.io/gogs/pkg/setting"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
)
|
||||
|
||||
// Milestone represents a milestone of repository.
|
||||
@@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package models
|
||||
package db
|
||||
|
||||
import (
|
||||
"container/list"
|
||||
@@ -12,16 +12,16 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/unknwon/com"
|
||||
"xorm.io/xorm"
|
||||
log "gopkg.in/clog.v1"
|
||||
"gopkg.in/ini.v1"
|
||||
"xorm.io/xorm"
|
||||
|
||||
"github.com/gogs/git-module"
|
||||
|
||||
"gogs.io/gogs/models/errors"
|
||||
"gogs.io/gogs/pkg/process"
|
||||
"gogs.io/gogs/pkg/setting"
|
||||
"gogs.io/gogs/pkg/sync"
|
||||
"gogs.io/gogs/internal/db/errors"
|
||||
"gogs.io/gogs/internal/process"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
"gogs.io/gogs/internal/sync"
|
||||
)
|
||||
|
||||
var MirrorQueue = sync.NewUniqueQueue(setting.Repository.MirrorQueueLength)
|
||||
@@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package models
|
||||
package db
|
||||
|
||||
import (
|
||||
"testing"
|
||||
@@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package models
|
||||
package db
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
@@ -17,15 +17,15 @@ import (
|
||||
|
||||
_ "github.com/denisenkom/go-mssqldb"
|
||||
_ "github.com/go-sql-driver/mysql"
|
||||
"xorm.io/core"
|
||||
"xorm.io/xorm"
|
||||
"github.com/json-iterator/go"
|
||||
_ "github.com/lib/pq"
|
||||
"github.com/unknwon/com"
|
||||
log "gopkg.in/clog.v1"
|
||||
"xorm.io/core"
|
||||
"xorm.io/xorm"
|
||||
|
||||
"gogs.io/gogs/models/migrations"
|
||||
"gogs.io/gogs/pkg/setting"
|
||||
"gogs.io/gogs/internal/db/migrations"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
)
|
||||
|
||||
// Engine represents a XORM engine or session.
|
||||
@@ -283,7 +283,7 @@ func DumpDatabase(dirPath string) (err error) {
|
||||
// Purposely create a local variable to not modify global variable
|
||||
tables := append(tables, new(Version))
|
||||
for _, table := range tables {
|
||||
tableName := strings.TrimPrefix(fmt.Sprintf("%T", table), "*models.")
|
||||
tableName := strings.TrimPrefix(fmt.Sprintf("%T", table), "*db.")
|
||||
tableFile := path.Join(dirPath, tableName+".json")
|
||||
f, err := os.Create(tableFile)
|
||||
if err != nil {
|
||||
@@ -313,7 +313,7 @@ func ImportDatabase(dirPath string, verbose bool) (err error) {
|
||||
// Purposely create a local variable to not modify global variable
|
||||
tables := append(tables, new(Version))
|
||||
for _, table := range tables {
|
||||
tableName := strings.TrimPrefix(fmt.Sprintf("%T", table), "*models.")
|
||||
tableName := strings.TrimPrefix(fmt.Sprintf("%T", table), "*db.")
|
||||
tableFile := path.Join(dirPath, tableName+".json")
|
||||
if !com.IsExist(tableFile) {
|
||||
continue
|
||||
@@ -4,7 +4,7 @@
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package models
|
||||
package db
|
||||
|
||||
import (
|
||||
_ "github.com/mattn/go-sqlite3"
|
||||
@@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package models
|
||||
package db
|
||||
|
||||
import (
|
||||
"testing"
|
||||
@@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package models
|
||||
package db
|
||||
|
||||
import (
|
||||
"errors"
|
||||
@@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package models
|
||||
package db
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
|
||||
"xorm.io/xorm"
|
||||
|
||||
"gogs.io/gogs/models/errors"
|
||||
"gogs.io/gogs/internal/db/errors"
|
||||
)
|
||||
|
||||
const OWNER_TEAM = "Owners"
|
||||
@@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package models
|
||||
package db
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -12,16 +12,16 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/unknwon/com"
|
||||
"xorm.io/xorm"
|
||||
log "gopkg.in/clog.v1"
|
||||
"xorm.io/xorm"
|
||||
|
||||
"github.com/gogs/git-module"
|
||||
api "github.com/gogs/go-gogs-client"
|
||||
|
||||
"gogs.io/gogs/models/errors"
|
||||
"gogs.io/gogs/pkg/process"
|
||||
"gogs.io/gogs/pkg/setting"
|
||||
"gogs.io/gogs/pkg/sync"
|
||||
"gogs.io/gogs/internal/db/errors"
|
||||
"gogs.io/gogs/internal/process"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
"gogs.io/gogs/internal/sync"
|
||||
)
|
||||
|
||||
var PullRequestQueue = sync.NewUniqueQueue(setting.Repository.PullRequestQueueLength)
|
||||
@@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package models
|
||||
package db
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -10,14 +10,14 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"xorm.io/xorm"
|
||||
log "gopkg.in/clog.v1"
|
||||
"xorm.io/xorm"
|
||||
|
||||
"github.com/gogs/git-module"
|
||||
api "github.com/gogs/go-gogs-client"
|
||||
|
||||
"gogs.io/gogs/models/errors"
|
||||
"gogs.io/gogs/pkg/process"
|
||||
"gogs.io/gogs/internal/db/errors"
|
||||
"gogs.io/gogs/internal/process"
|
||||
)
|
||||
|
||||
// Release represents a release of repository.
|
||||
@@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package models
|
||||
package db
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
@@ -19,24 +19,24 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/unknwon/cae/zip"
|
||||
"github.com/unknwon/com"
|
||||
"xorm.io/xorm"
|
||||
"github.com/mcuadros/go-version"
|
||||
"github.com/nfnt/resize"
|
||||
"github.com/unknwon/cae/zip"
|
||||
"github.com/unknwon/com"
|
||||
log "gopkg.in/clog.v1"
|
||||
"gopkg.in/ini.v1"
|
||||
"xorm.io/xorm"
|
||||
|
||||
git "github.com/gogs/git-module"
|
||||
"github.com/gogs/git-module"
|
||||
api "github.com/gogs/go-gogs-client"
|
||||
|
||||
"gogs.io/gogs/models/errors"
|
||||
"gogs.io/gogs/pkg/avatar"
|
||||
"gogs.io/gogs/pkg/bindata"
|
||||
"gogs.io/gogs/pkg/markup"
|
||||
"gogs.io/gogs/pkg/process"
|
||||
"gogs.io/gogs/pkg/setting"
|
||||
"gogs.io/gogs/pkg/sync"
|
||||
"gogs.io/gogs/internal/avatar"
|
||||
"gogs.io/gogs/internal/bindata"
|
||||
"gogs.io/gogs/internal/db/errors"
|
||||
"gogs.io/gogs/internal/markup"
|
||||
"gogs.io/gogs/internal/process"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
"gogs.io/gogs/internal/sync"
|
||||
)
|
||||
|
||||
// REPO_AVATAR_URL_PREFIX is used to identify a URL is to access repository avatar.
|
||||
@@ -219,7 +219,7 @@ func (repo *Repository) BeforeUpdate() {
|
||||
func (repo *Repository) AfterSet(colName string, _ xorm.Cell) {
|
||||
switch colName {
|
||||
case "default_branch":
|
||||
// FIXME: use models migration to solve all at once.
|
||||
// FIXME: use db migration to solve all at once.
|
||||
if len(repo.DefaultBranch) == 0 {
|
||||
repo.DefaultBranch = "master"
|
||||
}
|
||||
@@ -2,17 +2,17 @@
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package models
|
||||
package db
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/unknwon/com"
|
||||
"github.com/gogs/git-module"
|
||||
"github.com/unknwon/com"
|
||||
|
||||
"gogs.io/gogs/models/errors"
|
||||
"gogs.io/gogs/pkg/tool"
|
||||
"gogs.io/gogs/internal/db/errors"
|
||||
"gogs.io/gogs/internal/tool"
|
||||
)
|
||||
|
||||
type Branch struct {
|
||||
@@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package models
|
||||
package db
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package models
|
||||
package db
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -16,15 +16,15 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/unknwon/com"
|
||||
gouuid "github.com/satori/go.uuid"
|
||||
"github.com/unknwon/com"
|
||||
|
||||
"github.com/gogs/git-module"
|
||||
|
||||
"gogs.io/gogs/models/errors"
|
||||
"gogs.io/gogs/pkg/process"
|
||||
"gogs.io/gogs/pkg/setting"
|
||||
"gogs.io/gogs/pkg/tool"
|
||||
"gogs.io/gogs/internal/db/errors"
|
||||
"gogs.io/gogs/internal/process"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
"gogs.io/gogs/internal/tool"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package models
|
||||
package db
|
||||
|
||||
import (
|
||||
"os"
|
||||
@@ -1,19 +1,19 @@
|
||||
package models_test
|
||||
package db_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
. "github.com/smartystreets/goconvey/convey"
|
||||
|
||||
. "gogs.io/gogs/models"
|
||||
"gogs.io/gogs/pkg/markup"
|
||||
"gogs.io/gogs/internal/db"
|
||||
"gogs.io/gogs/internal/markup"
|
||||
)
|
||||
|
||||
func TestRepo(t *testing.T) {
|
||||
Convey("The metas map", t, func() {
|
||||
var repo = new(Repository)
|
||||
var repo = new(db.Repository)
|
||||
repo.Name = "testrepo"
|
||||
repo.Owner = new(User)
|
||||
repo.Owner = new(db.User)
|
||||
repo.Owner.Name = "testuser"
|
||||
repo.ExternalTrackerFormat = "https://someurl.com/{user}/{repo}/{issue}"
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package models
|
||||
package db
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
@@ -19,12 +19,12 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/unknwon/com"
|
||||
"xorm.io/xorm"
|
||||
"golang.org/x/crypto/ssh"
|
||||
log "gopkg.in/clog.v1"
|
||||
"xorm.io/xorm"
|
||||
|
||||
"gogs.io/gogs/pkg/process"
|
||||
"gogs.io/gogs/pkg/setting"
|
||||
"gogs.io/gogs/internal/process"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package models
|
||||
package db
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
|
||||
. "github.com/smartystreets/goconvey/convey"
|
||||
|
||||
"gogs.io/gogs/pkg/setting"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
)
|
||||
|
||||
func init() {
|
||||
@@ -2,15 +2,16 @@
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package models
|
||||
package db
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"xorm.io/xorm"
|
||||
"gogs.io/gogs/models/errors"
|
||||
"gogs.io/gogs/pkg/tool"
|
||||
gouuid "github.com/satori/go.uuid"
|
||||
"xorm.io/xorm"
|
||||
|
||||
"gogs.io/gogs/internal/db/errors"
|
||||
"gogs.io/gogs/internal/tool"
|
||||
)
|
||||
|
||||
// AccessToken represents a personal access token.
|
||||
@@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package models
|
||||
package db
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
@@ -10,14 +10,14 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/unknwon/com"
|
||||
"xorm.io/xorm"
|
||||
"github.com/pquerna/otp/totp"
|
||||
"github.com/unknwon/com"
|
||||
log "gopkg.in/clog.v1"
|
||||
"xorm.io/xorm"
|
||||
|
||||
"gogs.io/gogs/models/errors"
|
||||
"gogs.io/gogs/pkg/setting"
|
||||
"gogs.io/gogs/pkg/tool"
|
||||
"gogs.io/gogs/internal/db/errors"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
"gogs.io/gogs/internal/tool"
|
||||
)
|
||||
|
||||
// TwoFactor represents a two-factor authentication token.
|
||||
@@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package models
|
||||
package db
|
||||
|
||||
import (
|
||||
"container/list"
|
||||
@@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package models
|
||||
package db
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
@@ -20,19 +20,19 @@ import (
|
||||
"time"
|
||||
"unicode/utf8"
|
||||
|
||||
"github.com/unknwon/com"
|
||||
"xorm.io/xorm"
|
||||
"github.com/nfnt/resize"
|
||||
"github.com/unknwon/com"
|
||||
"golang.org/x/crypto/pbkdf2"
|
||||
log "gopkg.in/clog.v1"
|
||||
"xorm.io/xorm"
|
||||
|
||||
"github.com/gogs/git-module"
|
||||
api "github.com/gogs/go-gogs-client"
|
||||
|
||||
"gogs.io/gogs/models/errors"
|
||||
"gogs.io/gogs/pkg/avatar"
|
||||
"gogs.io/gogs/pkg/setting"
|
||||
"gogs.io/gogs/pkg/tool"
|
||||
"gogs.io/gogs/internal/avatar"
|
||||
"gogs.io/gogs/internal/db/errors"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
"gogs.io/gogs/internal/tool"
|
||||
)
|
||||
|
||||
// USER_AVATAR_URL_PREFIX is used to identify a URL is to access user avatar.
|
||||
@@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package models
|
||||
package db
|
||||
|
||||
// MailResendCacheKey returns key used for cache mail resend.
|
||||
func (u *User) MailResendCacheKey() string {
|
||||
@@ -2,13 +2,13 @@
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package models
|
||||
package db
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"gogs.io/gogs/models/errors"
|
||||
"gogs.io/gogs/internal/db/errors"
|
||||
)
|
||||
|
||||
// EmailAdresses is the list of all email addresses of a user. Can contain the
|
||||
@@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package models
|
||||
package db
|
||||
|
||||
import (
|
||||
"crypto/hmac"
|
||||
@@ -14,17 +14,17 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"xorm.io/xorm"
|
||||
"github.com/json-iterator/go"
|
||||
gouuid "github.com/satori/go.uuid"
|
||||
log "gopkg.in/clog.v1"
|
||||
"xorm.io/xorm"
|
||||
|
||||
api "github.com/gogs/go-gogs-client"
|
||||
|
||||
"gogs.io/gogs/models/errors"
|
||||
"gogs.io/gogs/pkg/httplib"
|
||||
"gogs.io/gogs/pkg/setting"
|
||||
"gogs.io/gogs/pkg/sync"
|
||||
"gogs.io/gogs/internal/db/errors"
|
||||
"gogs.io/gogs/internal/httplib"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
"gogs.io/gogs/internal/sync"
|
||||
)
|
||||
|
||||
var HookQueue = sync.NewUniqueQueue(setting.Webhook.QueueLength)
|
||||
@@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package models
|
||||
package db
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package models
|
||||
package db
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -14,7 +14,7 @@ import (
|
||||
"github.com/gogs/git-module"
|
||||
api "github.com/gogs/go-gogs-client"
|
||||
|
||||
"gogs.io/gogs/pkg/setting"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
)
|
||||
|
||||
type DiscordEmbedFooterObject struct {
|
||||
@@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package models
|
||||
package db
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
"github.com/gogs/git-module"
|
||||
api "github.com/gogs/go-gogs-client"
|
||||
|
||||
"gogs.io/gogs/pkg/setting"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
)
|
||||
|
||||
type SlackMeta struct {
|
||||
@@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package models
|
||||
package db
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -17,8 +17,8 @@ import (
|
||||
|
||||
"github.com/gogs/git-module"
|
||||
|
||||
"gogs.io/gogs/pkg/setting"
|
||||
"gogs.io/gogs/pkg/sync"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
"gogs.io/gogs/internal/sync"
|
||||
)
|
||||
|
||||
var wikiWorkingPool = sync.NewExclusivePool()
|
||||
@@ -8,11 +8,11 @@ import (
|
||||
"net/url"
|
||||
"strings"
|
||||
|
||||
"github.com/unknwon/com"
|
||||
"github.com/go-macaron/binding"
|
||||
"github.com/unknwon/com"
|
||||
"gopkg.in/macaron.v1"
|
||||
|
||||
"gogs.io/gogs/models"
|
||||
"gogs.io/gogs/internal/db"
|
||||
)
|
||||
|
||||
// _______________________________________ _________.______________________ _______________.___.
|
||||
@@ -56,7 +56,7 @@ func (f *MigrateRepo) Validate(ctx *macaron.Context, errs binding.Errors) bindin
|
||||
// and returns composed URL with needed username and password.
|
||||
// It also checks if given user has permission when remote address
|
||||
// is actually a local path.
|
||||
func (f MigrateRepo) ParseRemoteAddr(user *models.User) (string, error) {
|
||||
func (f MigrateRepo) ParseRemoteAddr(user *db.User) (string, error) {
|
||||
remoteAddr := strings.TrimSpace(f.CloneAddr)
|
||||
|
||||
// Remote address can be HTTP/HTTPS/Git URL or local path.
|
||||
@@ -65,16 +65,16 @@ func (f MigrateRepo) ParseRemoteAddr(user *models.User) (string, error) {
|
||||
strings.HasPrefix(remoteAddr, "git://") {
|
||||
u, err := url.Parse(remoteAddr)
|
||||
if err != nil {
|
||||
return "", models.ErrInvalidCloneAddr{IsURLError: true}
|
||||
return "", db.ErrInvalidCloneAddr{IsURLError: true}
|
||||
}
|
||||
if len(f.AuthUsername)+len(f.AuthPassword) > 0 {
|
||||
u.User = url.UserPassword(f.AuthUsername, f.AuthPassword)
|
||||
}
|
||||
remoteAddr = u.String()
|
||||
} else if !user.CanImportLocal() {
|
||||
return "", models.ErrInvalidCloneAddr{IsPermissionDenied: true}
|
||||
return "", db.ErrInvalidCloneAddr{IsPermissionDenied: true}
|
||||
} else if !com.IsDir(remoteAddr) {
|
||||
return "", models.ErrInvalidCloneAddr{IsInvalidPath: true}
|
||||
return "", db.ErrInvalidCloneAddr{IsInvalidPath: true}
|
||||
}
|
||||
|
||||
return remoteAddr, nil
|
||||
@@ -12,8 +12,8 @@ import (
|
||||
"gopkg.in/gomail.v2"
|
||||
"gopkg.in/macaron.v1"
|
||||
|
||||
"gogs.io/gogs/pkg/markup"
|
||||
"gogs.io/gogs/pkg/setting"
|
||||
"gogs.io/gogs/internal/markup"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -18,7 +18,7 @@ import (
|
||||
log "gopkg.in/clog.v1"
|
||||
"gopkg.in/gomail.v2"
|
||||
|
||||
"gogs.io/gogs/pkg/setting"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
)
|
||||
|
||||
type Message struct {
|
||||
@@ -52,7 +52,7 @@ func NewMessageFrom(to []string, from, subject, htmlBody string) *Message {
|
||||
}
|
||||
msg.SetBody(contentType, body)
|
||||
if switchedToPlaintext && setting.MailService.AddPlainTextAlt && !setting.MailService.UsePlainText {
|
||||
// The AddAlternative method name is confusing - adding html as an "alternative" will actually cause mail
|
||||
// The AddAlternative method name is confusing - adding html as an "alternative" will actually cause mail
|
||||
// clients to show it as first priority, and the text "main body" is the 2nd priority fallback.
|
||||
// See: https://godoc.org/gopkg.in/gomail.v2#Message.AddAlternative
|
||||
msg.AddAlternative("text/html", htmlBody)
|
||||
@@ -14,8 +14,8 @@ import (
|
||||
|
||||
"github.com/russross/blackfriday"
|
||||
|
||||
"gogs.io/gogs/pkg/setting"
|
||||
"gogs.io/gogs/pkg/tool"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
"gogs.io/gogs/internal/tool"
|
||||
)
|
||||
|
||||
// IsMarkdownFile reports whether name looks like a Markdown file based on its extension.
|
||||
@@ -12,8 +12,8 @@ import (
|
||||
"github.com/russross/blackfriday"
|
||||
. "github.com/smartystreets/goconvey/convey"
|
||||
|
||||
. "gogs.io/gogs/pkg/markup"
|
||||
"gogs.io/gogs/pkg/setting"
|
||||
. "gogs.io/gogs/internal/markup"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
)
|
||||
|
||||
func Test_IsMarkdownFile(t *testing.T) {
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user