mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-22 12:54:53 -05:00
merge
This commit is contained in:
commit
9b845c1115
3 changed files with 28 additions and 4 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -4,4 +4,4 @@ gogs
|
||||||
.DS_Store
|
.DS_Store
|
||||||
*.db
|
*.db
|
||||||
*.log
|
*.log
|
||||||
conf/custom.ini
|
custom/
|
|
@ -49,6 +49,7 @@ var (
|
||||||
|
|
||||||
var (
|
var (
|
||||||
ErrRepoAlreadyExist = errors.New("Repository already exist")
|
ErrRepoAlreadyExist = errors.New("Repository already exist")
|
||||||
|
ErrRepoNotExist = errors.New("Repository does not exist")
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
@ -225,6 +226,30 @@ func initRepository(f string, user *User, repo *Repository, initReadme bool, rep
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetRepositoryByName(user *User, repoName string) (*Repository, error) {
|
||||||
|
repo := &Repository{
|
||||||
|
OwnerId: user.Id,
|
||||||
|
LowerName: strings.ToLower(repoName),
|
||||||
|
}
|
||||||
|
has, err := orm.Get(repo)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
} else if !has {
|
||||||
|
return nil, ErrRepoNotExist
|
||||||
|
}
|
||||||
|
return repo, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetRepositoryById(id int64) (repo *Repository, err error) {
|
||||||
|
has, err := orm.Id(id).Get(repo)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
} else if !has {
|
||||||
|
return nil, ErrRepoNotExist
|
||||||
|
}
|
||||||
|
return repo, err
|
||||||
|
}
|
||||||
|
|
||||||
// GetRepositories returns the list of repositories of given user.
|
// GetRepositories returns the list of repositories of given user.
|
||||||
func GetRepositories(user *User) ([]Repository, error) {
|
func GetRepositories(user *User) ([]Repository, error) {
|
||||||
repos := make([]Repository, 0, 10)
|
repos := make([]Repository, 0, 10)
|
||||||
|
|
|
@ -37,15 +37,14 @@ func init() {
|
||||||
os.Exit(2)
|
os.Exit(2)
|
||||||
}
|
}
|
||||||
|
|
||||||
cfgPathPrefix := filepath.Join(workDir, "conf")
|
cfgPath := filepath.Join(workDir, "conf/app.ini")
|
||||||
cfgPath := filepath.Join(cfgPathPrefix, "app.ini")
|
|
||||||
Cfg, err = goconfig.LoadConfigFile(cfgPath)
|
Cfg, err = goconfig.LoadConfigFile(cfgPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("Cannot load config file '%s'\n", cfgPath)
|
fmt.Printf("Cannot load config file '%s'\n", cfgPath)
|
||||||
os.Exit(2)
|
os.Exit(2)
|
||||||
}
|
}
|
||||||
|
|
||||||
cfgPath = filepath.Join(cfgPathPrefix, "custom.ini")
|
cfgPath = filepath.Join(workDir, "custom/conf/app.ini")
|
||||||
if com.IsFile(cfgPath) {
|
if com.IsFile(cfgPath) {
|
||||||
if err = Cfg.AppendFiles(cfgPath); err != nil {
|
if err = Cfg.AppendFiles(cfgPath); err != nil {
|
||||||
fmt.Printf("Cannot load config file '%s'\n", cfgPath)
|
fmt.Printf("Cannot load config file '%s'\n", cfgPath)
|
||||||
|
|
Loading…
Reference in a new issue