aboutsummaryrefslogtreecommitdiff
path: root/models/repo/projectbase.go
diff options
context:
space:
mode:
Diffstat (limited to 'models/repo/projectbase.go')
-rw-r--r--models/repo/projectbase.go38
1 files changed, 38 insertions, 0 deletions
diff --git a/models/repo/projectbase.go b/models/repo/projectbase.go
new file mode 100644
index 000000000..ac5317dcb
--- /dev/null
+++ b/models/repo/projectbase.go
@@ -0,0 +1,38 @@
+// Copyright 2021 The Gitea Authors. All rights reserved.
+// Use of this source code is governed by a MIT-style
+// license that can be found in the LICENSE file.
+
+package repo
+
+import (
+ "path/filepath"
+ "strings"
+
+ user_model "code.gitea.io/gitea/models/user"
+ "code.gitea.io/gitea/modules/log"
+ "code.gitea.io/gitea/modules/util"
+)
+
+// ProjectBaseCloneLink function
+func (repo *Repository) ProjectBaseCloneLink() *CloneLink {
+ return repo.cloneLink(".projectbase")
+}
+
+// ProjectBasePath function
+func ProjectBasePath(userName, repoName string) string {
+ return filepath.Join(user_model.UserPath(userName), strings.ToLower(repoName)+".projectbase.git")
+}
+
+// ProjectBasePath function
+func (repo *Repository) ProjectBasePath() string {
+ return ProjectBasePath(repo.OwnerName, repo.Name)
+}
+
+// HasProjectBase function
+func (repo *Repository) HasProjectBase() bool {
+ isDir, err := util.IsDir(repo.ProjectBasePath())
+ if err != nil {
+ log.Error("Unable to check if %s is a directory: %v", repo.ProjectBasePath(), err)
+ }
+ return isDir
+}