From f165e89a8daf3f247e869344ddc09723d823b920 Mon Sep 17 00:00:00 2001 From: Naoki Takezoe Date: Fri, 17 Mar 2017 21:38:21 +0900 Subject: [PATCH] (refs #1498) Fix record inserting and deletion of repository related tables --- src/main/scala/gitbucket/core/model/DeployKey.scala | 6 ++---- .../scala/gitbucket/core/service/RepositoryService.scala | 8 +++----- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/main/scala/gitbucket/core/model/DeployKey.scala b/src/main/scala/gitbucket/core/model/DeployKey.scala index 4f34e45a0..71b80a211 100644 --- a/src/main/scala/gitbucket/core/model/DeployKey.scala +++ b/src/main/scala/gitbucket/core/model/DeployKey.scala @@ -1,13 +1,11 @@ package gitbucket.core.model -trait DeployKeyComponent { self: Profile => +trait DeployKeyComponent extends TemplateComponent { self: Profile => import profile.api._ lazy val DeployKeys = TableQuery[DeployKeys] - class DeployKeys(tag: Tag) extends Table[DeployKey](tag, "DEPLOY_KEY") { - val userName = column[String]("USER_NAME") - val repositoryName = column[String]("REPOSITORY_NAME") + class DeployKeys(tag: Tag) extends Table[DeployKey](tag, "DEPLOY_KEY") with BasicTemplate { val deployKeyId = column[Int]("DEPLOY_KEY_ID", O AutoInc) val title = column[String]("TITLE") val publicKey = column[String]("PUBLIC_KEY") diff --git a/src/main/scala/gitbucket/core/service/RepositoryService.scala b/src/main/scala/gitbucket/core/service/RepositoryService.scala index 9b5a1bf2c..3640f1c68 100644 --- a/src/main/scala/gitbucket/core/service/RepositoryService.scala +++ b/src/main/scala/gitbucket/core/service/RepositoryService.scala @@ -73,6 +73,7 @@ trait RepositoryService { self: AccountService => val collaborators = Collaborators .filter(_.byRepository(oldUserName, oldRepositoryName)).list val protectedBranches = ProtectedBranches .filter(_.byRepository(oldUserName, oldRepositoryName)).list val protectedBranchContexts = ProtectedBranchContexts.filter(_.byRepository(oldUserName, oldRepositoryName)).list + val deployKeys = DeployKeys .filter(_.byRepository(oldUserName, oldRepositoryName)).list Repositories.filter { t => (t.originUserName === oldUserName.bind) && (t.originRepositoryName === oldRepositoryName.bind) @@ -112,6 +113,7 @@ trait RepositoryService { self: AccountService => CommitStatuses .insertAll(commitStatuses.map(_.copy(userName = newUserName, repositoryName = newRepositoryName)) :_*) ProtectedBranches .insertAll(protectedBranches.map(_.copy(userName = newUserName, repositoryName = newRepositoryName)) :_*) ProtectedBranchContexts.insertAll(protectedBranchContexts.map(_.copy(userName = newUserName, repositoryName = newRepositoryName)) :_*) + DeployKeys .insertAll(deployKeys .map(_.copy(userName = newUserName, repositoryName = newRepositoryName)) :_*) // Update source repository of pull requests PullRequests.filter { t => @@ -126,11 +128,6 @@ trait RepositoryService { self: AccountService => userName = newUserName, repositoryName = newRepositoryName )) :_*) - IssueLabels.insertAll(issueLabels.map(x => x.copy( - labelId = newLabelMap(oldLabelMap(x.labelId)), - userName = newUserName, - repositoryName = newRepositoryName - )) :_*) // TODO Drop transfered owner from collaborators? Collaborators.insertAll(collaborators.map(_.copy(userName = newUserName, repositoryName = newRepositoryName)) :_*) @@ -168,6 +165,7 @@ trait RepositoryService { self: AccountService => Milestones .filter(_.byRepository(userName, repositoryName)).delete WebHooks .filter(_.byRepository(userName, repositoryName)).delete WebHookEvents .filter(_.byRepository(userName, repositoryName)).delete + DeployKeys .filter(_.byRepository(userName, repositoryName)).delete Repositories .filter(_.byRepository(userName, repositoryName)).delete // Update ORIGIN_USER_NAME and ORIGIN_REPOSITORY_NAME