diff options
author | Unknown <joe2010xtmf@163.com> | 2014-03-10 20:48:58 -0400 |
---|---|---|
committer | Unknown <joe2010xtmf@163.com> | 2014-03-10 20:48:58 -0400 |
commit | 897329a64416dd46b9e4f5a81c3c7a1666fc1173 (patch) | |
tree | ced28c8cea44742e091a38370414453b6c172ade /models/repo.go | |
parent | efa039a0f75ff9ba9376af1cbd3d948752c074fc (diff) | |
download | gitea-897329a64416dd46b9e4f5a81c3c7a1666fc1173.tar.gz gitea-897329a64416dd46b9e4f5a81c3c7a1666fc1173.zip |
Add add and delete SSH key
Diffstat (limited to 'models/repo.go')
-rw-r--r-- | models/repo.go | 21 |
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) |