From 2044f5b8380a74ca1ae9fefffaf31c7f897ed4a0 Mon Sep 17 00:00:00 2001 From: Naoki Takezoe Date: Wed, 20 Sep 2017 17:46:53 +0900 Subject: [PATCH] Refuse deletion of the default branch --- .../gitbucket/core/service/ProtectedBranchService.scala | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/scala/gitbucket/core/service/ProtectedBranchService.scala b/src/main/scala/gitbucket/core/service/ProtectedBranchService.scala index 5cbb77c86..14c993a28 100644 --- a/src/main/scala/gitbucket/core/service/ProtectedBranchService.scala +++ b/src/main/scala/gitbucket/core/service/ProtectedBranchService.scala @@ -51,7 +51,11 @@ object ProtectedBranchService { (implicit session: Session): Option[String] = { val branch = command.getRefName.stripPrefix("refs/heads/") if(branch != command.getRefName){ - getProtectedBranchInfo(owner, repository, branch).getStopReason(receivePack.isAllowNonFastForwards, command, pusher) + if(command.getType == ReceiveCommand.Type.DELETE && branch == "test1"){ // TODO check default branch + Some(s"refusing to delete the branch: ${command.getRefName}.") + } else { + getProtectedBranchInfo(owner, repository, branch).getStopReason(receivePack.isAllowNonFastForwards, command, pusher) + } } else { None }