mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-02 11:35:57 +01:00
enhance logcommand
This commit is contained in:
@@ -178,7 +178,7 @@ public final class LogCommandBuilder
|
||||
logger.debug("get changeset for {} with disabled cache", id);
|
||||
}
|
||||
|
||||
changeset = logCommand.getChangeset(id);
|
||||
changeset = logCommand.getChangeset(id, request);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -192,7 +192,7 @@ public final class LogCommandBuilder
|
||||
logger.debug("get changeset for {}", id);
|
||||
}
|
||||
|
||||
changeset = logCommand.getChangeset(id);
|
||||
changeset = logCommand.getChangeset(id, request);
|
||||
|
||||
if (changeset != null)
|
||||
{
|
||||
|
||||
@@ -49,7 +49,7 @@ import java.io.IOException;
|
||||
*/
|
||||
public interface LogCommand {
|
||||
|
||||
Changeset getChangeset(String id) throws IOException;
|
||||
Changeset getChangeset(String id, LogCommandRequest request) throws IOException;
|
||||
|
||||
ChangesetPagingResult getChangesets(LogCommandRequest request) throws IOException;
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ public class GitLogCommand extends AbstractGitCommand implements LogCommand
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Changeset getChangeset(String revision)
|
||||
public Changeset getChangeset(String revision, LogCommandRequest request)
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
@@ -131,7 +131,13 @@ public class GitLogCommand extends AbstractGitCommand implements LogCommand
|
||||
if (commit != null)
|
||||
{
|
||||
converter = new GitChangesetConverter(gr, revWalk);
|
||||
|
||||
if (request != null && !Strings.isNullOrEmpty(request.getBranch())) {
|
||||
changeset = converter.createChangeset(commit, request.getBranch());
|
||||
} else {
|
||||
changeset = converter.createChangeset(commit);
|
||||
|
||||
}
|
||||
}
|
||||
else if (logger.isWarnEnabled())
|
||||
{
|
||||
|
||||
@@ -171,7 +171,33 @@ public class GitLogCommandTest extends AbstractGitCommandTestBase
|
||||
public void testGetCommit()
|
||||
{
|
||||
GitLogCommand command = createCommand();
|
||||
Changeset c = command.getChangeset("435df2f061add3589cb3");
|
||||
Changeset c = command.getChangeset("435df2f061add3589cb3", null);
|
||||
|
||||
assertNotNull(c);
|
||||
String revision = "435df2f061add3589cb326cc64be9b9c3897ceca";
|
||||
assertEquals(revision, c.getId());
|
||||
assertEquals("added a and b files", c.getDescription());
|
||||
checkDate(c.getDate());
|
||||
assertEquals("Douglas Adams", c.getAuthor().getName());
|
||||
assertEquals("douglas.adams@hitchhiker.com", c.getAuthor().getMail());
|
||||
assertEquals("added a and b files", c.getDescription());
|
||||
|
||||
GitModificationsCommand gitModificationsCommand = new GitModificationsCommand(createContext(), repository);
|
||||
Modifications modifications = gitModificationsCommand.getModifications(revision);
|
||||
|
||||
assertNotNull(modifications);
|
||||
assertTrue("modified list should be empty", modifications.getModified().isEmpty());
|
||||
assertTrue("removed list should be empty", modifications.getRemoved().isEmpty());
|
||||
assertFalse("added list should not be empty", modifications.getAdded().isEmpty());
|
||||
assertEquals(2, modifications.getAdded().size());
|
||||
assertThat(modifications.getAdded(), contains("a.txt", "b.txt"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetCommitWithBranch()
|
||||
{
|
||||
GitLogCommand command = createCommand();
|
||||
Changeset c = command.getChangeset("435df2f061add3589cb3", null);
|
||||
|
||||
assertNotNull(c);
|
||||
String revision = "435df2f061add3589cb326cc64be9b9c3897ceca";
|
||||
|
||||
@@ -68,7 +68,7 @@ public class HgLogCommand extends AbstractCommand implements LogCommand
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public Changeset getChangeset(String id) {
|
||||
public Changeset getChangeset(String id, LogCommandRequest request) {
|
||||
com.aragost.javahg.Repository repository = open();
|
||||
HgLogChangesetCommand cmd = on(repository);
|
||||
|
||||
|
||||
@@ -154,7 +154,7 @@ public class HgLogCommandTest extends AbstractHgCommandTestBase
|
||||
HgLogCommand command = createComamnd();
|
||||
String revision = "a9bacaf1b7fa0cebfca71fed4e59ed69a6319427";
|
||||
Changeset c =
|
||||
command.getChangeset(revision);
|
||||
command.getChangeset(revision, null);
|
||||
|
||||
assertNotNull(c);
|
||||
assertEquals(revision, c.getId());
|
||||
|
||||
@@ -75,7 +75,7 @@ public class SvnLogCommand extends AbstractSvnCommand implements LogCommand
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public Changeset getChangeset(String revision) {
|
||||
public Changeset getChangeset(String revision, LogCommandRequest request) {
|
||||
Changeset changeset = null;
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
|
||||
@@ -128,7 +128,7 @@ public class SvnLogCommandTest extends AbstractSvnCommandTestBase
|
||||
|
||||
@Test
|
||||
public void testGetCommit() {
|
||||
Changeset c = createCommand().getChangeset("3");
|
||||
Changeset c = createCommand().getChangeset("3", null);
|
||||
|
||||
assertNotNull(c);
|
||||
assertEquals("3", c.getId());
|
||||
|
||||
Reference in New Issue
Block a user