mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-12 08:25:44 +01:00
small fixes
This commit is contained in:
@@ -92,7 +92,7 @@ public class HgModifyCommand implements ModifyCommand {
|
|||||||
return pullCommand.execute(workingCopy.getDirectory().getAbsolutePath());
|
return pullCommand.execute(workingCopy.getDirectory().getAbsolutePath());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new IntegrateChangesFromWorkdirException(context.getScmRepository(),
|
throw new IntegrateChangesFromWorkdirException(context.getScmRepository(),
|
||||||
String.format("Could not pull modify changes from working copy to central repository", request.getBranch()),
|
String.format("Could not pull modify changes from working copy to central repository for branch %s", request.getBranch()),
|
||||||
e);
|
e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,11 +78,10 @@ public class HgRepositoryServiceProvider extends RepositoryServiceProvider
|
|||||||
//~--- constructors ---------------------------------------------------------
|
//~--- constructors ---------------------------------------------------------
|
||||||
|
|
||||||
HgRepositoryServiceProvider(HgRepositoryHandler handler,
|
HgRepositoryServiceProvider(HgRepositoryHandler handler,
|
||||||
HgHookManager hookManager, Repository repository, HgWorkdirFactory workdirFactory)
|
HgHookManager hookManager, Repository repository)
|
||||||
{
|
{
|
||||||
this.repository = repository;
|
this.repository = repository;
|
||||||
this.handler = handler;
|
this.handler = handler;
|
||||||
this.workdirFactory = workdirFactory;
|
|
||||||
this.repositoryDirectory = handler.getDirectory(repository.getId());
|
this.repositoryDirectory = handler.getDirectory(repository.getId());
|
||||||
this.context = new HgCommandContext(hookManager, handler, repository,
|
this.context = new HgCommandContext(hookManager, handler, repository,
|
||||||
repositoryDirectory);
|
repositoryDirectory);
|
||||||
@@ -294,6 +293,4 @@ public class HgRepositoryServiceProvider extends RepositoryServiceProvider
|
|||||||
|
|
||||||
/** Field description */
|
/** Field description */
|
||||||
private File repositoryDirectory;
|
private File repositoryDirectory;
|
||||||
|
|
||||||
private final HgWorkdirFactory workdirFactory;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,15 +49,13 @@ public class HgRepositoryServiceResolver implements RepositoryServiceResolver
|
|||||||
|
|
||||||
private final HgRepositoryHandler handler;
|
private final HgRepositoryHandler handler;
|
||||||
private final HgHookManager hookManager;
|
private final HgHookManager hookManager;
|
||||||
private final HgWorkdirFactory workdirFactory;
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public HgRepositoryServiceResolver(HgRepositoryHandler handler,
|
public HgRepositoryServiceResolver(HgRepositoryHandler handler,
|
||||||
HgHookManager hookManager, HgWorkdirFactory workdirFactory)
|
HgHookManager hookManager)
|
||||||
{
|
{
|
||||||
this.handler = handler;
|
this.handler = handler;
|
||||||
this.hookManager = hookManager;
|
this.hookManager = hookManager;
|
||||||
this.workdirFactory = workdirFactory;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -65,7 +63,7 @@ public class HgRepositoryServiceResolver implements RepositoryServiceResolver
|
|||||||
HgRepositoryServiceProvider provider = null;
|
HgRepositoryServiceProvider provider = null;
|
||||||
|
|
||||||
if (HgRepositoryHandler.TYPE_NAME.equalsIgnoreCase(repository.getType())) {
|
if (HgRepositoryHandler.TYPE_NAME.equalsIgnoreCase(repository.getType())) {
|
||||||
provider = new HgRepositoryServiceProvider(handler, hookManager, repository, workdirFactory);
|
provider = new HgRepositoryServiceProvider(handler, hookManager, repository);
|
||||||
}
|
}
|
||||||
|
|
||||||
return provider;
|
return provider;
|
||||||
|
|||||||
@@ -108,10 +108,7 @@ public class MergeResourceTest extends RepositoryTestBase {
|
|||||||
@Test
|
@Test
|
||||||
void shouldHandleSuccessfulMerge() throws Exception {
|
void shouldHandleSuccessfulMerge() throws Exception {
|
||||||
when(mergeCommand.merge(any())).thenReturn(MergeCommandResult.success());
|
when(mergeCommand.merge(any())).thenReturn(MergeCommandResult.success());
|
||||||
User user = createDummyUser("dummy");
|
mockUser();
|
||||||
PrincipalCollection collection = mock(PrincipalCollection.class);
|
|
||||||
when(subject.getPrincipals()).thenReturn(collection);
|
|
||||||
when(collection.oneByType(User.class)).thenReturn(user);
|
|
||||||
|
|
||||||
URL url = Resources.getResource("sonia/scm/api/v2/mergeCommand.json");
|
URL url = Resources.getResource("sonia/scm/api/v2/mergeCommand.json");
|
||||||
byte[] mergeCommandJson = Resources.toByteArray(url);
|
byte[] mergeCommandJson = Resources.toByteArray(url);
|
||||||
@@ -129,10 +126,7 @@ public class MergeResourceTest extends RepositoryTestBase {
|
|||||||
@Test
|
@Test
|
||||||
void shouldHandleFailedMerge() throws Exception {
|
void shouldHandleFailedMerge() throws Exception {
|
||||||
when(mergeCommand.merge(any())).thenReturn(MergeCommandResult.failure(asList("file1", "file2")));
|
when(mergeCommand.merge(any())).thenReturn(MergeCommandResult.failure(asList("file1", "file2")));
|
||||||
User user = createDummyUser("dummy");
|
mockUser();
|
||||||
PrincipalCollection collection = mock(PrincipalCollection.class);
|
|
||||||
when(subject.getPrincipals()).thenReturn(collection);
|
|
||||||
when(collection.oneByType(User.class)).thenReturn(user);
|
|
||||||
|
|
||||||
URL url = Resources.getResource("sonia/scm/api/v2/mergeCommand.json");
|
URL url = Resources.getResource("sonia/scm/api/v2/mergeCommand.json");
|
||||||
byte[] mergeCommandJson = Resources.toByteArray(url);
|
byte[] mergeCommandJson = Resources.toByteArray(url);
|
||||||
@@ -201,13 +195,11 @@ public class MergeResourceTest extends RepositoryTestBase {
|
|||||||
assertThat(response.getStatus()).isEqualTo(204);
|
assertThat(response.getStatus()).isEqualTo(204);
|
||||||
}
|
}
|
||||||
|
|
||||||
private User createDummyUser(String name) {
|
|
||||||
User user = new User();
|
private void mockUser() {
|
||||||
user.setName(name);
|
PrincipalCollection collection = mock(PrincipalCollection.class);
|
||||||
user.setType("xml");
|
when(subject.getPrincipals()).thenReturn(collection);
|
||||||
user.setPassword("secret");
|
when(collection.oneByType(User.class)).thenReturn(new User("dummy"));
|
||||||
user.setCreationDate(System.currentTimeMillis());
|
|
||||||
return user;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user