]> source.dussan.org Git - gitea.git/commitdiff
More changes
authorevolvedlight <steve@evolvedlight.co.uk>
Mon, 13 Oct 2014 19:23:30 +0000 (20:23 +0100)
committerevolvedlight <steve@evolvedlight.co.uk>
Mon, 13 Oct 2014 19:23:30 +0000 (20:23 +0100)
models/repo.go
templates/repo/header.tmpl

index 2019542102d9e14d30b1bc1dc9ecd3111f1adc32..0ca8b305eab53aa1d4ccf8d0e331b8e73ba80a92 100644 (file)
@@ -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 {
index f0ebae5e6d059e1b2c75e8c3336294a86bdfa20c..884910d1c52dd5c9b942d687356cdff421af1c40 100644 (file)
                 </a>
             </li>
             <li id="repo-header-fork">
-                <a id="repo-header-fork-btn" href="{{.RepoLink}}/action/fork">
+                <a id="repo-header-fork-btn" {{if not .IsRepositoryOwner}} href="{{.RepoLink}}/action/fork"{{end}}>
                     <button class="btn btn-gray text-bold btn-radius">
                         <i class="octicon octicon-repo-forked"></i>{{.i18n.Tr "repo.fork"}}
                         <span class="num">{{.Repository.NumForks}}</span>
                     </button>
                 </a>
+            
             </li>
         </ul>
     </div>