More changes
This commit is contained in:
		
							parent
							
								
									211dc74816
								
							
						
					
					
						commit
						29ac3980ff
					
				| 
						 | 
				
			
			@ -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 {
 | 
			
		||||
| 
						 | 
				
			
			@ -933,6 +937,13 @@ func DeleteRepository(uid, repoId int64, userName string) error {
 | 
			
		|||
		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()
 | 
			
		||||
		return err
 | 
			
		||||
| 
						 | 
				
			
			@ -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 {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -45,12 +45,13 @@
 | 
			
		|||
                </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>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue