mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-11 16:05:44 +01:00
implement disable last commit for subversion browse command
This commit is contained in:
@@ -30,6 +30,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
package sonia.scm.repository.spi;
|
package sonia.scm.repository.spi;
|
||||||
|
|
||||||
//~--- non-JDK imports --------------------------------------------------------
|
//~--- non-JDK imports --------------------------------------------------------
|
||||||
@@ -65,7 +66,7 @@ import java.util.List;
|
|||||||
* @author Sebastian Sdorra
|
* @author Sebastian Sdorra
|
||||||
*/
|
*/
|
||||||
public class SvnBrowseCommand extends AbstractSvnCommand
|
public class SvnBrowseCommand extends AbstractSvnCommand
|
||||||
implements BrowseCommand
|
implements BrowseCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -105,7 +106,7 @@ public class SvnBrowseCommand extends AbstractSvnCommand
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public BrowserResult getBrowserResult(BrowseCommandRequest request)
|
public BrowserResult getBrowserResult(BrowseCommandRequest request)
|
||||||
throws IOException, RepositoryException
|
throws IOException, RepositoryException
|
||||||
{
|
{
|
||||||
String path = request.getPath();
|
String path = request.getPath();
|
||||||
long revisionNumber = SvnUtil.getRevisionNumber(request.getRevision());
|
long revisionNumber = SvnUtil.getRevisionNumber(request.getRevision());
|
||||||
@@ -113,8 +114,8 @@ public class SvnBrowseCommand extends AbstractSvnCommand
|
|||||||
if (logger.isDebugEnabled())
|
if (logger.isDebugEnabled())
|
||||||
{
|
{
|
||||||
logger.debug("browser repository {} in path {} at revision {}",
|
logger.debug("browser repository {} in path {} at revision {}",
|
||||||
new Object[] { repository.getName(),
|
new Object[] { repository.getName(),
|
||||||
path, revisionNumber });
|
path, revisionNumber });
|
||||||
}
|
}
|
||||||
|
|
||||||
BrowserResult result = null;
|
BrowserResult result = null;
|
||||||
@@ -124,7 +125,7 @@ public class SvnBrowseCommand extends AbstractSvnCommand
|
|||||||
SVNRepository svnRepository = open();
|
SVNRepository svnRepository = open();
|
||||||
Collection<SVNDirEntry> entries =
|
Collection<SVNDirEntry> entries =
|
||||||
svnRepository.getDir(Util.nonNull(path), revisionNumber, null,
|
svnRepository.getDir(Util.nonNull(path), revisionNumber, null,
|
||||||
(Collection) null);
|
(Collection) null);
|
||||||
List<FileObject> children = new ArrayList<FileObject>();
|
List<FileObject> children = new ArrayList<FileObject>();
|
||||||
String basePath = Util.EMPTY_STRING;
|
String basePath = Util.EMPTY_STRING;
|
||||||
|
|
||||||
@@ -140,8 +141,8 @@ public class SvnBrowseCommand extends AbstractSvnCommand
|
|||||||
|
|
||||||
for (SVNDirEntry entry : entries)
|
for (SVNDirEntry entry : entries)
|
||||||
{
|
{
|
||||||
children.add(createFileObject(svnRepository, revisionNumber, entry,
|
children.add(createFileObject(request, svnRepository, revisionNumber,
|
||||||
basePath));
|
entry, basePath));
|
||||||
}
|
}
|
||||||
|
|
||||||
result = new BrowserResult();
|
result = new BrowserResult();
|
||||||
@@ -163,6 +164,8 @@ public class SvnBrowseCommand extends AbstractSvnCommand
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
|
*
|
||||||
|
* @param request
|
||||||
* @param repository
|
* @param repository
|
||||||
* @param revision
|
* @param revision
|
||||||
* @param entry
|
* @param entry
|
||||||
@@ -170,8 +173,8 @@ public class SvnBrowseCommand extends AbstractSvnCommand
|
|||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private FileObject createFileObject(SVNRepository repository, long revision,
|
private FileObject createFileObject(BrowseCommandRequest request,
|
||||||
SVNDirEntry entry, String path)
|
SVNRepository repository, long revision, SVNDirEntry entry, String path)
|
||||||
{
|
{
|
||||||
FileObject fileObject = new FileObject();
|
FileObject fileObject = new FileObject();
|
||||||
|
|
||||||
@@ -179,13 +182,17 @@ public class SvnBrowseCommand extends AbstractSvnCommand
|
|||||||
fileObject.setPath(path.concat(entry.getRelativePath()));
|
fileObject.setPath(path.concat(entry.getRelativePath()));
|
||||||
fileObject.setDirectory(entry.getKind() == SVNNodeKind.DIR);
|
fileObject.setDirectory(entry.getKind() == SVNNodeKind.DIR);
|
||||||
|
|
||||||
if (entry.getDate() != null)
|
if (!request.isDisableLastCommit())
|
||||||
{
|
{
|
||||||
fileObject.setLastModified(entry.getDate().getTime());
|
if (entry.getDate() != null)
|
||||||
|
{
|
||||||
|
fileObject.setLastModified(entry.getDate().getTime());
|
||||||
|
}
|
||||||
|
|
||||||
|
fileObject.setDescription(entry.getCommitMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
fileObject.setLength(entry.getSize());
|
fileObject.setLength(entry.getSize());
|
||||||
fileObject.setDescription(entry.getCommitMessage());
|
|
||||||
|
|
||||||
if (fileObject.isDirectory() && entry.hasProperties())
|
if (fileObject.isDirectory() && entry.hasProperties())
|
||||||
{
|
{
|
||||||
@@ -205,7 +212,7 @@ public class SvnBrowseCommand extends AbstractSvnCommand
|
|||||||
* @param fileObject
|
* @param fileObject
|
||||||
*/
|
*/
|
||||||
private void fetchExternalsProperty(SVNRepository repository, long revision,
|
private void fetchExternalsProperty(SVNRepository repository, long revision,
|
||||||
SVNDirEntry entry, FileObject fileObject)
|
SVNDirEntry entry, FileObject fileObject)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -30,6 +30,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
package sonia.scm.repository.spi;
|
package sonia.scm.repository.spi;
|
||||||
|
|
||||||
//~--- non-JDK imports --------------------------------------------------------
|
//~--- non-JDK imports --------------------------------------------------------
|
||||||
@@ -65,40 +66,17 @@ public class SvnBrowseCommandTest extends AbstractSvnCommandTestBase
|
|||||||
@Test
|
@Test
|
||||||
public void testBrowse() throws IOException, RepositoryException
|
public void testBrowse() throws IOException, RepositoryException
|
||||||
{
|
{
|
||||||
BrowserResult result =
|
List<FileObject> foList = getRootFromTip(new BrowseCommandRequest());
|
||||||
createCommand().getBrowserResult(new BrowseCommandRequest());
|
|
||||||
|
|
||||||
assertNotNull(result);
|
FileObject a = getFileObject(foList, "a.txt");
|
||||||
|
FileObject c = getFileObject(foList, "c");
|
||||||
|
|
||||||
List<FileObject> foList = result.getFiles();
|
|
||||||
|
|
||||||
assertNotNull(foList);
|
|
||||||
assertFalse(foList.isEmpty());
|
|
||||||
assertEquals(2, foList.size());
|
|
||||||
|
|
||||||
FileObject a = null;
|
|
||||||
FileObject c = null;
|
|
||||||
|
|
||||||
for (FileObject f : foList)
|
|
||||||
{
|
|
||||||
if ("a.txt".equals(f.getName()))
|
|
||||||
{
|
|
||||||
a = f;
|
|
||||||
}
|
|
||||||
else if ("c".equals(f.getName()))
|
|
||||||
{
|
|
||||||
c = f;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
assertNotNull(a);
|
|
||||||
assertFalse(a.isDirectory());
|
assertFalse(a.isDirectory());
|
||||||
assertEquals("a.txt", a.getName());
|
assertEquals("a.txt", a.getName());
|
||||||
assertEquals("a.txt", a.getPath());
|
assertEquals("a.txt", a.getPath());
|
||||||
assertEquals("added line for blame test", a.getDescription());
|
assertEquals("added line for blame test", a.getDescription());
|
||||||
assertTrue(a.getLength() > 0);
|
assertTrue(a.getLength() > 0);
|
||||||
checkDate(a.getLastModified());
|
checkDate(a.getLastModified());
|
||||||
assertNotNull(c);
|
|
||||||
assertTrue(c.isDirectory());
|
assertTrue(c.isDirectory());
|
||||||
assertEquals("c", c.getName());
|
assertEquals("c", c.getName());
|
||||||
assertEquals("c", c.getPath());
|
assertEquals("c", c.getPath());
|
||||||
@@ -159,6 +137,28 @@ public class SvnBrowseCommandTest extends AbstractSvnCommandTestBase
|
|||||||
checkDate(e.getLastModified());
|
checkDate(e.getLastModified());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method description
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @throws IOException
|
||||||
|
* @throws RepositoryException
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testDisableLastCommit() throws IOException, RepositoryException
|
||||||
|
{
|
||||||
|
BrowseCommandRequest request = new BrowseCommandRequest();
|
||||||
|
|
||||||
|
request.setDisableLastCommit(true);
|
||||||
|
|
||||||
|
List<FileObject> foList = getRootFromTip(request);
|
||||||
|
|
||||||
|
FileObject a = getFileObject(foList, "a.txt");
|
||||||
|
|
||||||
|
assertNull(a.getDescription());
|
||||||
|
assertNull(a.getLastModified());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method description
|
* Method description
|
||||||
*
|
*
|
||||||
@@ -169,4 +169,61 @@ public class SvnBrowseCommandTest extends AbstractSvnCommandTestBase
|
|||||||
{
|
{
|
||||||
return new SvnBrowseCommand(createContext(), repository);
|
return new SvnBrowseCommand(createContext(), repository);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//~--- get methods ----------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method description
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param foList
|
||||||
|
* @param name
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private FileObject getFileObject(List<FileObject> foList, String name)
|
||||||
|
{
|
||||||
|
FileObject a = null;
|
||||||
|
|
||||||
|
for (FileObject f : foList)
|
||||||
|
{
|
||||||
|
if (name.equals(f.getName()))
|
||||||
|
{
|
||||||
|
a = f;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
assertNotNull(a);
|
||||||
|
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method description
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param request
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*
|
||||||
|
* @throws IOException
|
||||||
|
* @throws RepositoryException
|
||||||
|
*/
|
||||||
|
private List<FileObject> getRootFromTip(BrowseCommandRequest request)
|
||||||
|
throws IOException, RepositoryException
|
||||||
|
{
|
||||||
|
BrowserResult result = createCommand().getBrowserResult(request);
|
||||||
|
|
||||||
|
assertNotNull(result);
|
||||||
|
|
||||||
|
List<FileObject> foList = result.getFiles();
|
||||||
|
|
||||||
|
assertNotNull(foList);
|
||||||
|
assertFalse(foList.isEmpty());
|
||||||
|
assertEquals(2, foList.size());
|
||||||
|
|
||||||
|
return foList;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user