summaryrefslogtreecommitdiffstats
path: root/models/repo.go
diff options
context:
space:
mode:
Diffstat (limited to 'models/repo.go')
-rw-r--r--models/repo.go21
1 files changed, 17 insertions, 4 deletions
diff --git a/models/repo.go b/models/repo.go
index 05612a4229..d17f32976a 100644
--- a/models/repo.go
+++ b/models/repo.go
@@ -6,6 +6,7 @@ package models
import (
"errors"
+ "fmt"
"os"
"path/filepath"
"strings"
@@ -83,7 +84,8 @@ func CreateRepository(user *User, repoName, desc string, private bool) (*Reposit
if _, err = session.Insert(repo); err != nil {
if err2 := os.RemoveAll(f); err2 != nil {
- log.Error("delete repo directory %s/%s failed", user.Name, repoName)
+ return nil, errors.New(fmt.Sprintf(
+ "delete repo directory %s/%s failed", user.Name, repoName))
}
session.Rollback()
return nil, err
@@ -97,7 +99,8 @@ func CreateRepository(user *User, repoName, desc string, private bool) (*Reposit
}
if _, err = session.Insert(&access); err != nil {
if err2 := os.RemoveAll(f); err2 != nil {
- log.Error("delete repo directory %s/%s failed", user.Name, repoName)
+ return nil, errors.New(fmt.Sprintf(
+ "delete repo directory %s/%s failed", user.Name, repoName))
}
session.Rollback()
return nil, err
@@ -105,7 +108,8 @@ func CreateRepository(user *User, repoName, desc string, private bool) (*Reposit
if _, err = session.Exec("update user set num_repos = num_repos + 1 where id = ?", user.Id); err != nil {
if err2 := os.RemoveAll(f); err2 != nil {
- log.Error("delete repo directory %s/%s failed", user.Name, repoName)
+ return nil, errors.New(fmt.Sprintf(
+ "delete repo directory %s/%s failed", user.Name, repoName))
}
session.Rollback()
return nil, err
@@ -113,7 +117,8 @@ func CreateRepository(user *User, repoName, desc string, private bool) (*Reposit
if err = session.Commit(); err != nil {
if err2 := os.RemoveAll(f); err2 != nil {
- log.Error("delete repo directory %s/%s failed", user.Name, repoName)
+ return nil, errors.New(fmt.Sprintf(
+ "delete repo directory %s/%s failed", user.Name, repoName))
}
session.Rollback()
return nil, err
@@ -121,6 +126,14 @@ func CreateRepository(user *User, repoName, desc string, private bool) (*Reposit
return repo, nil
}
+// InitRepository initializes README and .gitignore if needed.
+func InitRepository(repo *Repository, initReadme bool, repoLang string) error {
+ // README.
+
+ // .gitignore
+ return nil
+}
+
// GetRepositories returns the list of repositories of given user.
func GetRepositories(user *User) ([]Repository, error) {
repos := make([]Repository, 0, 10)