mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-13 00:45:44 +01:00
Rename method
This commit is contained in:
@@ -69,7 +69,7 @@ public final class BranchCommandBuilder {
|
||||
}
|
||||
|
||||
public void delete(String branchName) {
|
||||
command.delete(branchName);
|
||||
command.deleteOrClose(branchName);
|
||||
}
|
||||
|
||||
private BranchCommand command;
|
||||
|
||||
@@ -42,5 +42,5 @@ import sonia.scm.repository.api.BranchRequest;
|
||||
public interface BranchCommand {
|
||||
Branch branch(BranchRequest name);
|
||||
|
||||
void delete(String branchName);
|
||||
void deleteOrClose(String branchName);
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ public class GitBranchCommand extends AbstractGitCommand implements BranchComman
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(String branchName) {
|
||||
public void deleteOrClose(String branchName) {
|
||||
try (Git gitRepo = new Git(context.open())) {
|
||||
RepositoryHookEvent hookEvent = createBranchHookEvent(BranchHookContextProvider.deleteHookEvent(branchName));
|
||||
eventBus.post(new PreReceiveRepositoryHookEvent(hookEvent));
|
||||
|
||||
@@ -73,14 +73,14 @@ public class GitBranchCommandTest extends AbstractGitCommandTestBase {
|
||||
public void shouldDeleteBranch() throws IOException {
|
||||
GitContext context = createContext();
|
||||
String branchToBeDeleted = "squash";
|
||||
createCommand().delete(branchToBeDeleted);
|
||||
createCommand().deleteOrClose(branchToBeDeleted);
|
||||
assertThat(readBranches(context)).filteredOn(b -> b.getName().equals(branchToBeDeleted)).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldThrowInternalRepositoryException() {
|
||||
String branchToBeDeleted = "master";
|
||||
assertThrows(InternalRepositoryException.class, () -> createCommand().delete(branchToBeDeleted));
|
||||
assertThrows(InternalRepositoryException.class, () -> createCommand().deleteOrClose(branchToBeDeleted));
|
||||
}
|
||||
|
||||
private GitBranchCommand createCommand() {
|
||||
@@ -118,7 +118,7 @@ public class GitBranchCommandTest extends AbstractGitCommandTestBase {
|
||||
doNothing().when(eventBus).post(captor.capture());
|
||||
when(hookContextFactory.createContext(any(), any())).thenAnswer(this::createMockedContext);
|
||||
|
||||
createCommand().delete("squash");
|
||||
createCommand().deleteOrClose("squash");
|
||||
|
||||
List<Object> events = captor.getAllValues();
|
||||
assertThat(events.get(0)).isInstanceOf(PreReceiveRepositoryHookEvent.class);
|
||||
|
||||
@@ -76,7 +76,7 @@ public class HgBranchCommand extends AbstractCommand implements BranchCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(String branchName) {
|
||||
public void deleteOrClose(String branchName) {
|
||||
try (WorkingCopy<com.aragost.javahg.Repository, com.aragost.javahg.Repository> workingCopy = workdirFactory.createWorkingCopy(getContext(), branchName)) {
|
||||
User currentUser = SecurityUtils.getSubject().getPrincipals().oneByType(User.class);
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ public class HgBranchCommandTest extends AbstractHgCommandTestBase {
|
||||
public void shouldCloseBranch() {
|
||||
String branchToBeClosed = "test-branch";
|
||||
|
||||
new HgBranchCommand(cmdContext, repository, workdirFactory).delete(branchToBeClosed);
|
||||
new HgBranchCommand(cmdContext, repository, workdirFactory).deleteOrClose(branchToBeClosed);
|
||||
assertThat(readBranches()).filteredOn(b -> b.getName().equals(branchToBeClosed)).isEmpty();
|
||||
}
|
||||
|
||||
@@ -68,8 +68,8 @@ public class HgBranchCommandTest extends AbstractHgCommandTestBase {
|
||||
public void shouldThrowInternalRepositoryException() {
|
||||
String branchToBeClosed = "default";
|
||||
|
||||
new HgBranchCommand(cmdContext, repository, workdirFactory).delete(branchToBeClosed);
|
||||
assertThrows(InternalRepositoryException.class, () -> new HgBranchCommand(cmdContext, repository, workdirFactory).delete(branchToBeClosed));
|
||||
new HgBranchCommand(cmdContext, repository, workdirFactory).deleteOrClose(branchToBeClosed);
|
||||
assertThrows(InternalRepositoryException.class, () -> new HgBranchCommand(cmdContext, repository, workdirFactory).deleteOrClose(branchToBeClosed));
|
||||
}
|
||||
|
||||
private List<Branch> readBranches() {
|
||||
|
||||
Reference in New Issue
Block a user