mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-05 04:55:50 +01:00
enhance logcommand
This commit is contained in:
@@ -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);
|
||||
changeset = converter.createChangeset(commit);
|
||||
|
||||
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";
|
||||
|
||||
Reference in New Issue
Block a user