mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-01 11:05:56 +01:00
Improve committer accuracy
Changes made by the SCM-Manager, like those through the editor and pull requests, now more accurately define the committer on the underlying changeset. Committed-by: Eduard Heimbuch <eduard.heimbuch@cloudogu.com> Co-authored-by: Eduard Heimbuch <eduard.heimbuch@cloudogu.com>
This commit is contained in:
committed by
SCM-Manager
parent
8eb2687e10
commit
7e83d34fc0
@@ -91,6 +91,14 @@ public class SvnModifyCommand implements ModifyCommand {
|
||||
}
|
||||
}
|
||||
|
||||
private String getCurrentUserName() {
|
||||
if (SecurityUtils.getSubject() != null && SecurityUtils.getSubject().getPrincipal() != null) {
|
||||
return SecurityUtils.getSubject().getPrincipal().toString();
|
||||
} else {
|
||||
return "SCM-Manager";
|
||||
}
|
||||
}
|
||||
|
||||
private String commitChanges(SVNClientManager clientManager, File workingDirectory, String commitMessage) {
|
||||
try {
|
||||
clientManager.setAuthenticationManager(SVNWCUtil.createDefaultAuthenticationManager(getCurrentUserName(), new char[0]));
|
||||
@@ -110,14 +118,6 @@ public class SvnModifyCommand implements ModifyCommand {
|
||||
}
|
||||
}
|
||||
|
||||
private String getCurrentUserName() {
|
||||
if (SecurityUtils.getSubject() != null && SecurityUtils.getSubject().getPrincipal() != null) {
|
||||
return SecurityUtils.getSubject().getPrincipal().toString();
|
||||
} else {
|
||||
return "SCM-Manager";
|
||||
}
|
||||
}
|
||||
|
||||
private void modifyWorkingDirectory(ModifyCommandRequest request, SVNClientManager clientManager, File workingDirectory) {
|
||||
for (ModifyCommandRequest.PartialRequest partialRequest : request.getRequests()) {
|
||||
try {
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
package sonia.scm.repository.spi;
|
||||
|
||||
import io.micrometer.core.instrument.simple.SimpleMeterRegistry;
|
||||
import org.apache.shiro.subject.PrincipalCollection;
|
||||
import org.apache.shiro.subject.Subject;
|
||||
import org.apache.shiro.util.ThreadContext;
|
||||
import org.junit.After;
|
||||
@@ -41,6 +42,7 @@ import sonia.scm.repository.api.FileLockedException;
|
||||
import sonia.scm.repository.work.NoneCachingWorkingCopyPool;
|
||||
import sonia.scm.repository.work.WorkdirProvider;
|
||||
import sonia.scm.repository.work.WorkingCopy;
|
||||
import sonia.scm.user.User;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -75,7 +77,10 @@ public class SvnModifyCommandTest extends AbstractSvnCommandTestBase {
|
||||
@Before
|
||||
public void initSecurityManager() {
|
||||
Subject subject = mock(Subject.class);
|
||||
PrincipalCollection principalCollection = mock(PrincipalCollection.class);
|
||||
when(subject.getPrincipal()).thenReturn("alThor");
|
||||
when(subject.getPrincipals()).thenReturn(principalCollection);
|
||||
when(principalCollection.oneByType(User.class)).thenReturn(new User("galaxy", "quest", "galaxy@quest.com"));
|
||||
ThreadContext.bind(subject);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user