From c2068f58e7bbc5d453542bb98fb3aa3d5c482001 Mon Sep 17 00:00:00 2001 From: xuwei-k <6b656e6a69@gmail.com> Date: Mon, 17 Jun 2024 14:54:33 +0900 Subject: [PATCH] prepare Scala 3 --- .../core/controller/AccountController.scala | 18 +++---------- .../core/controller/DashboardController.scala | 8 ++---- .../core/controller/IndexController.scala | 11 ++------ .../core/controller/IssuesController.scala | 19 +++---------- .../core/controller/LabelsController.scala | 6 +---- .../controller/MilestonesController.scala | 7 ++--- .../controller/PrioritiesController.scala | 6 +---- .../controller/PullRequestsController.scala | 27 +++++-------------- .../core/controller/ReleasesController.scala | 9 ++----- .../RepositorySettingsController.scala | 12 ++------- .../RepositoryViewerController.scala | 19 +++---------- .../controller/SystemSettingsController.scala | 2 +- .../core/controller/ValidationSupport.scala | 2 +- .../core/controller/WikiController.scala | 9 ++----- .../api/ApiGitReferenceControllerBase.scala | 2 +- .../api/ApiIssueCommentControllerBase.scala | 9 ++----- .../api/ApiIssueControllerBase.scala | 8 ++---- .../api/ApiIssueLabelControllerBase.scala | 6 +---- .../api/ApiIssueMilestoneControllerBase.scala | 2 +- .../api/ApiOrganizationControllerBase.scala | 2 +- .../api/ApiPullRequestControllerBase.scala | 10 ++----- .../api/ApiReleaseControllerBase.scala | 2 +- .../ApiRepositoryBranchControllerBase.scala | 11 ++------ ...RepositoryCollaboratorControllerBase.scala | 2 +- .../ApiRepositoryCommitControllerBase.scala | 2 +- .../ApiRepositoryContentsControllerBase.scala | 2 +- .../api/ApiRepositoryControllerBase.scala | 13 +++------ .../ApiRepositoryStatusControllerBase.scala | 2 +- .../ApiRepositoryWebhookControllerBase.scala | 2 +- .../api/ApiUserControllerBase.scala | 2 +- .../core/service/CommitsService.scala | 2 +- .../core/service/HandleCommentService.scala | 8 ++---- .../core/service/IssueCreationService.scala | 2 +- .../core/service/IssuesService.scala | 2 +- .../gitbucket/core/service/MergeService.scala | 9 ++----- .../core/service/PullRequestService.scala | 9 ++----- .../core/service/ReleaseService.scala | 2 +- .../service/RepositoryCommitFileService.scala | 8 ++---- .../service/RepositoryCreationService.scala | 7 +---- .../core/service/WebHookService.scala | 6 ++--- .../scala/gitbucket/core/ssh/GitCommand.scala | 2 +- .../gitbucket/core/util/Authenticator.scala | 10 +++---- 42 files changed, 78 insertions(+), 221 deletions(-) diff --git a/src/main/scala/gitbucket/core/controller/AccountController.scala b/src/main/scala/gitbucket/core/controller/AccountController.scala index c4b289550..0857f04e5 100644 --- a/src/main/scala/gitbucket/core/controller/AccountController.scala +++ b/src/main/scala/gitbucket/core/controller/AccountController.scala @@ -38,21 +38,9 @@ class AccountController with RequestCache trait AccountControllerBase extends AccountManagementControllerBase { - self: AccountService - with RepositoryService - with ActivityService - with WikiService - with LabelsService - with SshKeyService - with GpgKeyService - with OneselfAuthenticator - with UsersAuthenticator - with GroupManagerAuthenticator - with ReadableUsersAuthenticator - with AccessTokenService - with WebHookService - with PrioritiesService - with RepositoryCreationService => + self: AccountService & RepositoryService & ActivityService & WikiService & LabelsService & SshKeyService & + GpgKeyService & OneselfAuthenticator & UsersAuthenticator & GroupManagerAuthenticator & ReadableUsersAuthenticator & + AccessTokenService & WebHookService & PrioritiesService & RepositoryCreationService => case class AccountNewForm( userName: String, diff --git a/src/main/scala/gitbucket/core/controller/DashboardController.scala b/src/main/scala/gitbucket/core/controller/DashboardController.scala index 898ae7b3c..728a8000a 100644 --- a/src/main/scala/gitbucket/core/controller/DashboardController.scala +++ b/src/main/scala/gitbucket/core/controller/DashboardController.scala @@ -28,12 +28,8 @@ class DashboardController with RequestCache trait DashboardControllerBase extends ControllerBase { - self: IssuesService - with PullRequestService - with RepositoryService - with AccountService - with CommitStatusService - with UsersAuthenticator => + self: IssuesService & PullRequestService & RepositoryService & AccountService & CommitStatusService & + UsersAuthenticator => get("/dashboard/repos")(usersOnly { context.withLoginAccount { loginAccount => diff --git a/src/main/scala/gitbucket/core/controller/IndexController.scala b/src/main/scala/gitbucket/core/controller/IndexController.scala index 5b7ddb1ef..73a16f561 100644 --- a/src/main/scala/gitbucket/core/controller/IndexController.scala +++ b/src/main/scala/gitbucket/core/controller/IndexController.scala @@ -34,15 +34,8 @@ class IndexController with RequestCache trait IndexControllerBase extends ControllerBase { - self: RepositoryService - with ActivityService - with AccountService - with RepositorySearchService - with UsersAuthenticator - with ReferrerAuthenticator - with AccessTokenService - with AccountFederationService - with OpenIDConnectService => + self: RepositoryService & ActivityService & AccountService & RepositorySearchService & UsersAuthenticator & + ReferrerAuthenticator & AccessTokenService & AccountFederationService & OpenIDConnectService => case class SignInForm(userName: String, password: String, hash: Option[String]) diff --git a/src/main/scala/gitbucket/core/controller/IssuesController.scala b/src/main/scala/gitbucket/core/controller/IssuesController.scala index 4e96b81bf..a6a005664 100644 --- a/src/main/scala/gitbucket/core/controller/IssuesController.scala +++ b/src/main/scala/gitbucket/core/controller/IssuesController.scala @@ -34,21 +34,10 @@ class IssuesController with RequestCache trait IssuesControllerBase extends ControllerBase { - self: IssuesService - with RepositoryService - with AccountService - with LabelsService - with MilestonesService - with ActivityService - with HandleCommentService - with IssueCreationService - with CustomFieldsService - with ReadableUsersAuthenticator - with ReferrerAuthenticator - with WritableUsersAuthenticator - with PullRequestService - with WebHookIssueCommentService - with PrioritiesService => + self: IssuesService & RepositoryService & AccountService & LabelsService & MilestonesService & ActivityService & + HandleCommentService & IssueCreationService & CustomFieldsService & ReadableUsersAuthenticator & + ReferrerAuthenticator & WritableUsersAuthenticator & PullRequestService & WebHookIssueCommentService & + PrioritiesService => case class IssueCreateForm( title: String, diff --git a/src/main/scala/gitbucket/core/controller/LabelsController.scala b/src/main/scala/gitbucket/core/controller/LabelsController.scala index 570153810..55ae89646 100644 --- a/src/main/scala/gitbucket/core/controller/LabelsController.scala +++ b/src/main/scala/gitbucket/core/controller/LabelsController.scala @@ -28,11 +28,7 @@ class LabelsController with WritableUsersAuthenticator trait LabelsControllerBase extends ControllerBase { - self: LabelsService - with IssuesService - with RepositoryService - with ReferrerAuthenticator - with WritableUsersAuthenticator => + self: LabelsService & IssuesService & RepositoryService & ReferrerAuthenticator & WritableUsersAuthenticator => case class LabelForm(labelName: String, color: String) diff --git a/src/main/scala/gitbucket/core/controller/MilestonesController.scala b/src/main/scala/gitbucket/core/controller/MilestonesController.scala index ceaae310c..ae82ff2dd 100644 --- a/src/main/scala/gitbucket/core/controller/MilestonesController.scala +++ b/src/main/scala/gitbucket/core/controller/MilestonesController.scala @@ -26,11 +26,8 @@ class MilestonesController with WritableUsersAuthenticator trait MilestonesControllerBase extends ControllerBase { - self: MilestonesService - with RepositoryService - with CommitStatusService - with ReferrerAuthenticator - with WritableUsersAuthenticator => + self: MilestonesService & RepositoryService & CommitStatusService & ReferrerAuthenticator & + WritableUsersAuthenticator => case class MilestoneForm(title: String, description: Option[String], dueDate: Option[java.util.Date]) diff --git a/src/main/scala/gitbucket/core/controller/PrioritiesController.scala b/src/main/scala/gitbucket/core/controller/PrioritiesController.scala index 6231863fc..d4f9475fc 100644 --- a/src/main/scala/gitbucket/core/controller/PrioritiesController.scala +++ b/src/main/scala/gitbucket/core/controller/PrioritiesController.scala @@ -28,11 +28,7 @@ class PrioritiesController with WritableUsersAuthenticator trait PrioritiesControllerBase extends ControllerBase { - self: PrioritiesService - with IssuesService - with RepositoryService - with ReferrerAuthenticator - with WritableUsersAuthenticator => + self: PrioritiesService & IssuesService & RepositoryService & ReferrerAuthenticator & WritableUsersAuthenticator => case class PriorityForm(priorityName: String, description: Option[String], color: String) diff --git a/src/main/scala/gitbucket/core/controller/PullRequestsController.scala b/src/main/scala/gitbucket/core/controller/PullRequestsController.scala index 5fd39ed9a..04dee173a 100644 --- a/src/main/scala/gitbucket/core/controller/PullRequestsController.scala +++ b/src/main/scala/gitbucket/core/controller/PullRequestsController.scala @@ -40,23 +40,10 @@ class PullRequestsController with RequestCache trait PullRequestsControllerBase extends ControllerBase { - self: RepositoryService - with AccountService - with IssuesService - with MilestonesService - with LabelsService - with CustomFieldsService - with CommitsService - with ActivityService - with PullRequestService - with WebHookPullRequestService - with ReadableUsersAuthenticator - with ReferrerAuthenticator - with WritableUsersAuthenticator - with CommitStatusService - with MergeService - with ProtectedBranchService - with PrioritiesService => + self: RepositoryService & AccountService & IssuesService & MilestonesService & LabelsService & CustomFieldsService & + CommitsService & ActivityService & PullRequestService & WebHookPullRequestService & ReadableUsersAuthenticator & + ReferrerAuthenticator & WritableUsersAuthenticator & CommitStatusService & MergeService & ProtectedBranchService & + PrioritiesService => val pullRequestForm = mapping( "title" -> trim(label("Title", text(required))), @@ -569,7 +556,7 @@ trait PullRequestsControllerBase extends ControllerBase { val (originOwner, tmpOriginBranch) = parseCompareIdentifier(origin, forkedRepository.owner) val (forkedOwner, tmpForkedBranch) = parseCompareIdentifier(forked, forkedRepository.owner) - (for ( + (for { originRepositoryName <- if (originOwner == forkedOwner) { Some(forkedRepository.name) @@ -579,9 +566,9 @@ trait PullRequestsControllerBase extends ControllerBase { .find(_.userName == originOwner) .map(_.repositoryName) } - }; + } originRepository <- getRepository(originOwner, originRepositoryName) - ) yield { + } yield { Using.resources( Git.open(getRepositoryDir(originRepository.owner, originRepository.name)), Git.open(getRepositoryDir(forkedRepository.owner, forkedRepository.name)) diff --git a/src/main/scala/gitbucket/core/controller/ReleasesController.scala b/src/main/scala/gitbucket/core/controller/ReleasesController.scala index 252ed71b5..f572bc2bc 100644 --- a/src/main/scala/gitbucket/core/controller/ReleasesController.scala +++ b/src/main/scala/gitbucket/core/controller/ReleasesController.scala @@ -33,13 +33,8 @@ class ReleaseController with RequestCache trait ReleaseControllerBase extends ControllerBase { - self: RepositoryService - with AccountService - with ReleaseService - with ReadableUsersAuthenticator - with ReferrerAuthenticator - with WritableUsersAuthenticator - with ActivityService => + self: RepositoryService & AccountService & ReleaseService & ReadableUsersAuthenticator & ReferrerAuthenticator & + WritableUsersAuthenticator & ActivityService => case class ReleaseForm( name: String, diff --git a/src/main/scala/gitbucket/core/controller/RepositorySettingsController.scala b/src/main/scala/gitbucket/core/controller/RepositorySettingsController.scala index 1b2337900..808bf4455 100644 --- a/src/main/scala/gitbucket/core/controller/RepositorySettingsController.scala +++ b/src/main/scala/gitbucket/core/controller/RepositorySettingsController.scala @@ -37,16 +37,8 @@ class RepositorySettingsController with RequestCache trait RepositorySettingsControllerBase extends ControllerBase { - self: RepositoryService - with AccountService - with WebHookService - with ProtectedBranchService - with CommitStatusService - with DeployKeyService - with CustomFieldsService - with ActivityService - with OwnerAuthenticator - with UsersAuthenticator => + self: RepositoryService & AccountService & WebHookService & ProtectedBranchService & CommitStatusService & + DeployKeyService & CustomFieldsService & ActivityService & OwnerAuthenticator & UsersAuthenticator => // for repository options case class OptionsForm( diff --git a/src/main/scala/gitbucket/core/controller/RepositoryViewerController.scala b/src/main/scala/gitbucket/core/controller/RepositoryViewerController.scala index 1dab85760..3cf7e8bfe 100644 --- a/src/main/scala/gitbucket/core/controller/RepositoryViewerController.scala +++ b/src/main/scala/gitbucket/core/controller/RepositoryViewerController.scala @@ -65,21 +65,10 @@ class RepositoryViewerController * The repository viewer. */ trait RepositoryViewerControllerBase extends ControllerBase { - self: RepositoryService - with RepositoryCommitFileService - with AccountService - with ActivityService - with IssuesService - with WebHookService - with CommitsService - with ReadableUsersAuthenticator - with ReferrerAuthenticator - with WritableUsersAuthenticator - with PullRequestService - with CommitStatusService - with WebHookPullRequestService - with WebHookPullRequestReviewCommentService - with ProtectedBranchService => + self: RepositoryService & RepositoryCommitFileService & AccountService & ActivityService & IssuesService & + WebHookService & CommitsService & ReadableUsersAuthenticator & ReferrerAuthenticator & WritableUsersAuthenticator & + PullRequestService & CommitStatusService & WebHookPullRequestService & WebHookPullRequestReviewCommentService & + ProtectedBranchService => ArchiveCommand.registerFormat("zip", new ZipFormat) ArchiveCommand.registerFormat("tar.gz", new TgzFormat) diff --git a/src/main/scala/gitbucket/core/controller/SystemSettingsController.scala b/src/main/scala/gitbucket/core/controller/SystemSettingsController.scala index e75714d97..4835e5c61 100644 --- a/src/main/scala/gitbucket/core/controller/SystemSettingsController.scala +++ b/src/main/scala/gitbucket/core/controller/SystemSettingsController.scala @@ -29,7 +29,7 @@ case class Table(name: String, columns: Seq[Column]) case class Column(name: String, primaryKey: Boolean) trait SystemSettingsControllerBase extends AccountManagementControllerBase { - self: AccountService with RepositoryService with AdminAuthenticator => + self: AccountService & RepositoryService & AdminAuthenticator => private val form = mapping( "baseUrl" -> trim(label("Base URL", optional(text()))), diff --git a/src/main/scala/gitbucket/core/controller/ValidationSupport.scala b/src/main/scala/gitbucket/core/controller/ValidationSupport.scala index 4ab83369c..1e7e7f285 100644 --- a/src/main/scala/gitbucket/core/controller/ValidationSupport.scala +++ b/src/main/scala/gitbucket/core/controller/ValidationSupport.scala @@ -10,7 +10,7 @@ import org.scalatra.servlet.ServletBase /** * Extends scalatra-forms to support the client-side validation and Ajax requests as well. */ -trait ValidationSupport extends FormSupport { self: ServletBase with JacksonJsonSupport with I18nSupport => +trait ValidationSupport extends FormSupport { self: ServletBase & JacksonJsonSupport & I18nSupport => def get[T](path: String, form: ValueType[T])(action: T => Any): Route = { registerValidate(path, form) diff --git a/src/main/scala/gitbucket/core/controller/WikiController.scala b/src/main/scala/gitbucket/core/controller/WikiController.scala index de1e0971e..028691e5e 100644 --- a/src/main/scala/gitbucket/core/controller/WikiController.scala +++ b/src/main/scala/gitbucket/core/controller/WikiController.scala @@ -29,13 +29,8 @@ class WikiController with RequestCache trait WikiControllerBase extends ControllerBase { - self: WikiService - with RepositoryService - with AccountService - with ActivityService - with WebHookService - with ReadableUsersAuthenticator - with ReferrerAuthenticator => + self: WikiService & RepositoryService & AccountService & ActivityService & WebHookService & + ReadableUsersAuthenticator & ReferrerAuthenticator => case class WikiPageEditForm( pageName: String, diff --git a/src/main/scala/gitbucket/core/controller/api/ApiGitReferenceControllerBase.scala b/src/main/scala/gitbucket/core/controller/api/ApiGitReferenceControllerBase.scala index af368b2fb..fef3b49af 100644 --- a/src/main/scala/gitbucket/core/controller/api/ApiGitReferenceControllerBase.scala +++ b/src/main/scala/gitbucket/core/controller/api/ApiGitReferenceControllerBase.scala @@ -15,7 +15,7 @@ import scala.jdk.CollectionConverters._ import scala.util.Using trait ApiGitReferenceControllerBase extends ControllerBase { - self: ReferrerAuthenticator with WritableUsersAuthenticator => + self: ReferrerAuthenticator & WritableUsersAuthenticator => private val logger = LoggerFactory.getLogger(classOf[ApiGitReferenceControllerBase]) diff --git a/src/main/scala/gitbucket/core/controller/api/ApiIssueCommentControllerBase.scala b/src/main/scala/gitbucket/core/controller/api/ApiIssueCommentControllerBase.scala index 965992990..3e8892e69 100644 --- a/src/main/scala/gitbucket/core/controller/api/ApiIssueCommentControllerBase.scala +++ b/src/main/scala/gitbucket/core/controller/api/ApiIssueCommentControllerBase.scala @@ -7,13 +7,8 @@ import gitbucket.core.util.{ReadableUsersAuthenticator, ReferrerAuthenticator, R import org.scalatra.ActionResult trait ApiIssueCommentControllerBase extends ControllerBase { - self: AccountService - with IssuesService - with RepositoryService - with HandleCommentService - with MilestonesService - with ReadableUsersAuthenticator - with ReferrerAuthenticator => + self: AccountService & IssuesService & RepositoryService & HandleCommentService & MilestonesService & + ReadableUsersAuthenticator & ReferrerAuthenticator => /* * i. List issue comments for a repository * https://docs.github.com/en/rest/reference/issues#list-issue-comments-for-a-repository diff --git a/src/main/scala/gitbucket/core/controller/api/ApiIssueControllerBase.scala b/src/main/scala/gitbucket/core/controller/api/ApiIssueControllerBase.scala index c22e4bc87..599547dae 100644 --- a/src/main/scala/gitbucket/core/controller/api/ApiIssueControllerBase.scala +++ b/src/main/scala/gitbucket/core/controller/api/ApiIssueControllerBase.scala @@ -9,12 +9,8 @@ import gitbucket.core.util.{ReadableUsersAuthenticator, ReferrerAuthenticator, R import gitbucket.core.util.Implicits._ trait ApiIssueControllerBase extends ControllerBase { - self: AccountService - with IssuesService - with IssueCreationService - with MilestonesService - with ReadableUsersAuthenticator - with ReferrerAuthenticator => + self: AccountService & IssuesService & IssueCreationService & MilestonesService & ReadableUsersAuthenticator & + ReferrerAuthenticator => /* * i. List issues * https://developer.github.com/v3/issues/#list-issues diff --git a/src/main/scala/gitbucket/core/controller/api/ApiIssueLabelControllerBase.scala b/src/main/scala/gitbucket/core/controller/api/ApiIssueLabelControllerBase.scala index a4b45db46..daa6fb0e3 100644 --- a/src/main/scala/gitbucket/core/controller/api/ApiIssueLabelControllerBase.scala +++ b/src/main/scala/gitbucket/core/controller/api/ApiIssueLabelControllerBase.scala @@ -7,11 +7,7 @@ import gitbucket.core.util._ import org.scalatra.{Created, NoContent, UnprocessableEntity} trait ApiIssueLabelControllerBase extends ControllerBase { - self: AccountService - with IssuesService - with LabelsService - with ReferrerAuthenticator - with WritableUsersAuthenticator => + self: AccountService & IssuesService & LabelsService & ReferrerAuthenticator & WritableUsersAuthenticator => /* * i. List all labels for this repository diff --git a/src/main/scala/gitbucket/core/controller/api/ApiIssueMilestoneControllerBase.scala b/src/main/scala/gitbucket/core/controller/api/ApiIssueMilestoneControllerBase.scala index 9b552389a..ddad86aae 100644 --- a/src/main/scala/gitbucket/core/controller/api/ApiIssueMilestoneControllerBase.scala +++ b/src/main/scala/gitbucket/core/controller/api/ApiIssueMilestoneControllerBase.scala @@ -7,7 +7,7 @@ import gitbucket.core.util.Implicits._ import org.scalatra.NoContent trait ApiIssueMilestoneControllerBase extends ControllerBase { - self: MilestonesService with WritableUsersAuthenticator with ReferrerAuthenticator => + self: MilestonesService & WritableUsersAuthenticator & ReferrerAuthenticator => /* * i. List milestones diff --git a/src/main/scala/gitbucket/core/controller/api/ApiOrganizationControllerBase.scala b/src/main/scala/gitbucket/core/controller/api/ApiOrganizationControllerBase.scala index b5545ed5b..645358043 100644 --- a/src/main/scala/gitbucket/core/controller/api/ApiOrganizationControllerBase.scala +++ b/src/main/scala/gitbucket/core/controller/api/ApiOrganizationControllerBase.scala @@ -6,7 +6,7 @@ import gitbucket.core.util.Implicits._ import gitbucket.core.util.{AdminAuthenticator, UsersAuthenticator} trait ApiOrganizationControllerBase extends ControllerBase { - self: RepositoryService with AccountService with AdminAuthenticator with UsersAuthenticator => + self: RepositoryService & AccountService & AdminAuthenticator & UsersAuthenticator => /* * i. List your organizations diff --git a/src/main/scala/gitbucket/core/controller/api/ApiPullRequestControllerBase.scala b/src/main/scala/gitbucket/core/controller/api/ApiPullRequestControllerBase.scala index 550a53a3c..f2529bb2a 100644 --- a/src/main/scala/gitbucket/core/controller/api/ApiPullRequestControllerBase.scala +++ b/src/main/scala/gitbucket/core/controller/api/ApiPullRequestControllerBase.scala @@ -16,14 +16,8 @@ import scala.util.Using import scala.jdk.CollectionConverters._ trait ApiPullRequestControllerBase extends ControllerBase { - self: AccountService - with IssuesService - with PullRequestService - with RepositoryService - with MergeService - with ReferrerAuthenticator - with ReadableUsersAuthenticator - with WritableUsersAuthenticator => + self: AccountService & IssuesService & PullRequestService & RepositoryService & MergeService & ReferrerAuthenticator & + ReadableUsersAuthenticator & WritableUsersAuthenticator => /* * i. Link Relations diff --git a/src/main/scala/gitbucket/core/controller/api/ApiReleaseControllerBase.scala b/src/main/scala/gitbucket/core/controller/api/ApiReleaseControllerBase.scala index e040ef07b..93e7f1327 100644 --- a/src/main/scala/gitbucket/core/controller/api/ApiReleaseControllerBase.scala +++ b/src/main/scala/gitbucket/core/controller/api/ApiReleaseControllerBase.scala @@ -11,7 +11,7 @@ import org.apache.commons.io.FileUtils import org.scalatra.NoContent trait ApiReleaseControllerBase extends ControllerBase { - self: AccountService with ReleaseService with ReferrerAuthenticator with WritableUsersAuthenticator => + self: AccountService & ReleaseService & ReferrerAuthenticator & WritableUsersAuthenticator => /** * i. List releases for a repository diff --git a/src/main/scala/gitbucket/core/controller/api/ApiRepositoryBranchControllerBase.scala b/src/main/scala/gitbucket/core/controller/api/ApiRepositoryBranchControllerBase.scala index 6ec5635f7..82d489960 100644 --- a/src/main/scala/gitbucket/core/controller/api/ApiRepositoryBranchControllerBase.scala +++ b/src/main/scala/gitbucket/core/controller/api/ApiRepositoryBranchControllerBase.scala @@ -12,15 +12,8 @@ import org.scalatra.NoContent import scala.util.Using trait ApiRepositoryBranchControllerBase extends ControllerBase { - self: RepositoryService - with AccountService - with OwnerAuthenticator - with UsersAuthenticator - with GroupManagerAuthenticator - with ProtectedBranchService - with ReferrerAuthenticator - with ReadableUsersAuthenticator - with WritableUsersAuthenticator => + self: RepositoryService & AccountService & OwnerAuthenticator & UsersAuthenticator & GroupManagerAuthenticator & + ProtectedBranchService & ReferrerAuthenticator & ReadableUsersAuthenticator & WritableUsersAuthenticator => /** * i. List branches diff --git a/src/main/scala/gitbucket/core/controller/api/ApiRepositoryCollaboratorControllerBase.scala b/src/main/scala/gitbucket/core/controller/api/ApiRepositoryCollaboratorControllerBase.scala index f234795a3..4a8ab09f8 100644 --- a/src/main/scala/gitbucket/core/controller/api/ApiRepositoryCollaboratorControllerBase.scala +++ b/src/main/scala/gitbucket/core/controller/api/ApiRepositoryCollaboratorControllerBase.scala @@ -7,7 +7,7 @@ import gitbucket.core.util.{OwnerAuthenticator, ReferrerAuthenticator} import org.scalatra.NoContent trait ApiRepositoryCollaboratorControllerBase extends ControllerBase { - self: RepositoryService with AccountService with ReferrerAuthenticator with OwnerAuthenticator => + self: RepositoryService & AccountService & ReferrerAuthenticator & OwnerAuthenticator => /* * i. List repository collaborators diff --git a/src/main/scala/gitbucket/core/controller/api/ApiRepositoryCommitControllerBase.scala b/src/main/scala/gitbucket/core/controller/api/ApiRepositoryCommitControllerBase.scala index c4c53221f..49b982704 100644 --- a/src/main/scala/gitbucket/core/controller/api/ApiRepositoryCommitControllerBase.scala +++ b/src/main/scala/gitbucket/core/controller/api/ApiRepositoryCommitControllerBase.scala @@ -21,7 +21,7 @@ import scala.math.min import scala.util.Using trait ApiRepositoryCommitControllerBase extends ControllerBase { - self: AccountService with CommitsService with ProtectedBranchService with ReferrerAuthenticator => + self: AccountService & CommitsService & ProtectedBranchService & ReferrerAuthenticator => /* * i. List commits on a repository * https://developer.github.com/v3/repos/commits/#list-commits-on-a-repository diff --git a/src/main/scala/gitbucket/core/controller/api/ApiRepositoryContentsControllerBase.scala b/src/main/scala/gitbucket/core/controller/api/ApiRepositoryContentsControllerBase.scala index 381d87131..1f0c40bd0 100644 --- a/src/main/scala/gitbucket/core/controller/api/ApiRepositoryContentsControllerBase.scala +++ b/src/main/scala/gitbucket/core/controller/api/ApiRepositoryContentsControllerBase.scala @@ -12,7 +12,7 @@ import org.eclipse.jgit.api.Git import scala.util.Using trait ApiRepositoryContentsControllerBase extends ControllerBase { - self: ReferrerAuthenticator with WritableUsersAuthenticator with RepositoryCommitFileService => + self: ReferrerAuthenticator & WritableUsersAuthenticator & RepositoryCommitFileService => /** * i. Get a repository README diff --git a/src/main/scala/gitbucket/core/controller/api/ApiRepositoryControllerBase.scala b/src/main/scala/gitbucket/core/controller/api/ApiRepositoryControllerBase.scala index a9cd6eb5b..e4555b934 100644 --- a/src/main/scala/gitbucket/core/controller/api/ApiRepositoryControllerBase.scala +++ b/src/main/scala/gitbucket/core/controller/api/ApiRepositoryControllerBase.scala @@ -15,16 +15,9 @@ import scala.concurrent.duration.Duration import scala.util.Using trait ApiRepositoryControllerBase extends ControllerBase { - self: RepositoryService - with ApiGitReferenceControllerBase - with RepositoryCreationService - with AccountService - with OwnerAuthenticator - with UsersAuthenticator - with GroupManagerAuthenticator - with ReferrerAuthenticator - with ReadableUsersAuthenticator - with WritableUsersAuthenticator => + self: RepositoryService & ApiGitReferenceControllerBase & RepositoryCreationService & AccountService & + OwnerAuthenticator & UsersAuthenticator & GroupManagerAuthenticator & ReferrerAuthenticator & + ReadableUsersAuthenticator & WritableUsersAuthenticator => /** * i. List your repositories diff --git a/src/main/scala/gitbucket/core/controller/api/ApiRepositoryStatusControllerBase.scala b/src/main/scala/gitbucket/core/controller/api/ApiRepositoryStatusControllerBase.scala index bf26ad5e5..e6d22414a 100644 --- a/src/main/scala/gitbucket/core/controller/api/ApiRepositoryStatusControllerBase.scala +++ b/src/main/scala/gitbucket/core/controller/api/ApiRepositoryStatusControllerBase.scala @@ -7,7 +7,7 @@ import gitbucket.core.util.Implicits._ import gitbucket.core.util.{JGitUtil, ReferrerAuthenticator, WritableUsersAuthenticator} trait ApiRepositoryStatusControllerBase extends ControllerBase { - self: AccountService with CommitStatusService with ReferrerAuthenticator with WritableUsersAuthenticator => + self: AccountService & CommitStatusService & ReferrerAuthenticator & WritableUsersAuthenticator => /* * i. Create a status diff --git a/src/main/scala/gitbucket/core/controller/api/ApiRepositoryWebhookControllerBase.scala b/src/main/scala/gitbucket/core/controller/api/ApiRepositoryWebhookControllerBase.scala index 78f5b4133..5bfe6c2a6 100644 --- a/src/main/scala/gitbucket/core/controller/api/ApiRepositoryWebhookControllerBase.scala +++ b/src/main/scala/gitbucket/core/controller/api/ApiRepositoryWebhookControllerBase.scala @@ -8,7 +8,7 @@ import gitbucket.core.util.Implicits._ import org.scalatra.NoContent trait ApiRepositoryWebhookControllerBase extends ControllerBase { - self: RepositoryService with WebHookService with ReferrerAuthenticator with WritableUsersAuthenticator => + self: RepositoryService & WebHookService & ReferrerAuthenticator & WritableUsersAuthenticator => /* * i. List repository webhooks diff --git a/src/main/scala/gitbucket/core/controller/api/ApiUserControllerBase.scala b/src/main/scala/gitbucket/core/controller/api/ApiUserControllerBase.scala index cbf37be08..4b7655425 100644 --- a/src/main/scala/gitbucket/core/controller/api/ApiUserControllerBase.scala +++ b/src/main/scala/gitbucket/core/controller/api/ApiUserControllerBase.scala @@ -8,7 +8,7 @@ import gitbucket.core.util.StringUtil._ import org.scalatra.NoContent trait ApiUserControllerBase extends ControllerBase { - self: RepositoryService with AccountService with AdminAuthenticator with UsersAuthenticator => + self: RepositoryService & AccountService & AdminAuthenticator & UsersAuthenticator => /** * i. Get a single user diff --git a/src/main/scala/gitbucket/core/service/CommitsService.scala b/src/main/scala/gitbucket/core/service/CommitsService.scala index d7f7d1da4..782e8b52b 100644 --- a/src/main/scala/gitbucket/core/service/CommitsService.scala +++ b/src/main/scala/gitbucket/core/service/CommitsService.scala @@ -16,7 +16,7 @@ import gitbucket.core.util.{FileUtil, StringUtil} import org.apache.commons.io.FileUtils trait CommitsService { - self: ActivityService with PullRequestService with WebHookPullRequestReviewCommentService => + self: ActivityService & PullRequestService & WebHookPullRequestReviewCommentService => def getCommitComments(owner: String, repository: String, commitId: String, includePullRequest: Boolean)(implicit s: Session diff --git a/src/main/scala/gitbucket/core/service/HandleCommentService.scala b/src/main/scala/gitbucket/core/service/HandleCommentService.scala index 52f297a77..341194a30 100644 --- a/src/main/scala/gitbucket/core/service/HandleCommentService.scala +++ b/src/main/scala/gitbucket/core/service/HandleCommentService.scala @@ -16,12 +16,8 @@ import gitbucket.core.service.RepositoryService.RepositoryInfo import gitbucket.core.util.Implicits._ trait HandleCommentService { - self: RepositoryService - with IssuesService - with ActivityService - with WebHookService - with WebHookIssueCommentService - with WebHookPullRequestService => + self: RepositoryService & IssuesService & ActivityService & WebHookService & WebHookIssueCommentService & + WebHookPullRequestService => /** * @see [[https://github.com/gitbucket/gitbucket/wiki/CommentAction]] diff --git a/src/main/scala/gitbucket/core/service/IssueCreationService.scala b/src/main/scala/gitbucket/core/service/IssueCreationService.scala index 467c462c9..49fcd177e 100644 --- a/src/main/scala/gitbucket/core/service/IssueCreationService.scala +++ b/src/main/scala/gitbucket/core/service/IssueCreationService.scala @@ -10,7 +10,7 @@ import gitbucket.core.util.Implicits._ trait IssueCreationService { - self: RepositoryService with WebHookIssueCommentService with LabelsService with IssuesService with ActivityService => + self: RepositoryService & WebHookIssueCommentService & LabelsService & IssuesService & ActivityService => def createIssue( repository: RepositoryInfo, diff --git a/src/main/scala/gitbucket/core/service/IssuesService.scala b/src/main/scala/gitbucket/core/service/IssuesService.scala index d2a9d2f6b..983233381 100644 --- a/src/main/scala/gitbucket/core/service/IssuesService.scala +++ b/src/main/scala/gitbucket/core/service/IssuesService.scala @@ -26,7 +26,7 @@ import gitbucket.core.plugin.PluginRegistry import scala.jdk.CollectionConverters._ trait IssuesService { - self: AccountService with RepositoryService with LabelsService with PrioritiesService with MilestonesService => + self: AccountService & RepositoryService & LabelsService & PrioritiesService & MilestonesService => import IssuesService._ def getIssue(owner: String, repository: String, issueId: String)(implicit s: Session) = diff --git a/src/main/scala/gitbucket/core/service/MergeService.scala b/src/main/scala/gitbucket/core/service/MergeService.scala index b9d92687a..1e7637940 100644 --- a/src/main/scala/gitbucket/core/service/MergeService.scala +++ b/src/main/scala/gitbucket/core/service/MergeService.scala @@ -23,13 +23,8 @@ import scala.jdk.CollectionConverters._ import scala.util.Using trait MergeService { - self: AccountService - with ActivityService - with IssuesService - with RepositoryService - with PullRequestService - with WebHookPullRequestService - with WebHookService => + self: AccountService & ActivityService & IssuesService & RepositoryService & PullRequestService & + WebHookPullRequestService & WebHookService => import MergeService._ diff --git a/src/main/scala/gitbucket/core/service/PullRequestService.scala b/src/main/scala/gitbucket/core/service/PullRequestService.scala index ffbdeb9db..3db36b5fd 100644 --- a/src/main/scala/gitbucket/core/service/PullRequestService.scala +++ b/src/main/scala/gitbucket/core/service/PullRequestService.scala @@ -25,13 +25,8 @@ import scala.jdk.CollectionConverters.* import scala.util.Using trait PullRequestService { - self: IssuesService - with CommitsService - with WebHookService - with WebHookPullRequestService - with RepositoryService - with MergeService - with ActivityService => + self: IssuesService & CommitsService & WebHookService & WebHookPullRequestService & RepositoryService & MergeService & + ActivityService => import PullRequestService.* def getPullRequest(owner: String, repository: String, issueId: Int)(implicit diff --git a/src/main/scala/gitbucket/core/service/ReleaseService.scala b/src/main/scala/gitbucket/core/service/ReleaseService.scala index f6542d352..64f219400 100644 --- a/src/main/scala/gitbucket/core/service/ReleaseService.scala +++ b/src/main/scala/gitbucket/core/service/ReleaseService.scala @@ -8,7 +8,7 @@ import gitbucket.core.model.Profile.dateColumnType import gitbucket.core.util.JGitUtil trait ReleaseService { - self: AccountService with RepositoryService => + self: AccountService & RepositoryService => def createReleaseAsset( owner: String, diff --git a/src/main/scala/gitbucket/core/service/RepositoryCommitFileService.scala b/src/main/scala/gitbucket/core/service/RepositoryCommitFileService.scala index efbd7a4d8..dd38a0023 100644 --- a/src/main/scala/gitbucket/core/service/RepositoryCommitFileService.scala +++ b/src/main/scala/gitbucket/core/service/RepositoryCommitFileService.scala @@ -17,12 +17,8 @@ import org.eclipse.jgit.transport.{ReceiveCommand, ReceivePack} import scala.util.Using trait RepositoryCommitFileService { - self: AccountService - with ActivityService - with IssuesService - with PullRequestService - with WebHookPullRequestService - with RepositoryService => + self: AccountService & ActivityService & IssuesService & PullRequestService & WebHookPullRequestService & + RepositoryService => /** * Create multiple files by callback function. diff --git a/src/main/scala/gitbucket/core/service/RepositoryCreationService.scala b/src/main/scala/gitbucket/core/service/RepositoryCreationService.scala index b4e13c0ae..19612992a 100644 --- a/src/main/scala/gitbucket/core/service/RepositoryCreationService.scala +++ b/src/main/scala/gitbucket/core/service/RepositoryCreationService.scala @@ -46,12 +46,7 @@ object RepositoryCreationService { } trait RepositoryCreationService { - self: AccountService - with RepositoryService - with LabelsService - with WikiService - with ActivityService - with PrioritiesService => + self: AccountService & RepositoryService & LabelsService & WikiService & ActivityService & PrioritiesService => def canCreateRepository(repositoryOwner: String, loginAccount: Account)(implicit session: Session): Boolean = { repositoryOwner == loginAccount.userName || getGroupsByUserName(loginAccount.userName) diff --git a/src/main/scala/gitbucket/core/service/WebHookService.scala b/src/main/scala/gitbucket/core/service/WebHookService.scala index 1fdcaa41c..2fb7c78d1 100644 --- a/src/main/scala/gitbucket/core/service/WebHookService.scala +++ b/src/main/scala/gitbucket/core/service/WebHookService.scala @@ -367,7 +367,7 @@ trait WebHookService { } trait WebHookPullRequestService extends WebHookService { - self: AccountService with RepositoryService with PullRequestService with IssuesService => + self: AccountService & RepositoryService & PullRequestService & IssuesService => import WebHookService._ // https://developer.github.com/v3/activity/events/types/#issuesevent @@ -513,7 +513,7 @@ trait WebHookPullRequestService extends WebHookService { } trait WebHookPullRequestReviewCommentService extends WebHookService { - self: AccountService with RepositoryService with PullRequestService with IssuesService with CommitsService => + self: AccountService & RepositoryService & PullRequestService & IssuesService & CommitsService => def callPullRequestReviewCommentWebHook( action: String, comment: CommitComment, @@ -561,7 +561,7 @@ trait WebHookPullRequestReviewCommentService extends WebHookService { } trait WebHookIssueCommentService extends WebHookPullRequestService { - self: AccountService with RepositoryService with PullRequestService with IssuesService => + self: AccountService & RepositoryService & PullRequestService & IssuesService => import WebHookService._ def callIssueCommentWebHook( diff --git a/src/main/scala/gitbucket/core/ssh/GitCommand.scala b/src/main/scala/gitbucket/core/ssh/GitCommand.scala index 8b7245643..8628b383d 100644 --- a/src/main/scala/gitbucket/core/ssh/GitCommand.scala +++ b/src/main/scala/gitbucket/core/ssh/GitCommand.scala @@ -92,7 +92,7 @@ abstract class GitCommand extends Command with ServerSessionAware { } abstract class DefaultGitCommand(val owner: String, val repoName: String) extends GitCommand { - self: RepositoryService with AccountService with DeployKeyService => + self: RepositoryService & AccountService & DeployKeyService => protected def userName(authType: AuthType): String = { authType match { diff --git a/src/main/scala/gitbucket/core/util/Authenticator.scala b/src/main/scala/gitbucket/core/util/Authenticator.scala index 580502274..abd4eb5bc 100644 --- a/src/main/scala/gitbucket/core/util/Authenticator.scala +++ b/src/main/scala/gitbucket/core/util/Authenticator.scala @@ -25,7 +25,7 @@ trait OneselfAuthenticator { self: ControllerBase => /** * Allows only the repository owner and administrators. */ -trait OwnerAuthenticator { self: ControllerBase with RepositoryService with AccountService => +trait OwnerAuthenticator { self: ControllerBase & RepositoryService & AccountService => protected def ownerOnly(action: (RepositoryInfo) => Any) = { authenticate(action) } protected def ownerOnly[T](action: (T, RepositoryInfo) => Any) = (form: T) => { authenticate(action(form, _)) } @@ -82,7 +82,7 @@ trait AdminAuthenticator { self: ControllerBase => /** * Allows only guests and signed in users who can access the repository. */ -trait ReferrerAuthenticator { self: ControllerBase with RepositoryService with AccountService => +trait ReferrerAuthenticator { self: ControllerBase & RepositoryService & AccountService => protected def referrersOnly(action: (RepositoryInfo) => Any) = { authenticate(action) } protected def referrersOnly[T](action: (T, RepositoryInfo) => Any) = (form: T) => { authenticate(action(form, _)) } @@ -102,7 +102,7 @@ trait ReferrerAuthenticator { self: ControllerBase with RepositoryService with A /** * Allows only signed in users who have read permission for the repository. */ -trait ReadableUsersAuthenticator { self: ControllerBase with RepositoryService with AccountService => +trait ReadableUsersAuthenticator { self: ControllerBase & RepositoryService & AccountService => protected def readableUsersOnly(action: (RepositoryInfo) => Any) = { authenticate(action) } protected def readableUsersOnly[T](action: (T, RepositoryInfo) => Any) = (form: T) => { authenticate(action(form, _)) @@ -124,7 +124,7 @@ trait ReadableUsersAuthenticator { self: ControllerBase with RepositoryService w /** * Allows only signed in users who have write permission for the repository. */ -trait WritableUsersAuthenticator { self: ControllerBase with RepositoryService with AccountService => +trait WritableUsersAuthenticator { self: ControllerBase & RepositoryService & AccountService => protected def writableUsersOnly(action: (RepositoryInfo) => Any) = { authenticate(action) } protected def writableUsersOnly[T](action: (T, RepositoryInfo) => Any) = (form: T) => { authenticate(action(form, _)) @@ -151,7 +151,7 @@ trait WritableUsersAuthenticator { self: ControllerBase with RepositoryService w /** * Allows only the group managers. */ -trait GroupManagerAuthenticator { self: ControllerBase with AccountService => +trait GroupManagerAuthenticator { self: ControllerBase & AccountService => protected def managersOnly(action: => Any) = { authenticate(action) } protected def managersOnly[T](action: T => Any) = (form: T) => { authenticate(action(form)) }