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:
Unknwon
2019-10-24 01:51:46 -07:00
committed by GitHub
parent 613139e7be
commit 01c8df01ec
178 changed files with 1609 additions and 1608 deletions

View File

@@ -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 "gogs.io/gogs/internal/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.BuildGitHash=$(shell git rev-parse HEAD)"
DATA_FILES := $(shell find conf | sed 's/ /\\ /g') DATA_FILES := $(shell find conf | sed 's/ /\\ /g')
LESS_FILES := $(wildcard public/less/gogs.less public/less/_*.less) 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) OS := $(shell uname)
@@ -51,9 +51,9 @@ pack:
release: build 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/... go-bindata -o=$@ -ignore="\\.DS_Store|README.md|TRANSLATORS|auth.d" -pkg=bindata conf/...
less: public/css/gogs.css less: public/css/gogs.css

View File

@@ -12,11 +12,11 @@ import (
"github.com/urfave/cli" "github.com/urfave/cli"
"gogs.io/gogs/cmd" "gogs.io/gogs/internal/cmd"
"gogs.io/gogs/pkg/setting" "gogs.io/gogs/internal/setting"
) )
const Version = "0.11.95.1023" const Version = "0.11.95.1024"
func init() { func init() {
setting.AppVer = Version setting.AppVer = Version

View File

@@ -13,10 +13,10 @@ import (
log "gopkg.in/clog.v1" log "gopkg.in/clog.v1"
"gopkg.in/macaron.v1" "gopkg.in/macaron.v1"
"gogs.io/gogs/models" "gogs.io/gogs/internal/db"
"gogs.io/gogs/models/errors" "gogs.io/gogs/internal/db/errors"
"gogs.io/gogs/pkg/setting" "gogs.io/gogs/internal/setting"
"gogs.io/gogs/pkg/tool" "gogs.io/gogs/internal/tool"
) )
func IsAPIPath(url string) bool { 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 // SignedInID returns the id of signed in user, along with one bool value which indicates whether user uses token
// authentication. // authentication.
func SignedInID(c *macaron.Context, sess session.Store) (_ int64, isTokenAuth bool) { func SignedInID(c *macaron.Context, sess session.Store) (_ int64, isTokenAuth bool) {
if !models.HasEngine { if !db.HasEngine {
return 0, false 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. // Let's see if token is valid.
if len(tokenSHA) > 0 { if len(tokenSHA) > 0 {
t, err := models.GetAccessTokenBySHA(tokenSHA) t, err := db.GetAccessTokenBySHA(tokenSHA)
if err != nil { if err != nil {
if !models.IsErrAccessTokenNotExist(err) && !models.IsErrAccessTokenEmpty(err) { if !db.IsErrAccessTokenNotExist(err) && !db.IsErrAccessTokenEmpty(err) {
log.Error(2, "GetAccessTokenBySHA: %v", err) log.Error(2, "GetAccessTokenBySHA: %v", err)
} }
return 0, false return 0, false
} }
t.Updated = time.Now() t.Updated = time.Now()
if err = models.UpdateAccessToken(t); err != nil { if err = db.UpdateAccessToken(t); err != nil {
log.Error(2, "UpdateAccessToken: %v", err) log.Error(2, "UpdateAccessToken: %v", err)
} }
return t.UID, true return t.UID, true
@@ -69,7 +69,7 @@ func SignedInID(c *macaron.Context, sess session.Store) (_ int64, isTokenAuth bo
return 0, false return 0, false
} }
if id, ok := uid.(int64); ok { if id, ok := uid.(int64); ok {
if _, err := models.GetUserByID(id); err != nil { if _, err := db.GetUserByID(id); err != nil {
if !errors.IsUserNotExist(err) { if !errors.IsUserNotExist(err) {
log.Error(2, "GetUserByID: %v", 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, // 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. // 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) { func SignedInUser(ctx *macaron.Context, sess session.Store) (_ *db.User, isBasicAuth bool, isTokenAuth bool) {
if !models.HasEngine { if !db.HasEngine {
return nil, false, false return nil, false, false
} }
@@ -93,7 +93,7 @@ func SignedInUser(ctx *macaron.Context, sess session.Store) (_ *models.User, isB
if setting.Service.EnableReverseProxyAuth { if setting.Service.EnableReverseProxyAuth {
webAuthUser := ctx.Req.Header.Get(setting.ReverseProxyAuthUser) webAuthUser := ctx.Req.Header.Get(setting.ReverseProxyAuthUser)
if len(webAuthUser) > 0 { if len(webAuthUser) > 0 {
u, err := models.GetUserByName(webAuthUser) u, err := db.GetUserByName(webAuthUser)
if err != nil { if err != nil {
if !errors.IsUserNotExist(err) { if !errors.IsUserNotExist(err) {
log.Error(2, "GetUserByName: %v", 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. // Check if enabled auto-registration.
if setting.Service.EnableReverseProxyAutoRegister { if setting.Service.EnableReverseProxyAutoRegister {
u := &models.User{ u := &db.User{
Name: webAuthUser, Name: webAuthUser,
Email: gouuid.NewV4().String() + "@localhost", Email: gouuid.NewV4().String() + "@localhost",
Passwd: webAuthUser, Passwd: webAuthUser,
IsActive: true, IsActive: true,
} }
if err = models.CreateUser(u); err != nil { if err = db.CreateUser(u); err != nil {
// FIXME: should I create a system notice? // FIXME: should I create a system notice?
log.Error(2, "CreateUser: %v", err) log.Error(2, "CreateUser: %v", err)
return nil, false, false 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" { if len(auths) == 2 && auths[0] == "Basic" {
uname, passwd, _ := tool.BasicAuthDecode(auths[1]) uname, passwd, _ := tool.BasicAuthDecode(auths[1])
u, err := models.UserLogin(uname, passwd, -1) u, err := db.UserLogin(uname, passwd, -1)
if err != nil { if err != nil {
if !errors.IsUserNotExist(err) { if !errors.IsUserNotExist(err) {
log.Error(2, "UserLogin: %v", 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 return nil, false, false
} }
u, err := models.GetUserByID(uid) u, err := db.GetUserByID(uid)
if err != nil { if err != nil {
log.Error(2, "GetUserByID: %v", err) log.Error(2, "GetUserByID: %v", err)
return nil, false, false return nil, false, false

View File

@@ -11,8 +11,8 @@ import (
"github.com/urfave/cli" "github.com/urfave/cli"
"gogs.io/gogs/models" "gogs.io/gogs/internal/db"
"gogs.io/gogs/pkg/setting" "gogs.io/gogs/internal/setting"
) )
var ( var (
@@ -50,7 +50,7 @@ to make automatic initialization process more smoothly`,
Name: "delete-inactive-users", Name: "delete-inactive-users",
Usage: "Delete all inactive accounts", Usage: "Delete all inactive accounts",
Action: adminDashboardOperation( Action: adminDashboardOperation(
models.DeleteInactivateUsers, db.DeleteInactivateUsers,
"All inactivate accounts have been deleted successfully", "All inactivate accounts have been deleted successfully",
), ),
Flags: []cli.Flag{ Flags: []cli.Flag{
@@ -62,7 +62,7 @@ to make automatic initialization process more smoothly`,
Name: "delete-repository-archives", Name: "delete-repository-archives",
Usage: "Delete all repositories archives", Usage: "Delete all repositories archives",
Action: adminDashboardOperation( Action: adminDashboardOperation(
models.DeleteRepositoryArchives, db.DeleteRepositoryArchives,
"All repositories archives have been deleted successfully", "All repositories archives have been deleted successfully",
), ),
Flags: []cli.Flag{ Flags: []cli.Flag{
@@ -74,7 +74,7 @@ to make automatic initialization process more smoothly`,
Name: "delete-missing-repositories", Name: "delete-missing-repositories",
Usage: "Delete all repository records that lost Git files", Usage: "Delete all repository records that lost Git files",
Action: adminDashboardOperation( Action: adminDashboardOperation(
models.DeleteMissingRepositories, db.DeleteMissingRepositories,
"All repositories archives have been deleted successfully", "All repositories archives have been deleted successfully",
), ),
Flags: []cli.Flag{ Flags: []cli.Flag{
@@ -86,7 +86,7 @@ to make automatic initialization process more smoothly`,
Name: "collect-garbage", Name: "collect-garbage",
Usage: "Do garbage collection on repositories", Usage: "Do garbage collection on repositories",
Action: adminDashboardOperation( Action: adminDashboardOperation(
models.GitGcRepos, db.GitGcRepos,
"All repositories have done garbage collection successfully", "All repositories have done garbage collection successfully",
), ),
Flags: []cli.Flag{ Flags: []cli.Flag{
@@ -98,7 +98,7 @@ to make automatic initialization process more smoothly`,
Name: "rewrite-authorized-keys", Name: "rewrite-authorized-keys",
Usage: "Rewrite '.ssh/authorized_keys' file (caution: non-Gogs keys will be lost)", Usage: "Rewrite '.ssh/authorized_keys' file (caution: non-Gogs keys will be lost)",
Action: adminDashboardOperation( Action: adminDashboardOperation(
models.RewriteAuthorizedKeys, db.RewriteAuthorizedKeys,
"All public keys have been rewritten successfully", "All public keys have been rewritten successfully",
), ),
Flags: []cli.Flag{ Flags: []cli.Flag{
@@ -110,7 +110,7 @@ to make automatic initialization process more smoothly`,
Name: "resync-hooks", Name: "resync-hooks",
Usage: "Resync pre-receive, update and post-receive hooks", Usage: "Resync pre-receive, update and post-receive hooks",
Action: adminDashboardOperation( Action: adminDashboardOperation(
models.SyncRepositoryHooks, db.SyncRepositoryHooks,
"All repositories' pre-receive, update and post-receive hooks have been resynced successfully", "All repositories' pre-receive, update and post-receive hooks have been resynced successfully",
), ),
Flags: []cli.Flag{ Flags: []cli.Flag{
@@ -122,7 +122,7 @@ to make automatic initialization process more smoothly`,
Name: "reinit-missing-repositories", Name: "reinit-missing-repositories",
Usage: "Reinitialize all repository records that lost Git files", Usage: "Reinitialize all repository records that lost Git files",
Action: adminDashboardOperation( Action: adminDashboardOperation(
models.ReinitMissingRepositories, db.ReinitMissingRepositories,
"All repository records that lost Git files have been reinitialized successfully", "All repository records that lost Git files have been reinitialized successfully",
), ),
Flags: []cli.Flag{ Flags: []cli.Flag{
@@ -145,10 +145,10 @@ func runCreateUser(c *cli.Context) error {
} }
setting.NewContext() setting.NewContext()
models.LoadConfigs() db.LoadConfigs()
models.SetEngine() db.SetEngine()
if err := models.CreateUser(&models.User{ if err := db.CreateUser(&db.User{
Name: c.String("name"), Name: c.String("name"),
Email: c.String("email"), Email: c.String("email"),
Passwd: c.String("password"), Passwd: c.String("password"),
@@ -169,8 +169,8 @@ func adminDashboardOperation(operation func() error, successMessage string) func
} }
setting.NewContext() setting.NewContext()
models.LoadConfigs() db.LoadConfigs()
models.SetEngine() db.SetEngine()
if err := operation(); err != nil { if err := operation(); err != nil {
functionName := runtime.FuncForPC(reflect.ValueOf(operation).Pointer()).Name() functionName := runtime.FuncForPC(reflect.ValueOf(operation).Pointer()).Name()

View File

@@ -17,8 +17,8 @@ import (
log "gopkg.in/clog.v1" log "gopkg.in/clog.v1"
"gopkg.in/ini.v1" "gopkg.in/ini.v1"
"gogs.io/gogs/models" "gogs.io/gogs/internal/db"
"gogs.io/gogs/pkg/setting" "gogs.io/gogs/internal/setting"
) )
var Backup = cli.Command{ var Backup = cli.Command{
@@ -48,8 +48,8 @@ func runBackup(c *cli.Context) error {
setting.CustomConf = c.String("config") setting.CustomConf = c.String("config")
} }
setting.NewContext() setting.NewContext()
models.LoadConfigs() db.LoadConfigs()
models.SetEngine() db.SetEngine()
tmpDir := c.String("tempdir") tmpDir := c.String("tempdir")
if !com.IsExist(tmpDir) { if !com.IsExist(tmpDir) {
@@ -84,7 +84,7 @@ func runBackup(c *cli.Context) error {
// Database // Database
dbDir := path.Join(rootDir, "db") 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) log.Fatal(0, "Fail to dump database: %v", err)
} }
if err = z.AddDir(_ARCHIVE_ROOT_DIR+"/db", dbDir); err != nil { if err = z.AddDir(_ARCHIVE_ROOT_DIR+"/db", dbDir); err != nil {

View File

@@ -21,12 +21,12 @@ import (
"github.com/gogs/git-module" "github.com/gogs/git-module"
"gogs.io/gogs/models" "gogs.io/gogs/internal/db"
"gogs.io/gogs/models/errors" "gogs.io/gogs/internal/db/errors"
"gogs.io/gogs/pkg/httplib" "gogs.io/gogs/internal/httplib"
"gogs.io/gogs/pkg/mailer" "gogs.io/gogs/internal/mailer"
"gogs.io/gogs/pkg/setting" "gogs.io/gogs/internal/setting"
"gogs.io/gogs/pkg/template" "gogs.io/gogs/internal/template"
) )
var ( var (
@@ -70,7 +70,7 @@ func runHookPreReceive(c *cli.Context) error {
} }
setup(c, "hooks/pre-receive.log", true) 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) buf := bytes.NewBuffer(nil)
scanner := bufio.NewScanner(os.Stdin) scanner := bufio.NewScanner(os.Stdin)
@@ -91,8 +91,8 @@ func runHookPreReceive(c *cli.Context) error {
branchName := strings.TrimPrefix(string(fields[2]), git.BRANCH_PREFIX) branchName := strings.TrimPrefix(string(fields[2]), git.BRANCH_PREFIX)
// Branch protection // Branch protection
repoID := com.StrTo(os.Getenv(models.ENV_REPO_ID)).MustInt64() repoID := com.StrTo(os.Getenv(db.ENV_REPO_ID)).MustInt64()
protectBranch, err := models.GetProtectBranchOfRepoByName(repoID, branchName) protectBranch, err := db.GetProtectBranchOfRepoByName(repoID, branchName)
if err != nil { if err != nil {
if errors.IsErrBranchNotExist(err) { if errors.IsErrBranchNotExist(err) {
continue continue
@@ -107,9 +107,9 @@ func runHookPreReceive(c *cli.Context) error {
bypassRequirePullRequest := false bypassRequirePullRequest := false
// Check if user is in whitelist when enabled // 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 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), "") 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 // Check force push
output, err := git.NewCommand("rev-list", "--max-count=1", oldCommitID, "^"+newCommitID). 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 { if err != nil {
fail("Internal error", "Fail to detect force push: %v", err) fail("Internal error", "Fail to detect force push: %v", err)
} else if len(output) > 0 { } 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) { if !com.IsFile(customHooksPath) {
return nil return nil
} }
@@ -147,7 +147,7 @@ func runHookPreReceive(c *cli.Context) error {
} else { } else {
hookCmd = exec.Command(customHooksPath) 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.Stdout = os.Stdout
hookCmd.Stdin = buf hookCmd.Stdin = buf
hookCmd.Stderr = os.Stderr 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") 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) { if !com.IsFile(customHooksPath) {
return nil return nil
} }
@@ -181,7 +181,7 @@ func runHookUpdate(c *cli.Context) error {
} else { } else {
hookCmd = exec.Command(customHooksPath, args...) 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.Stdout = os.Stdout
hookCmd.Stdin = os.Stdin hookCmd.Stdin = os.Stdin
hookCmd.Stderr = os.Stderr hookCmd.Stderr = os.Stderr
@@ -204,7 +204,7 @@ func runHookPostReceive(c *cli.Context) error {
mailer.InitMailRender(path.Join(setting.StaticRootPath, "templates/mail"), mailer.InitMailRender(path.Join(setting.StaticRootPath, "templates/mail"),
path.Join(setting.CustomPath, "templates/mail"), template.NewFuncMap()) 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) buf := bytes.NewBuffer(nil)
scanner := bufio.NewScanner(os.Stdin) scanner := bufio.NewScanner(os.Stdin)
@@ -222,24 +222,24 @@ func runHookPostReceive(c *cli.Context) error {
continue continue
} }
options := models.PushUpdateOptions{ options := db.PushUpdateOptions{
OldCommitID: string(fields[0]), OldCommitID: string(fields[0]),
NewCommitID: string(fields[1]), NewCommitID: string(fields[1]),
RefFullName: string(fields[2]), RefFullName: string(fields[2]),
PusherID: com.StrTo(os.Getenv(models.ENV_AUTH_USER_ID)).MustInt64(), PusherID: com.StrTo(os.Getenv(db.ENV_AUTH_USER_ID)).MustInt64(),
PusherName: os.Getenv(models.ENV_AUTH_USER_NAME), PusherName: os.Getenv(db.ENV_AUTH_USER_NAME),
RepoUserName: os.Getenv(models.ENV_REPO_OWNER_NAME), RepoUserName: os.Getenv(db.ENV_REPO_OWNER_NAME),
RepoName: os.Getenv(models.ENV_REPO_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) log.Error(2, "PushUpdate: %v", err)
} }
// Ask for running deliver hook and test pull request tasks // Ask for running deliver hook and test pull request tasks
reqURL := setting.LocalURL + options.RepoUserName + "/" + options.RepoName + "/tasks/trigger?branch=" + reqURL := setting.LocalURL + options.RepoUserName + "/" + options.RepoName + "/tasks/trigger?branch=" +
template.EscapePound(strings.TrimPrefix(options.RefFullName, git.BRANCH_PREFIX)) + template.EscapePound(strings.TrimPrefix(options.RefFullName, git.BRANCH_PREFIX)) +
"&secret=" + os.Getenv(models.ENV_REPO_OWNER_SALT_MD5) + "&secret=" + os.Getenv(db.ENV_REPO_OWNER_SALT_MD5) +
"&pusher=" + os.Getenv(models.ENV_AUTH_USER_ID) "&pusher=" + os.Getenv(db.ENV_AUTH_USER_ID)
log.Trace("Trigger task: %s", reqURL) log.Trace("Trigger task: %s", reqURL)
resp, err := httplib.Head(reqURL).SetTLSClientConfig(&tls.Config{ 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) { if !com.IsFile(customHooksPath) {
return nil return nil
} }
@@ -266,7 +266,7 @@ func runHookPostReceive(c *cli.Context) error {
} else { } else {
hookCmd = exec.Command(customHooksPath) 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.Stdout = os.Stdout
hookCmd.Stdin = buf hookCmd.Stdin = buf
hookCmd.Stderr = os.Stderr hookCmd.Stderr = os.Stderr

View File

@@ -15,7 +15,7 @@ import (
"github.com/unknwon/com" "github.com/unknwon/com"
"github.com/urfave/cli" "github.com/urfave/cli"
"gogs.io/gogs/pkg/setting" "gogs.io/gogs/internal/setting"
) )
var ( var (

View File

@@ -8,15 +8,15 @@ import (
"os" "os"
"path" "path"
"github.com/mcuadros/go-version"
"github.com/unknwon/cae/zip" "github.com/unknwon/cae/zip"
"github.com/unknwon/com" "github.com/unknwon/com"
"github.com/mcuadros/go-version"
"github.com/urfave/cli" "github.com/urfave/cli"
log "gopkg.in/clog.v1" log "gopkg.in/clog.v1"
"gopkg.in/ini.v1" "gopkg.in/ini.v1"
"gogs.io/gogs/models" "gogs.io/gogs/internal/db"
"gogs.io/gogs/pkg/setting" "gogs.io/gogs/internal/setting"
) )
var Restore = cli.Command{ var Restore = cli.Command{
@@ -91,12 +91,12 @@ func runRestore(c *cli.Context) error {
setting.CustomConf = configFile setting.CustomConf = configFile
} }
setting.NewContext() setting.NewContext()
models.LoadConfigs() db.LoadConfigs()
models.SetEngine() db.SetEngine()
// Database // Database
dbDir := path.Join(archivePath, "db") 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) log.Fatal(0, "Failed to import database: %v", err)
} }

View File

@@ -16,9 +16,9 @@ import (
"github.com/urfave/cli" "github.com/urfave/cli"
log "gopkg.in/clog.v1" log "gopkg.in/clog.v1"
"gogs.io/gogs/models" "gogs.io/gogs/internal/db"
"gogs.io/gogs/models/errors" "gogs.io/gogs/internal/db/errors"
"gogs.io/gogs/pkg/setting" "gogs.io/gogs/internal/setting"
) )
const ( const (
@@ -76,14 +76,14 @@ func setup(c *cli.Context, logPath string, connectDB bool) {
return return
} }
models.LoadConfigs() db.LoadConfigs()
if setting.UseSQLite3 { if setting.UseSQLite3 {
workDir, _ := setting.WorkDir() workDir, _ := setting.WorkDir()
os.Chdir(workDir) os.Chdir(workDir)
} }
if err := models.SetEngine(); err != nil { if err := db.SetEngine(); err != nil {
fail("Internal error", "SetEngine: %v", err) fail("Internal error", "SetEngine: %v", err)
} }
} }
@@ -96,29 +96,29 @@ func parseSSHCmd(cmd string) (string, string) {
return ss[0], strings.Replace(ss[1], "'/", "'", 1) 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. // 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) fail("Key access denied", "Deploy key access denied: [key_id: %d, repo_id: %d]", key.ID, repo.ID)
} }
// Update deploy key activity. // Update deploy key activity.
deployKey, err := models.GetDeployKeyByRepo(key.ID, repo.ID) deployKey, err := db.GetDeployKeyByRepo(key.ID, repo.ID)
if err != nil { if err != nil {
fail("Internal error", "GetDeployKey: %v", err) fail("Internal error", "GetDeployKey: %v", err)
} }
deployKey.Updated = time.Now() deployKey.Updated = time.Now()
if err = models.UpdateDeployKey(deployKey); err != nil { if err = db.UpdateDeployKey(deployKey); err != nil {
fail("Internal error", "UpdateDeployKey: %v", err) fail("Internal error", "UpdateDeployKey: %v", err)
} }
} }
var ( var (
allowedCommands = map[string]models.AccessMode{ allowedCommands = map[string]db.AccessMode{
"git-upload-pack": models.ACCESS_MODE_READ, "git-upload-pack": db.ACCESS_MODE_READ,
"git-upload-archive": models.ACCESS_MODE_READ, "git-upload-archive": db.ACCESS_MODE_READ,
"git-receive-pack": models.ACCESS_MODE_WRITE, "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(strings.ToLower(repoFields[1]), ".git")
repoName = strings.TrimSuffix(repoName, ".wiki") repoName = strings.TrimSuffix(repoName, ".wiki")
owner, err := models.GetUserByName(ownerName) owner, err := db.GetUserByName(ownerName)
if err != nil { if err != nil {
if errors.IsUserNotExist(err) { if errors.IsUserNotExist(err) {
fail("Repository owner does not exist", "Unregistered owner: %s", ownerName) 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) 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 err != nil {
if errors.IsRepoNotExist(err) { if errors.IsRepoNotExist(err) {
fail(_ACCESS_DENIED_MESSAGE, "Repository does not exist: %s/%s", owner.Name, repoName) 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. // 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", "") fail("Mirror repository is read-only", "")
} }
// Allow anonymous (user is nil) clone for public repositories. // 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 { if err != nil {
fail("Invalid key ID", "Invalid key ID '%s': %v", c.Args()[0], err) 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. // Check deploy key or user key.
if key.IsDeployKey() { if key.IsDeployKey() {
if key.Mode < requestMode { if key.Mode < requestMode {
@@ -194,19 +194,19 @@ func runServ(c *cli.Context) error {
} }
checkDeployKey(key, repo) checkDeployKey(key, repo)
} else { } else {
user, err = models.GetUserByKeyID(key.ID) user, err = db.GetUserByKeyID(key.ID)
if err != nil { if err != nil {
fail("Internal error", "Fail to get user by key ID '%d': %v", key.ID, err) 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 { if err != nil {
fail("Internal error", "Fail to check access: %v", err) fail("Internal error", "Fail to check access: %v", err)
} }
if mode < requestMode { if mode < requestMode {
clientMessage := _ACCESS_DENIED_MESSAGE 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" clientMessage = "You do not have sufficient authorization for this action"
} }
fail(clientMessage, fail(clientMessage,
@@ -227,13 +227,13 @@ func runServ(c *cli.Context) error {
// Update user key activity. // Update user key activity.
if key.ID > 0 { if key.ID > 0 {
key, err := models.GetPublicKeyByID(key.ID) key, err := db.GetPublicKeyByID(key.ID)
if err != nil { if err != nil {
fail("Internal error", "GetPublicKeyByID: %v", err) fail("Internal error", "GetPublicKeyByID: %v", err)
} }
key.Updated = time.Now() key.Updated = time.Now()
if err = models.UpdatePublicKey(key); err != nil { if err = db.UpdatePublicKey(key); err != nil {
fail("Internal error", "UpdatePublicKey: %v", err) fail("Internal error", "UpdatePublicKey: %v", err)
} }
} }
@@ -250,8 +250,8 @@ func runServ(c *cli.Context) error {
} else { } else {
gitCmd = exec.Command(verb, repoFullName) gitCmd = exec.Command(verb, repoFullName)
} }
if requestMode == models.ACCESS_MODE_WRITE { if requestMode == db.ACCESS_MODE_WRITE {
gitCmd.Env = append(os.Environ(), models.ComposeHookEnvs(models.ComposeHookEnvsOptions{ gitCmd.Env = append(os.Environ(), db.ComposeHookEnvs(db.ComposeHookEnvsOptions{
AuthUser: user, AuthUser: user,
OwnerName: owner.Name, OwnerName: owner.Name,
OwnerSalt: owner.Salt, OwnerSalt: owner.Salt,

View File

@@ -15,7 +15,6 @@ import (
"path" "path"
"strings" "strings"
"github.com/unknwon/com"
"github.com/go-macaron/binding" "github.com/go-macaron/binding"
"github.com/go-macaron/cache" "github.com/go-macaron/cache"
"github.com/go-macaron/captcha" "github.com/go-macaron/captcha"
@@ -26,24 +25,25 @@ import (
"github.com/go-macaron/toolbox" "github.com/go-macaron/toolbox"
"github.com/mcuadros/go-version" "github.com/mcuadros/go-version"
"github.com/prometheus/client_golang/prometheus/promhttp" "github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/unknwon/com"
"github.com/urfave/cli" "github.com/urfave/cli"
log "gopkg.in/clog.v1" log "gopkg.in/clog.v1"
"gopkg.in/macaron.v1" "gopkg.in/macaron.v1"
"gogs.io/gogs/models" "gogs.io/gogs/internal/bindata"
"gogs.io/gogs/pkg/bindata" "gogs.io/gogs/internal/context"
"gogs.io/gogs/pkg/context" "gogs.io/gogs/internal/db"
"gogs.io/gogs/pkg/form" "gogs.io/gogs/internal/form"
"gogs.io/gogs/pkg/mailer" "gogs.io/gogs/internal/mailer"
"gogs.io/gogs/pkg/setting" "gogs.io/gogs/internal/route"
"gogs.io/gogs/pkg/template" "gogs.io/gogs/internal/route/admin"
"gogs.io/gogs/routes" apiv1 "gogs.io/gogs/internal/route/api/v1"
"gogs.io/gogs/routes/admin" "gogs.io/gogs/internal/route/dev"
apiv1 "gogs.io/gogs/routes/api/v1" "gogs.io/gogs/internal/route/org"
"gogs.io/gogs/routes/dev" "gogs.io/gogs/internal/route/repo"
"gogs.io/gogs/routes/org" "gogs.io/gogs/internal/route/user"
"gogs.io/gogs/routes/repo" "gogs.io/gogs/internal/setting"
"gogs.io/gogs/routes/user" "gogs.io/gogs/internal/template"
) )
var Web = cli.Command{ var Web = cli.Command{
@@ -97,14 +97,14 @@ func newMacaron() *macaron.Macaron {
m.Use(macaron.Static( m.Use(macaron.Static(
setting.AvatarUploadPath, setting.AvatarUploadPath,
macaron.StaticOptions{ macaron.StaticOptions{
Prefix: models.USER_AVATAR_URL_PREFIX, Prefix: db.USER_AVATAR_URL_PREFIX,
SkipLogging: setting.DisableRouterLog, SkipLogging: setting.DisableRouterLog,
}, },
)) ))
m.Use(macaron.Static( m.Use(macaron.Static(
setting.RepositoryAvatarUploadPath, setting.RepositoryAvatarUploadPath,
macaron.StaticOptions{ macaron.StaticOptions{
Prefix: models.REPO_AVATAR_URL_PREFIX, Prefix: db.REPO_AVATAR_URL_PREFIX,
SkipLogging: setting.DisableRouterLog, SkipLogging: setting.DisableRouterLog,
}, },
)) ))
@@ -156,7 +156,7 @@ func newMacaron() *macaron.Macaron {
HealthCheckFuncs: []*toolbox.HealthCheckFuncDesc{ HealthCheckFuncs: []*toolbox.HealthCheckFuncDesc{
&toolbox.HealthCheckFuncDesc{ &toolbox.HealthCheckFuncDesc{
Desc: "Database connection", Desc: "Database connection",
Func: models.Ping, Func: db.Ping,
}, },
}, },
})) }))
@@ -168,7 +168,7 @@ func runWeb(c *cli.Context) error {
if c.IsSet("config") { if c.IsSet("config") {
setting.CustomConf = c.String("config") setting.CustomConf = c.String("config")
} }
routes.GlobalInit() route.GlobalInit()
checkVersion() checkVersion()
m := newMacaron() m := newMacaron()
@@ -182,20 +182,20 @@ func runWeb(c *cli.Context) error {
m.SetAutoHead(true) 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. // Especially some AJAX requests, we can reduce middleware number to improve performance.
// Routers. // Routers.
m.Get("/", ignSignIn, routes.Home) m.Get("/", ignSignIn, route.Home)
m.Group("/explore", func() { m.Group("/explore", func() {
m.Get("", func(c *context.Context) { m.Get("", func(c *context.Context) {
c.Redirect(setting.AppSubURL + "/explore/repos") c.Redirect(setting.AppSubURL + "/explore/repos")
}) })
m.Get("/repos", routes.ExploreRepos) m.Get("/repos", route.ExploreRepos)
m.Get("/users", routes.ExploreUsers) m.Get("/users", route.ExploreUsers)
m.Get("/organizations", routes.ExploreOrganizations) m.Get("/organizations", route.ExploreOrganizations)
}, ignSignIn) }, ignSignIn)
m.Combo("/install", routes.InstallInit).Get(routes.Install). m.Combo("/install", route.InstallInit).Get(route.Install).
Post(bindIgnErr(form.Install{}), routes.InstallPost) Post(bindIgnErr(form.Install{}), route.InstallPost)
m.Get("/^:type(issues|pulls)$", reqSignIn, user.Issues) m.Get("/^:type(issues|pulls)$", reqSignIn, user.Issues)
// ***** START: User ***** // ***** START: User *****
@@ -311,9 +311,9 @@ func runWeb(c *cli.Context) error {
}, context.InjectParamsUser()) }, context.InjectParamsUser())
m.Get("/attachments/:uuid", func(c *context.Context) { 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 { if err != nil {
c.NotFoundOrServerError("GetAttachmentByUUID", models.IsErrAttachmentNotExist, err) c.NotFoundOrServerError("GetAttachmentByUUID", db.IsErrAttachmentNotExist, err)
return return
} else if !com.IsFile(attach.LocalPath()) { } else if !com.IsFile(attach.LocalPath()) {
c.NotFound() c.NotFound()
@@ -644,7 +644,7 @@ func runWeb(c *cli.Context) error {
m.Head("/tasks/trigger", repo.TriggerTask) m.Head("/tasks/trigger", repo.TriggerTask)
}) })
// Use the regexp to match the repository name // 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. // e.g. with or without ".git" suffix.
m.Group("/:reponame([\\d\\w-_\\.]+\\.git$)", func() { m.Group("/:reponame([\\d\\w-_\\.]+\\.git$)", func() {
m.Get("", ignSignIn, context.RepoAssignment(), context.RepoRef(), repo.Home) m.Get("", ignSignIn, context.RepoAssignment(), context.RepoRef(), repo.Home)
@@ -682,7 +682,7 @@ func runWeb(c *cli.Context) error {
}) })
// Not found handler. // Not found handler.
m.NotFound(routes.NotFound) m.NotFound(route.NotFound)
// Flag for port number in case first time run conflict. // Flag for port number in case first time run conflict.
if c.IsSet("port") { if c.IsSet("port") {

View File

@@ -13,7 +13,7 @@ import (
log "gopkg.in/clog.v1" log "gopkg.in/clog.v1"
"gopkg.in/macaron.v1" "gopkg.in/macaron.v1"
"gogs.io/gogs/pkg/setting" "gogs.io/gogs/internal/setting"
) )
type APIContext struct { type APIContext struct {

View File

@@ -5,10 +5,10 @@
package context package context
import ( import (
"gogs.io/gogs/models" "gogs.io/gogs/internal/db"
) )
type APIOrganization struct { type APIOrganization struct {
Organization *models.User Organization *db.User
Team *models.Team Team *db.Team
} }

View File

@@ -12,9 +12,9 @@ import (
"github.com/go-macaron/csrf" "github.com/go-macaron/csrf"
"gopkg.in/macaron.v1" "gopkg.in/macaron.v1"
"gogs.io/gogs/pkg/auth" "gogs.io/gogs/internal/auth"
"gogs.io/gogs/pkg/setting" "gogs.io/gogs/internal/setting"
"gogs.io/gogs/pkg/tool" "gogs.io/gogs/internal/tool"
) )
type ToggleOptions struct { type ToggleOptions struct {

View File

@@ -12,20 +12,20 @@ import (
"strings" "strings"
"time" "time"
"github.com/unknwon/com"
"github.com/go-macaron/cache" "github.com/go-macaron/cache"
"github.com/go-macaron/csrf" "github.com/go-macaron/csrf"
"github.com/go-macaron/i18n" "github.com/go-macaron/i18n"
"github.com/go-macaron/session" "github.com/go-macaron/session"
"github.com/unknwon/com"
log "gopkg.in/clog.v1" log "gopkg.in/clog.v1"
"gopkg.in/macaron.v1" "gopkg.in/macaron.v1"
"gogs.io/gogs/models" "gogs.io/gogs/internal/auth"
"gogs.io/gogs/models/errors" "gogs.io/gogs/internal/db"
"gogs.io/gogs/pkg/auth" "gogs.io/gogs/internal/db/errors"
"gogs.io/gogs/pkg/form" "gogs.io/gogs/internal/form"
"gogs.io/gogs/pkg/setting" "gogs.io/gogs/internal/setting"
"gogs.io/gogs/pkg/template" "gogs.io/gogs/internal/template"
) )
// Context represents context of a request. // Context represents context of a request.
@@ -37,7 +37,7 @@ type Context struct {
Session session.Store Session session.Store
Link string // Current request URL Link string // Current request URL
User *models.User User *db.User
IsLogged bool IsLogged bool
IsBasicAuth bool IsBasicAuth bool
IsTokenAuth bool IsTokenAuth bool
@@ -252,13 +252,13 @@ func Contexter() macaron.Handler {
repoName := c.Params(":reponame") repoName := c.Params(":reponame")
branchName := "master" branchName := "master"
owner, err := models.GetUserByName(ownerName) owner, err := db.GetUserByName(ownerName)
if err != nil { if err != nil {
c.NotFoundOrServerError("GetUserByName", errors.IsUserNotExist, err) c.NotFoundOrServerError("GetUserByName", errors.IsUserNotExist, err)
return return
} }
repo, err := models.GetRepositoryByName(owner.ID, repoName) repo, err := db.GetRepositoryByName(owner.ID, repoName)
if err == nil && len(repo.DefaultBranch) > 0 { if err == nil && len(repo.DefaultBranch) > 0 {
branchName = repo.DefaultBranch branchName = repo.DefaultBranch
} }
@@ -280,7 +280,7 @@ func Contexter() macaron.Handler {
</html> </html>
`, map[string]string{ `, map[string]string{
"GoGetImport": path.Join(setting.HostAddress, setting.AppSubURL, repo.FullName()), "GoGetImport": path.Join(setting.HostAddress, setting.AppSubURL, repo.FullName()),
"CloneLink": models.ComposeHTTPSCloneURL(ownerName, repoName), "CloneLink": db.ComposeHTTPSCloneURL(ownerName, repoName),
"GoDocDirectory": prefix + "{/dir}", "GoDocDirectory": prefix + "{/dir}",
"GoDocFile": prefix + "{/dir}/{file}#L{line}", "GoDocFile": prefix + "{/dir}/{file}#L{line}",
"InsecureFlag": insecureFlag, "InsecureFlag": insecureFlag,

View File

@@ -11,9 +11,9 @@ import (
"github.com/unknwon/com" "github.com/unknwon/com"
log "gopkg.in/clog.v1" log "gopkg.in/clog.v1"
"gogs.io/gogs/pkg/markup" "gogs.io/gogs/internal/markup"
"gogs.io/gogs/pkg/setting" "gogs.io/gogs/internal/setting"
"gogs.io/gogs/pkg/tool" "gogs.io/gogs/internal/tool"
) )
// renderNoticeBanner checks if a notice banner file exists and loads the message to display // renderNoticeBanner checks if a notice banner file exists and loads the message to display

View File

@@ -9,9 +9,9 @@ import (
"gopkg.in/macaron.v1" "gopkg.in/macaron.v1"
"gogs.io/gogs/models" "gogs.io/gogs/internal/db"
"gogs.io/gogs/models/errors" "gogs.io/gogs/internal/db/errors"
"gogs.io/gogs/pkg/setting" "gogs.io/gogs/internal/setting"
) )
type Organization struct { type Organization struct {
@@ -19,10 +19,10 @@ type Organization struct {
IsMember bool IsMember bool
IsTeamMember bool // Is member of team. IsTeamMember bool // Is member of team.
IsTeamAdmin bool // In owner team or team that has admin permission level. IsTeamAdmin bool // In owner team or team that has admin permission level.
Organization *models.User Organization *db.User
OrgLink string OrgLink string
Team *models.Team Team *db.Team
} }
func HandleOrgAssignment(c *Context, args ...bool) { func HandleOrgAssignment(c *Context, args ...bool) {
@@ -48,7 +48,7 @@ func HandleOrgAssignment(c *Context, args ...bool) {
orgName := c.Params(":org") orgName := c.Params(":org")
var err error var err error
c.Org.Organization, err = models.GetUserByName(orgName) c.Org.Organization, err = db.GetUserByName(orgName)
if err != nil { if err != nil {
c.NotFoundOrServerError("GetUserByName", errors.IsUserNotExist, err) c.NotFoundOrServerError("GetUserByName", errors.IsUserNotExist, err)
return return
@@ -81,7 +81,7 @@ func HandleOrgAssignment(c *Context, args ...bool) {
} }
} else { } else {
// Fake data. // Fake data.
c.Data["SignedUser"] = &models.User{} c.Data["SignedUser"] = &db.User{}
} }
if (requireMember && !c.Org.IsMember) || if (requireMember && !c.Org.IsMember) ||
(requireOwner && !c.Org.IsOwner) { (requireOwner && !c.Org.IsOwner) {
@@ -134,7 +134,7 @@ func HandleOrgAssignment(c *Context, args ...bool) {
return 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 c.Data["IsTeamAdmin"] = c.Org.IsTeamAdmin
if requireTeamAdmin && !c.Org.IsTeamAdmin { if requireTeamAdmin && !c.Org.IsTeamAdmin {
c.Handle(404, "OrgAssignment", err) c.Handle(404, "OrgAssignment", err)

View File

@@ -14,26 +14,26 @@ import (
"github.com/gogs/git-module" "github.com/gogs/git-module"
"gogs.io/gogs/models" "gogs.io/gogs/internal/db"
"gogs.io/gogs/models/errors" "gogs.io/gogs/internal/db/errors"
"gogs.io/gogs/pkg/setting" "gogs.io/gogs/internal/setting"
) )
type PullRequest struct { type PullRequest struct {
BaseRepo *models.Repository BaseRepo *db.Repository
Allowed bool Allowed bool
SameRepo bool SameRepo bool
HeadInfo string // [<user>:]<branch> HeadInfo string // [<user>:]<branch>
} }
type Repository struct { type Repository struct {
AccessMode models.AccessMode AccessMode db.AccessMode
IsWatching bool IsWatching bool
IsViewBranch bool IsViewBranch bool
IsViewTag bool IsViewTag bool
IsViewCommit bool IsViewCommit bool
Repository *models.Repository Repository *db.Repository
Owner *models.User Owner *db.User
Commit *git.Commit Commit *git.Commit
Tag *git.Tag Tag *git.Tag
GitRepo *git.Repository GitRepo *git.Repository
@@ -42,31 +42,31 @@ type Repository struct {
TreePath string TreePath string
CommitID string CommitID string
RepoLink string RepoLink string
CloneLink models.CloneLink CloneLink db.CloneLink
CommitsCount int64 CommitsCount int64
Mirror *models.Mirror Mirror *db.Mirror
PullRequest *PullRequest PullRequest *PullRequest
} }
// IsOwner returns true if current user is the owner of repository. // IsOwner returns true if current user is the owner of repository.
func (r *Repository) IsOwner() bool { 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. // IsAdmin returns true if current user has admin or higher access of repository.
func (r *Repository) IsAdmin() bool { 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. // IsWriter returns true if current user has write or higher access of repository.
func (r *Repository) IsWriter() bool { 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 // HasAccess returns true if the current user has at least read access for this repository
func (r *Repository) HasAccess() bool { 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. // 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 { func RepoAssignment(pages ...bool) macaron.Handler {
return func(c *Context) { return func(c *Context) {
var ( var (
owner *models.User owner *db.User
err error err error
isIssuesPage bool isIssuesPage bool
isWikiPage bool isWikiPage bool
@@ -134,7 +134,7 @@ func RepoAssignment(pages ...bool) macaron.Handler {
if c.IsLogged && c.User.LowerName == strings.ToLower(ownerName) { if c.IsLogged && c.User.LowerName == strings.ToLower(ownerName) {
owner = c.User owner = c.User
} else { } else {
owner, err = models.GetUserByName(ownerName) owner, err = db.GetUserByName(ownerName)
if err != nil { if err != nil {
c.NotFoundOrServerError("GetUserByName", errors.IsUserNotExist, err) c.NotFoundOrServerError("GetUserByName", errors.IsUserNotExist, err)
return return
@@ -143,7 +143,7 @@ func RepoAssignment(pages ...bool) macaron.Handler {
c.Repo.Owner = owner c.Repo.Owner = owner
c.Data["Username"] = c.Repo.Owner.Name c.Data["Username"] = c.Repo.Owner.Name
repo, err := models.GetRepositoryByName(owner.ID, repoName) repo, err := db.GetRepositoryByName(owner.ID, repoName)
if err != nil { if err != nil {
c.NotFoundOrServerError("GetRepositoryByName", errors.IsRepoNotExist, err) c.NotFoundOrServerError("GetRepositoryByName", errors.IsRepoNotExist, err)
return return
@@ -158,9 +158,9 @@ func RepoAssignment(pages ...bool) macaron.Handler {
// Admin has super access. // Admin has super access.
if c.IsLogged && c.User.IsAdmin { if c.IsLogged && c.User.IsAdmin {
c.Repo.AccessMode = models.ACCESS_MODE_OWNER c.Repo.AccessMode = db.ACCESS_MODE_OWNER
} else { } else {
mode, err := models.UserAccessMode(c.UserID(), repo) mode, err := db.UserAccessMode(c.UserID(), repo)
if err != nil { if err != nil {
c.ServerError("UserAccessMode", err) c.ServerError("UserAccessMode", err)
return return
@@ -169,7 +169,7 @@ func RepoAssignment(pages ...bool) macaron.Handler {
} }
// Check access // 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 // Redirect to any accessible page if not yet on it
if repo.IsPartialPublic() && if repo.IsPartialPublic() &&
(!(isIssuesPage || isWikiPage) || (!(isIssuesPage || isWikiPage) ||
@@ -199,7 +199,7 @@ func RepoAssignment(pages ...bool) macaron.Handler {
} }
if repo.IsMirror { if repo.IsMirror {
c.Repo.Mirror, err = models.GetMirrorByRepoID(repo.ID) c.Repo.Mirror, err = db.GetMirrorByRepoID(repo.ID)
if err != nil { if err != nil {
c.ServerError("GetMirror", err) c.ServerError("GetMirror", err)
return return
@@ -209,7 +209,7 @@ func RepoAssignment(pages ...bool) macaron.Handler {
c.Data["Mirror"] = c.Repo.Mirror 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 { if err != nil {
c.ServerError(fmt.Sprintf("RepoAssignment Invalid repo '%s'", c.Repo.Repository.RepoPath()), err) c.ServerError(fmt.Sprintf("RepoAssignment Invalid repo '%s'", c.Repo.Repository.RepoPath()), err)
return return
@@ -237,8 +237,8 @@ func RepoAssignment(pages ...bool) macaron.Handler {
c.Data["WikiCloneLink"] = repo.WikiCloneLink() c.Data["WikiCloneLink"] = repo.WikiCloneLink()
if c.IsLogged { if c.IsLogged {
c.Data["IsWatchingRepo"] = models.IsWatching(c.User.ID, repo.ID) c.Data["IsWatchingRepo"] = db.IsWatching(c.User.ID, repo.ID)
c.Data["IsStaringRepo"] = models.IsStaring(c.User.ID, repo.ID) c.Data["IsStaringRepo"] = db.IsStaring(c.User.ID, repo.ID)
} }
// repo is bare and display enable // repo is bare and display enable
@@ -286,7 +286,7 @@ func RepoRef() macaron.Handler {
// For API calls. // For API calls.
if c.Repo.GitRepo == nil { 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) c.Repo.GitRepo, err = git.OpenRepository(repoPath)
if err != nil { if err != nil {
c.Handle(500, "RepoRef Invalid repo "+repoPath, err) c.Handle(500, "RepoRef Invalid repo "+repoPath, err)

View File

@@ -7,20 +7,20 @@ package context
import ( import (
"gopkg.in/macaron.v1" "gopkg.in/macaron.v1"
"gogs.io/gogs/models" "gogs.io/gogs/internal/db"
"gogs.io/gogs/models/errors" "gogs.io/gogs/internal/db/errors"
) )
// ParamsUser is the wrapper type of the target user defined by URL parameter, namely ':username'. // ParamsUser is the wrapper type of the target user defined by URL parameter, namely ':username'.
type ParamsUser struct { type ParamsUser struct {
*models.User *db.User
} }
// InjectParamsUser returns a handler that retrieves target user based on URL parameter ':username', // InjectParamsUser returns a handler that retrieves target user based on URL parameter ':username',
// and injects it as *ParamsUser. // and injects it as *ParamsUser.
func InjectParamsUser() macaron.Handler { func InjectParamsUser() macaron.Handler {
return func(c *Context) { return func(c *Context) {
user, err := models.GetUserByName(c.Params(":username")) user, err := db.GetUserByName(c.Params(":username"))
if err != nil { if err != nil {
c.NotFoundOrServerError("GetUserByName", errors.IsUserNotExist, err) c.NotFoundOrServerError("GetUserByName", errors.IsUserNotExist, err)
return return

View File

@@ -11,8 +11,8 @@ import (
"github.com/gogs/cron" "github.com/gogs/cron"
"gogs.io/gogs/models" "gogs.io/gogs/internal/db"
"gogs.io/gogs/pkg/setting" "gogs.io/gogs/internal/setting"
) )
var c = cron.New() var c = cron.New()
@@ -23,47 +23,47 @@ func NewContext() {
err error err error
) )
if setting.Cron.UpdateMirror.Enabled { 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 { if err != nil {
log.Fatal(2, "Cron.(update mirrors): %v", err) log.Fatal(2, "Cron.(update mirrors): %v", err)
} }
if setting.Cron.UpdateMirror.RunAtStart { if setting.Cron.UpdateMirror.RunAtStart {
entry.Prev = time.Now() entry.Prev = time.Now()
entry.ExecTimes++ entry.ExecTimes++
go models.MirrorUpdate() go db.MirrorUpdate()
} }
} }
if setting.Cron.RepoHealthCheck.Enabled { 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 { if err != nil {
log.Fatal(2, "Cron.(repository health check): %v", err) log.Fatal(2, "Cron.(repository health check): %v", err)
} }
if setting.Cron.RepoHealthCheck.RunAtStart { if setting.Cron.RepoHealthCheck.RunAtStart {
entry.Prev = time.Now() entry.Prev = time.Now()
entry.ExecTimes++ entry.ExecTimes++
go models.GitFsck() go db.GitFsck()
} }
} }
if setting.Cron.CheckRepoStats.Enabled { 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 { if err != nil {
log.Fatal(2, "Cron.(check repository statistics): %v", err) log.Fatal(2, "Cron.(check repository statistics): %v", err)
} }
if setting.Cron.CheckRepoStats.RunAtStart { if setting.Cron.CheckRepoStats.RunAtStart {
entry.Prev = time.Now() entry.Prev = time.Now()
entry.ExecTimes++ entry.ExecTimes++
go models.CheckRepoStats() go db.CheckRepoStats()
} }
} }
if setting.Cron.RepoArchiveCleanup.Enabled { 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 { if err != nil {
log.Fatal(2, "Cron.(repository archive cleanup): %v", err) log.Fatal(2, "Cron.(repository archive cleanup): %v", err)
} }
if setting.Cron.RepoArchiveCleanup.RunAtStart { if setting.Cron.RepoArchiveCleanup.RunAtStart {
entry.Prev = time.Now() entry.Prev = time.Now()
entry.ExecTimes++ entry.ExecTimes++
go models.DeleteOldRepositoryArchives() go db.DeleteOldRepositoryArchives()
} }
} }
c.Start() c.Start()

View File

@@ -2,14 +2,14 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
package models package db
import ( import (
"fmt" "fmt"
log "gopkg.in/clog.v1" log "gopkg.in/clog.v1"
"gogs.io/gogs/models/errors" "gogs.io/gogs/internal/db/errors"
) )
type AccessMode int type AccessMode int

View File

@@ -2,7 +2,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
package models package db
import ( import (
"fmt" "fmt"
@@ -12,17 +12,17 @@ import (
"time" "time"
"unicode" "unicode"
"github.com/unknwon/com"
"xorm.io/xorm"
"github.com/json-iterator/go" "github.com/json-iterator/go"
"github.com/unknwon/com"
log "gopkg.in/clog.v1" log "gopkg.in/clog.v1"
"xorm.io/xorm"
"github.com/gogs/git-module" "github.com/gogs/git-module"
api "github.com/gogs/go-gogs-client" api "github.com/gogs/go-gogs-client"
"gogs.io/gogs/models/errors" "gogs.io/gogs/internal/db/errors"
"gogs.io/gogs/pkg/setting" "gogs.io/gogs/internal/setting"
"gogs.io/gogs/pkg/tool" "gogs.io/gogs/internal/tool"
) )
type ActionType int type ActionType int

View File

@@ -2,7 +2,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
package models package db
import ( import (
"fmt" "fmt"
@@ -11,10 +11,10 @@ import (
"time" "time"
"github.com/unknwon/com" "github.com/unknwon/com"
"xorm.io/xorm"
log "gopkg.in/clog.v1" log "gopkg.in/clog.v1"
"xorm.io/xorm"
"gogs.io/gogs/pkg/tool" "gogs.io/gogs/internal/tool"
) )
type NoticeType int type NoticeType int

View File

@@ -2,7 +2,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
package models package db
import ( import (
"fmt" "fmt"
@@ -12,10 +12,10 @@ import (
"path" "path"
"time" "time"
"xorm.io/xorm"
gouuid "github.com/satori/go.uuid" 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. // Attachment represent a attachment of issue/comment/release.

View File

@@ -2,7 +2,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
package models package db
import ( import (
"fmt" "fmt"
@@ -10,13 +10,13 @@ import (
"time" "time"
"github.com/unknwon/com" "github.com/unknwon/com"
"xorm.io/xorm"
log "gopkg.in/clog.v1" log "gopkg.in/clog.v1"
"xorm.io/xorm"
api "github.com/gogs/go-gogs-client" api "github.com/gogs/go-gogs-client"
"gogs.io/gogs/models/errors" "gogs.io/gogs/internal/db/errors"
"gogs.io/gogs/pkg/markup" "gogs.io/gogs/internal/markup"
) )
// CommentType defines whether a comment is just a simple comment, an action (like close) or a reference. // CommentType defines whether a comment is just a simple comment, an action (like close) or a reference.

View File

@@ -2,7 +2,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
package models package db
import ( import (
"fmt" "fmt"

View File

@@ -2,7 +2,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
package models package db
import ( import (
"bytes" "bytes"
@@ -17,9 +17,9 @@ import (
"github.com/gogs/git-module" "github.com/gogs/git-module"
"gogs.io/gogs/pkg/setting" "gogs.io/gogs/internal/setting"
"gogs.io/gogs/pkg/template/highlight" "gogs.io/gogs/internal/template/highlight"
"gogs.io/gogs/pkg/tool" "gogs.io/gogs/internal/tool"
) )
type DiffSection struct { type DiffSection struct {

View File

@@ -2,7 +2,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
package models package db
import ( import (
"html/template" "html/template"

View File

@@ -2,7 +2,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
package models package db
import ( import (
"fmt" "fmt"
@@ -10,14 +10,14 @@ import (
"time" "time"
"github.com/unknwon/com" "github.com/unknwon/com"
"xorm.io/xorm"
log "gopkg.in/clog.v1" log "gopkg.in/clog.v1"
"xorm.io/xorm"
api "github.com/gogs/go-gogs-client" api "github.com/gogs/go-gogs-client"
"gogs.io/gogs/models/errors" "gogs.io/gogs/internal/db/errors"
"gogs.io/gogs/pkg/setting" "gogs.io/gogs/internal/setting"
"gogs.io/gogs/pkg/tool" "gogs.io/gogs/internal/tool"
) )
var ( var (

View File

@@ -2,7 +2,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
package models package db
import ( import (
"fmt" "fmt"
@@ -15,7 +15,7 @@ import (
api "github.com/gogs/go-gogs-client" 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})") var labelColorPattern = regexp.MustCompile("#([a-fA-F0-9]{6})")

View File

@@ -2,7 +2,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
package models package db
import ( import (
"fmt" "fmt"
@@ -10,9 +10,9 @@ import (
"github.com/unknwon/com" "github.com/unknwon/com"
log "gopkg.in/clog.v1" log "gopkg.in/clog.v1"
"gogs.io/gogs/pkg/mailer" "gogs.io/gogs/internal/mailer"
"gogs.io/gogs/pkg/markup" "gogs.io/gogs/internal/markup"
"gogs.io/gogs/pkg/setting" "gogs.io/gogs/internal/setting"
) )
func (issue *Issue) MailSubject() string { func (issue *Issue) MailSubject() string {

View File

@@ -3,7 +3,7 @@
// license that can be found in the LICENSE file. // 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. // FIXME: Put this file into its own package and separate into different files based on login sources.
package models package db
import ( import (
"crypto/tls" "crypto/tls"
@@ -24,11 +24,11 @@ import (
"xorm.io/core" "xorm.io/core"
"xorm.io/xorm" "xorm.io/xorm"
"gogs.io/gogs/models/errors" "gogs.io/gogs/internal/auth/github"
"gogs.io/gogs/pkg/auth/github" "gogs.io/gogs/internal/auth/ldap"
"gogs.io/gogs/pkg/auth/ldap" "gogs.io/gogs/internal/auth/pam"
"gogs.io/gogs/pkg/auth/pam" "gogs.io/gogs/internal/db/errors"
"gogs.io/gogs/pkg/setting" "gogs.io/gogs/internal/setting"
) )
type LoginType int type LoginType int

View File

@@ -10,10 +10,10 @@ import (
"time" "time"
"github.com/unknwon/com" "github.com/unknwon/com"
"xorm.io/xorm"
log "gopkg.in/clog.v1" log "gopkg.in/clog.v1"
"xorm.io/xorm"
"gogs.io/gogs/pkg/tool" "gogs.io/gogs/internal/tool"
) )
const _MIN_DB_VER = 10 const _MIN_DB_VER = 10

View File

@@ -15,7 +15,7 @@ import (
"xorm.io/xorm" "xorm.io/xorm"
log "gopkg.in/clog.v1" log "gopkg.in/clog.v1"
"gogs.io/gogs/pkg/setting" "gogs.io/gogs/internal/setting"
) )
func generateAndMigrateGitHooks(x *xorm.Engine) (err error) { func generateAndMigrateGitHooks(x *xorm.Engine) (err error) {

View File

@@ -14,7 +14,7 @@ import (
"github.com/gogs/git-module" "github.com/gogs/git-module"
"gogs.io/gogs/pkg/setting" "gogs.io/gogs/internal/setting"
) )
func updateRepositorySizes(x *xorm.Engine) (err error) { func updateRepositorySizes(x *xorm.Engine) (err error) {

View File

@@ -9,7 +9,7 @@ import (
"xorm.io/xorm" "xorm.io/xorm"
"gogs.io/gogs/pkg/setting" "gogs.io/gogs/internal/setting"
) )
func updateRepositoryDescriptionField(x *xorm.Engine) error { func updateRepositoryDescriptionField(x *xorm.Engine) error {

View File

@@ -2,18 +2,18 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
package models package db
import ( import (
"fmt" "fmt"
"time" "time"
"xorm.io/xorm"
log "gopkg.in/clog.v1" log "gopkg.in/clog.v1"
"xorm.io/xorm"
api "github.com/gogs/go-gogs-client" api "github.com/gogs/go-gogs-client"
"gogs.io/gogs/pkg/setting" "gogs.io/gogs/internal/setting"
) )
// Milestone represents a milestone of repository. // Milestone represents a milestone of repository.

View File

@@ -2,7 +2,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
package models package db
import ( import (
"container/list" "container/list"
@@ -12,16 +12,16 @@ import (
"time" "time"
"github.com/unknwon/com" "github.com/unknwon/com"
"xorm.io/xorm"
log "gopkg.in/clog.v1" log "gopkg.in/clog.v1"
"gopkg.in/ini.v1" "gopkg.in/ini.v1"
"xorm.io/xorm"
"github.com/gogs/git-module" "github.com/gogs/git-module"
"gogs.io/gogs/models/errors" "gogs.io/gogs/internal/db/errors"
"gogs.io/gogs/pkg/process" "gogs.io/gogs/internal/process"
"gogs.io/gogs/pkg/setting" "gogs.io/gogs/internal/setting"
"gogs.io/gogs/pkg/sync" "gogs.io/gogs/internal/sync"
) )
var MirrorQueue = sync.NewUniqueQueue(setting.Repository.MirrorQueueLength) var MirrorQueue = sync.NewUniqueQueue(setting.Repository.MirrorQueueLength)

View File

@@ -2,7 +2,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
package models package db
import ( import (
"testing" "testing"

View File

@@ -2,7 +2,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
package models package db
import ( import (
"bufio" "bufio"
@@ -17,15 +17,15 @@ import (
_ "github.com/denisenkom/go-mssqldb" _ "github.com/denisenkom/go-mssqldb"
_ "github.com/go-sql-driver/mysql" _ "github.com/go-sql-driver/mysql"
"xorm.io/core"
"xorm.io/xorm"
"github.com/json-iterator/go" "github.com/json-iterator/go"
_ "github.com/lib/pq" _ "github.com/lib/pq"
"github.com/unknwon/com" "github.com/unknwon/com"
log "gopkg.in/clog.v1" log "gopkg.in/clog.v1"
"xorm.io/core"
"xorm.io/xorm"
"gogs.io/gogs/models/migrations" "gogs.io/gogs/internal/db/migrations"
"gogs.io/gogs/pkg/setting" "gogs.io/gogs/internal/setting"
) )
// Engine represents a XORM engine or session. // 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 // Purposely create a local variable to not modify global variable
tables := append(tables, new(Version)) tables := append(tables, new(Version))
for _, table := range tables { 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") tableFile := path.Join(dirPath, tableName+".json")
f, err := os.Create(tableFile) f, err := os.Create(tableFile)
if err != nil { 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 // Purposely create a local variable to not modify global variable
tables := append(tables, new(Version)) tables := append(tables, new(Version))
for _, table := range tables { 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") tableFile := path.Join(dirPath, tableName+".json")
if !com.IsExist(tableFile) { if !com.IsExist(tableFile) {
continue continue

View File

@@ -4,7 +4,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
package models package db
import ( import (
_ "github.com/mattn/go-sqlite3" _ "github.com/mattn/go-sqlite3"

View File

@@ -2,7 +2,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
package models package db
import ( import (
"testing" "testing"

View File

@@ -2,7 +2,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
package models package db
import ( import (
"errors" "errors"

View File

@@ -2,7 +2,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
package models package db
import ( import (
"fmt" "fmt"
@@ -10,7 +10,7 @@ import (
"xorm.io/xorm" "xorm.io/xorm"
"gogs.io/gogs/models/errors" "gogs.io/gogs/internal/db/errors"
) )
const OWNER_TEAM = "Owners" const OWNER_TEAM = "Owners"

View File

@@ -2,7 +2,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
package models package db
import ( import (
"fmt" "fmt"
@@ -12,16 +12,16 @@ import (
"time" "time"
"github.com/unknwon/com" "github.com/unknwon/com"
"xorm.io/xorm"
log "gopkg.in/clog.v1" log "gopkg.in/clog.v1"
"xorm.io/xorm"
"github.com/gogs/git-module" "github.com/gogs/git-module"
api "github.com/gogs/go-gogs-client" api "github.com/gogs/go-gogs-client"
"gogs.io/gogs/models/errors" "gogs.io/gogs/internal/db/errors"
"gogs.io/gogs/pkg/process" "gogs.io/gogs/internal/process"
"gogs.io/gogs/pkg/setting" "gogs.io/gogs/internal/setting"
"gogs.io/gogs/pkg/sync" "gogs.io/gogs/internal/sync"
) )
var PullRequestQueue = sync.NewUniqueQueue(setting.Repository.PullRequestQueueLength) var PullRequestQueue = sync.NewUniqueQueue(setting.Repository.PullRequestQueueLength)

View File

@@ -2,7 +2,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
package models package db
import ( import (
"fmt" "fmt"
@@ -10,14 +10,14 @@ import (
"strings" "strings"
"time" "time"
"xorm.io/xorm"
log "gopkg.in/clog.v1" log "gopkg.in/clog.v1"
"xorm.io/xorm"
"github.com/gogs/git-module" "github.com/gogs/git-module"
api "github.com/gogs/go-gogs-client" api "github.com/gogs/go-gogs-client"
"gogs.io/gogs/models/errors" "gogs.io/gogs/internal/db/errors"
"gogs.io/gogs/pkg/process" "gogs.io/gogs/internal/process"
) )
// Release represents a release of repository. // Release represents a release of repository.

View File

@@ -2,7 +2,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
package models package db
import ( import (
"bytes" "bytes"
@@ -19,24 +19,24 @@ import (
"strings" "strings"
"time" "time"
"github.com/unknwon/cae/zip"
"github.com/unknwon/com"
"xorm.io/xorm"
"github.com/mcuadros/go-version" "github.com/mcuadros/go-version"
"github.com/nfnt/resize" "github.com/nfnt/resize"
"github.com/unknwon/cae/zip"
"github.com/unknwon/com"
log "gopkg.in/clog.v1" log "gopkg.in/clog.v1"
"gopkg.in/ini.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" api "github.com/gogs/go-gogs-client"
"gogs.io/gogs/models/errors" "gogs.io/gogs/internal/avatar"
"gogs.io/gogs/pkg/avatar" "gogs.io/gogs/internal/bindata"
"gogs.io/gogs/pkg/bindata" "gogs.io/gogs/internal/db/errors"
"gogs.io/gogs/pkg/markup" "gogs.io/gogs/internal/markup"
"gogs.io/gogs/pkg/process" "gogs.io/gogs/internal/process"
"gogs.io/gogs/pkg/setting" "gogs.io/gogs/internal/setting"
"gogs.io/gogs/pkg/sync" "gogs.io/gogs/internal/sync"
) )
// REPO_AVATAR_URL_PREFIX is used to identify a URL is to access repository avatar. // 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) { func (repo *Repository) AfterSet(colName string, _ xorm.Cell) {
switch colName { switch colName {
case "default_branch": 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 { if len(repo.DefaultBranch) == 0 {
repo.DefaultBranch = "master" repo.DefaultBranch = "master"
} }

View File

@@ -2,17 +2,17 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
package models package db
import ( import (
"fmt" "fmt"
"strings" "strings"
"github.com/unknwon/com"
"github.com/gogs/git-module" "github.com/gogs/git-module"
"github.com/unknwon/com"
"gogs.io/gogs/models/errors" "gogs.io/gogs/internal/db/errors"
"gogs.io/gogs/pkg/tool" "gogs.io/gogs/internal/tool"
) )
type Branch struct { type Branch struct {

View File

@@ -2,7 +2,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
package models package db
import ( import (
"fmt" "fmt"

View File

@@ -2,7 +2,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
package models package db
import ( import (
"fmt" "fmt"
@@ -16,15 +16,15 @@ import (
"strings" "strings"
"time" "time"
"github.com/unknwon/com"
gouuid "github.com/satori/go.uuid" gouuid "github.com/satori/go.uuid"
"github.com/unknwon/com"
"github.com/gogs/git-module" "github.com/gogs/git-module"
"gogs.io/gogs/models/errors" "gogs.io/gogs/internal/db/errors"
"gogs.io/gogs/pkg/process" "gogs.io/gogs/internal/process"
"gogs.io/gogs/pkg/setting" "gogs.io/gogs/internal/setting"
"gogs.io/gogs/pkg/tool" "gogs.io/gogs/internal/tool"
) )
const ( const (

View File

@@ -2,7 +2,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
package models package db
import ( import (
"os" "os"

View File

@@ -1,19 +1,19 @@
package models_test package db_test
import ( import (
"testing" "testing"
. "github.com/smartystreets/goconvey/convey" . "github.com/smartystreets/goconvey/convey"
. "gogs.io/gogs/models" "gogs.io/gogs/internal/db"
"gogs.io/gogs/pkg/markup" "gogs.io/gogs/internal/markup"
) )
func TestRepo(t *testing.T) { func TestRepo(t *testing.T) {
Convey("The metas map", t, func() { Convey("The metas map", t, func() {
var repo = new(Repository) var repo = new(db.Repository)
repo.Name = "testrepo" repo.Name = "testrepo"
repo.Owner = new(User) repo.Owner = new(db.User)
repo.Owner.Name = "testuser" repo.Owner.Name = "testuser"
repo.ExternalTrackerFormat = "https://someurl.com/{user}/{repo}/{issue}" repo.ExternalTrackerFormat = "https://someurl.com/{user}/{repo}/{issue}"

View File

@@ -2,7 +2,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
package models package db
import ( import (
"encoding/base64" "encoding/base64"
@@ -19,12 +19,12 @@ import (
"time" "time"
"github.com/unknwon/com" "github.com/unknwon/com"
"xorm.io/xorm"
"golang.org/x/crypto/ssh" "golang.org/x/crypto/ssh"
log "gopkg.in/clog.v1" log "gopkg.in/clog.v1"
"xorm.io/xorm"
"gogs.io/gogs/pkg/process" "gogs.io/gogs/internal/process"
"gogs.io/gogs/pkg/setting" "gogs.io/gogs/internal/setting"
) )
const ( const (

View File

@@ -2,7 +2,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
package models package db
import ( import (
"fmt" "fmt"
@@ -11,7 +11,7 @@ import (
. "github.com/smartystreets/goconvey/convey" . "github.com/smartystreets/goconvey/convey"
"gogs.io/gogs/pkg/setting" "gogs.io/gogs/internal/setting"
) )
func init() { func init() {

View File

@@ -2,15 +2,16 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
package models package db
import ( import (
"time" "time"
"xorm.io/xorm"
"gogs.io/gogs/models/errors"
"gogs.io/gogs/pkg/tool"
gouuid "github.com/satori/go.uuid" 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. // AccessToken represents a personal access token.

View File

@@ -2,7 +2,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
package models package db
import ( import (
"encoding/base64" "encoding/base64"
@@ -10,14 +10,14 @@ import (
"strings" "strings"
"time" "time"
"github.com/unknwon/com"
"xorm.io/xorm"
"github.com/pquerna/otp/totp" "github.com/pquerna/otp/totp"
"github.com/unknwon/com"
log "gopkg.in/clog.v1" log "gopkg.in/clog.v1"
"xorm.io/xorm"
"gogs.io/gogs/models/errors" "gogs.io/gogs/internal/db/errors"
"gogs.io/gogs/pkg/setting" "gogs.io/gogs/internal/setting"
"gogs.io/gogs/pkg/tool" "gogs.io/gogs/internal/tool"
) )
// TwoFactor represents a two-factor authentication token. // TwoFactor represents a two-factor authentication token.

View File

@@ -2,7 +2,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
package models package db
import ( import (
"container/list" "container/list"

View File

@@ -2,7 +2,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
package models package db
import ( import (
"bytes" "bytes"
@@ -20,19 +20,19 @@ import (
"time" "time"
"unicode/utf8" "unicode/utf8"
"github.com/unknwon/com"
"xorm.io/xorm"
"github.com/nfnt/resize" "github.com/nfnt/resize"
"github.com/unknwon/com"
"golang.org/x/crypto/pbkdf2" "golang.org/x/crypto/pbkdf2"
log "gopkg.in/clog.v1" log "gopkg.in/clog.v1"
"xorm.io/xorm"
"github.com/gogs/git-module" "github.com/gogs/git-module"
api "github.com/gogs/go-gogs-client" api "github.com/gogs/go-gogs-client"
"gogs.io/gogs/models/errors" "gogs.io/gogs/internal/avatar"
"gogs.io/gogs/pkg/avatar" "gogs.io/gogs/internal/db/errors"
"gogs.io/gogs/pkg/setting" "gogs.io/gogs/internal/setting"
"gogs.io/gogs/pkg/tool" "gogs.io/gogs/internal/tool"
) )
// USER_AVATAR_URL_PREFIX is used to identify a URL is to access user avatar. // USER_AVATAR_URL_PREFIX is used to identify a URL is to access user avatar.

View File

@@ -2,7 +2,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
package models package db
// MailResendCacheKey returns key used for cache mail resend. // MailResendCacheKey returns key used for cache mail resend.
func (u *User) MailResendCacheKey() string { func (u *User) MailResendCacheKey() string {

View File

@@ -2,13 +2,13 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
package models package db
import ( import (
"fmt" "fmt"
"strings" "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 // EmailAdresses is the list of all email addresses of a user. Can contain the

View File

@@ -2,7 +2,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
package models package db
import ( import (
"crypto/hmac" "crypto/hmac"
@@ -14,17 +14,17 @@ import (
"strings" "strings"
"time" "time"
"xorm.io/xorm"
"github.com/json-iterator/go" "github.com/json-iterator/go"
gouuid "github.com/satori/go.uuid" gouuid "github.com/satori/go.uuid"
log "gopkg.in/clog.v1" log "gopkg.in/clog.v1"
"xorm.io/xorm"
api "github.com/gogs/go-gogs-client" api "github.com/gogs/go-gogs-client"
"gogs.io/gogs/models/errors" "gogs.io/gogs/internal/db/errors"
"gogs.io/gogs/pkg/httplib" "gogs.io/gogs/internal/httplib"
"gogs.io/gogs/pkg/setting" "gogs.io/gogs/internal/setting"
"gogs.io/gogs/pkg/sync" "gogs.io/gogs/internal/sync"
) )
var HookQueue = sync.NewUniqueQueue(setting.Webhook.QueueLength) var HookQueue = sync.NewUniqueQueue(setting.Webhook.QueueLength)

View File

@@ -2,7 +2,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
package models package db
import ( import (
"fmt" "fmt"

View File

@@ -2,7 +2,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
package models package db
import ( import (
"fmt" "fmt"
@@ -14,7 +14,7 @@ import (
"github.com/gogs/git-module" "github.com/gogs/git-module"
api "github.com/gogs/go-gogs-client" api "github.com/gogs/go-gogs-client"
"gogs.io/gogs/pkg/setting" "gogs.io/gogs/internal/setting"
) )
type DiscordEmbedFooterObject struct { type DiscordEmbedFooterObject struct {

View File

@@ -2,7 +2,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
package models package db
import ( import (
"fmt" "fmt"
@@ -13,7 +13,7 @@ import (
"github.com/gogs/git-module" "github.com/gogs/git-module"
api "github.com/gogs/go-gogs-client" api "github.com/gogs/go-gogs-client"
"gogs.io/gogs/pkg/setting" "gogs.io/gogs/internal/setting"
) )
type SlackMeta struct { type SlackMeta struct {

View File

@@ -2,7 +2,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
package models package db
import ( import (
"fmt" "fmt"
@@ -17,8 +17,8 @@ import (
"github.com/gogs/git-module" "github.com/gogs/git-module"
"gogs.io/gogs/pkg/setting" "gogs.io/gogs/internal/setting"
"gogs.io/gogs/pkg/sync" "gogs.io/gogs/internal/sync"
) )
var wikiWorkingPool = sync.NewExclusivePool() var wikiWorkingPool = sync.NewExclusivePool()

View File

@@ -8,11 +8,11 @@ import (
"net/url" "net/url"
"strings" "strings"
"github.com/unknwon/com"
"github.com/go-macaron/binding" "github.com/go-macaron/binding"
"github.com/unknwon/com"
"gopkg.in/macaron.v1" "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. // and returns composed URL with needed username and password.
// It also checks if given user has permission when remote address // It also checks if given user has permission when remote address
// is actually a local path. // 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) remoteAddr := strings.TrimSpace(f.CloneAddr)
// Remote address can be HTTP/HTTPS/Git URL or local path. // 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://") { strings.HasPrefix(remoteAddr, "git://") {
u, err := url.Parse(remoteAddr) u, err := url.Parse(remoteAddr)
if err != nil { if err != nil {
return "", models.ErrInvalidCloneAddr{IsURLError: true} return "", db.ErrInvalidCloneAddr{IsURLError: true}
} }
if len(f.AuthUsername)+len(f.AuthPassword) > 0 { if len(f.AuthUsername)+len(f.AuthPassword) > 0 {
u.User = url.UserPassword(f.AuthUsername, f.AuthPassword) u.User = url.UserPassword(f.AuthUsername, f.AuthPassword)
} }
remoteAddr = u.String() remoteAddr = u.String()
} else if !user.CanImportLocal() { } else if !user.CanImportLocal() {
return "", models.ErrInvalidCloneAddr{IsPermissionDenied: true} return "", db.ErrInvalidCloneAddr{IsPermissionDenied: true}
} else if !com.IsDir(remoteAddr) { } else if !com.IsDir(remoteAddr) {
return "", models.ErrInvalidCloneAddr{IsInvalidPath: true} return "", db.ErrInvalidCloneAddr{IsInvalidPath: true}
} }
return remoteAddr, nil return remoteAddr, nil

View File

@@ -12,8 +12,8 @@ import (
"gopkg.in/gomail.v2" "gopkg.in/gomail.v2"
"gopkg.in/macaron.v1" "gopkg.in/macaron.v1"
"gogs.io/gogs/pkg/markup" "gogs.io/gogs/internal/markup"
"gogs.io/gogs/pkg/setting" "gogs.io/gogs/internal/setting"
) )
const ( const (

View File

@@ -18,7 +18,7 @@ import (
log "gopkg.in/clog.v1" log "gopkg.in/clog.v1"
"gopkg.in/gomail.v2" "gopkg.in/gomail.v2"
"gogs.io/gogs/pkg/setting" "gogs.io/gogs/internal/setting"
) )
type Message struct { type Message struct {

View File

@@ -14,8 +14,8 @@ import (
"github.com/russross/blackfriday" "github.com/russross/blackfriday"
"gogs.io/gogs/pkg/setting" "gogs.io/gogs/internal/setting"
"gogs.io/gogs/pkg/tool" "gogs.io/gogs/internal/tool"
) )
// IsMarkdownFile reports whether name looks like a Markdown file based on its extension. // IsMarkdownFile reports whether name looks like a Markdown file based on its extension.

View File

@@ -12,8 +12,8 @@ import (
"github.com/russross/blackfriday" "github.com/russross/blackfriday"
. "github.com/smartystreets/goconvey/convey" . "github.com/smartystreets/goconvey/convey"
. "gogs.io/gogs/pkg/markup" . "gogs.io/gogs/internal/markup"
"gogs.io/gogs/pkg/setting" "gogs.io/gogs/internal/setting"
) )
func Test_IsMarkdownFile(t *testing.T) { func Test_IsMarkdownFile(t *testing.T) {

Some files were not shown because too many files have changed in this diff Show More