summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorevolvedlight <steve@evolvedlight.co.uk>2014-10-13 20:23:30 +0100
committerevolvedlight <steve@evolvedlight.co.uk>2014-10-13 20:23:30 +0100
commit29ac3980ffdb5faa525d77fddc109c9023ebe257 (patch)
treea363cdb92b6361f6182147c0661bd20048ed9d2b /models
parent211dc74816c3832f973284f19ad0831da039ac76 (diff)
downloadgitea-29ac3980ffdb5faa525d77fddc109c9023ebe257.tar.gz
gitea-29ac3980ffdb5faa525d77fddc109c9023ebe257.zip
More changes
Diffstat (limited to 'models')
-rw-r--r--models/repo.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/models/repo.go b/models/repo.go
index 2019542102..0ca8b305ea 100644
--- a/models/repo.go
+++ b/models/repo.go
@@ -178,6 +178,10 @@ func (repo *Repository) GetPath() string {
return RepoPath(repo.Owner.Name, repo.Name)
}
+func (repo *Repository) IsOwnedBy(u *User) bool {
+ return repo.OwnerId == u.Id
+}
+
// DescriptionHtml does special handles to description and return HTML string.
func (repo *Repository) DescriptionHtml() template.HTML {
sanitize := func(s string) string {
@@ -932,6 +936,13 @@ func DeleteRepository(uid, repoId int64, userName string) error {
sess.Rollback()
return err
}
+
+ if repo.IsFork {
+ if _, err = sess.Exec("UPDATE `repository` SET num_forks = num_forks - 1 WHERE id = ?", repo.ForkId); err != nil {
+ sess.Rollback()
+ return err
+ }
+ }
if _, err = sess.Exec("UPDATE `user` SET num_repos = num_repos - 1 WHERE id = ?", uid); err != nil {
sess.Rollback()
@@ -1249,6 +1260,8 @@ func ForkRepository(u *User, oldRepo *Repository) (*Repository, error) {
LowerName: oldRepo.LowerName,
Description: oldRepo.Description,
IsPrivate: oldRepo.IsPrivate,
+ IsFork: true,
+ ForkId: oldRepo.Id,
}
if _, err = sess.Insert(repo); err != nil {