aboutsummaryrefslogtreecommitdiff
path: root/models/repo/projectbase.go
blob: ac5317dcbba7127fdf4479657e568b0a036eb9a1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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
}