enhance logcommand

This commit is contained in:
Eduard Heimbuch
2019-10-25 12:31:18 +02:00
parent 5c7bd90f7a
commit a938fd8682
8 changed files with 42 additions and 10 deletions

View File

@@ -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())
{

View File

@@ -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";