From c9e5e38fcfa759a1d2578d1c7a56ac0e65e2bf78 Mon Sep 17 00:00:00 2001 From: evolvedlight Date: Sat, 4 Oct 2014 18:19:14 +0100 Subject: Initial cut of git fork --- templates/repo/diff.tmpl | 2 ++ templates/repo/header.tmpl | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'templates') diff --git a/templates/repo/diff.tmpl b/templates/repo/diff.tmpl index 8e5efd146f..fa97073c6e 100644 --- a/templates/repo/diff.tmpl +++ b/templates/repo/diff.tmpl @@ -96,6 +96,7 @@ {{range .Sections}} + Test: {{ .NumLines}} {{range .Lines}} + diff --git a/templates/repo/header.tmpl b/templates/repo/header.tmpl index 699e90461e..f0ebae5e6d 100644 --- a/templates/repo/header.tmpl +++ b/templates/repo/header.tmpl @@ -44,14 +44,14 @@ - + \ No newline at end of file -- cgit v1.2.3 From 29ac3980ffdb5faa525d77fddc109c9023ebe257 Mon Sep 17 00:00:00 2001 From: evolvedlight Date: Mon, 13 Oct 2014 20:23:30 +0100 Subject: More changes --- models/repo.go | 13 +++++++++++++ templates/repo/header.tmpl | 3 ++- 2 files changed, 15 insertions(+), 1 deletion(-) (limited to 'templates') 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 { diff --git a/templates/repo/header.tmpl b/templates/repo/header.tmpl index f0ebae5e6d..884910d1c5 100644 --- a/templates/repo/header.tmpl +++ b/templates/repo/header.tmpl @@ -45,12 +45,13 @@
  • - + +
  • -- cgit v1.2.3
    @@ -104,6 +105,7 @@ {{if .RightIdx}}{{.RightIdx}}{{end}}
    {{ToUtf8 .Content}}