From a887e475e36bb0a225e05c15d560d6fdb946833e Mon Sep 17 00:00:00 2001 From: Unknwon Date: Sun, 11 Jun 2017 00:43:56 -0400 Subject: [PATCH] repo: change action visibility when repository visibility changed (#4414) --- gogs.go | 2 +- models/action.go | 4 ++-- models/repo.go | 7 ++++++- templates/.VERSION | 2 +- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/gogs.go b/gogs.go index 8549e4317..08f2a9050 100644 --- a/gogs.go +++ b/gogs.go @@ -16,7 +16,7 @@ import ( "github.com/gogits/gogs/pkg/setting" ) -const APP_VER = "0.11.19.0611" +const APP_VER = "0.11.20.0611" func init() { setting.AppVer = APP_VER diff --git a/models/action.go b/models/action.go index 4d2068941..97fd379a3 100644 --- a/models/action.go +++ b/models/action.go @@ -21,8 +21,8 @@ import ( api "github.com/gogits/go-gogs-client" "github.com/gogits/gogs/models/errors" - "github.com/gogits/gogs/pkg/tool" "github.com/gogits/gogs/pkg/setting" + "github.com/gogits/gogs/pkg/tool" ) type ActionType int @@ -78,7 +78,7 @@ type Action struct { ActUserID int64 // Action user id. ActUserName string // Action user name. ActAvatar string `xorm:"-"` - RepoID int64 + RepoID int64 `xorm:"INDEX"` RepoUserName string RepoName string RefName string diff --git a/models/repo.go b/models/repo.go index 7a2ee3fb2..22e15870d 100644 --- a/models/repo.go +++ b/models/repo.go @@ -1369,6 +1369,11 @@ func updateRepository(e Engine, repo *Repository, visibilityChanged bool) (err e return fmt.Errorf("updateRepository[%d]: %v", forkRepos[i].ID, err) } } + + // Change visibility of generated actions + if _, err = e.Where("repo_id = ?", repo.ID).Cols("is_private").Update(&Action{IsPrivate: repo.IsPrivate}); err != nil { + return fmt.Errorf("change action visibility of repository [id: %d]: %v", repo.ID, err) + } } return nil @@ -1376,7 +1381,7 @@ func updateRepository(e Engine, repo *Repository, visibilityChanged bool) (err e func UpdateRepository(repo *Repository, visibilityChanged bool) (err error) { sess := x.NewSession() - defer sessionRelease(sess) + defer sess.Close() if err = sess.Begin(); err != nil { return err } diff --git a/templates/.VERSION b/templates/.VERSION index 82236ad37..e14c9273a 100644 --- a/templates/.VERSION +++ b/templates/.VERSION @@ -1 +1 @@ -0.11.19.0611 \ No newline at end of file +0.11.20.0611 \ No newline at end of file