mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-10-26 08:06:09 +01:00
Do not expose subversion commit with id 0
This commit is contained in:
@@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## Unreleased
|
||||
### Fixed
|
||||
- Do not expose subversion commit with id 0 ([#1395](https://github.com/scm-manager/scm-manager/pull/1395))
|
||||
|
||||
## [2.8.0] - 2020-10-27
|
||||
### Added
|
||||
- Generation of email addresses for users, where none is configured ([#1370](https://github.com/scm-manager/scm-manager/pull/1370))
|
||||
|
||||
@@ -198,7 +198,7 @@ public final class SvnUtil
|
||||
Person.toPerson(entry.getAuthor()),
|
||||
entry.getMessage());
|
||||
|
||||
if (revision > 0)
|
||||
if (revision > 1)
|
||||
{
|
||||
changeset.getParents().add(String.valueOf(revision - 1));
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ package sonia.scm.repository.spi;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.Lists;
|
||||
import org.slf4j.Logger;
|
||||
@@ -76,6 +77,7 @@ public class SvnLogCommand extends AbstractSvnCommand implements LogCommand
|
||||
try
|
||||
{
|
||||
long revisioNumber = parseRevision(revision, repository);
|
||||
Preconditions.checkArgument(revisioNumber > 0, "revision must be greater than zero: %d", revisioNumber);
|
||||
SVNRepository repo = open();
|
||||
Collection<SVNLogEntry> entries = repo.log(null, null, revisioNumber,
|
||||
revisioNumber, true, true);
|
||||
|
||||
@@ -32,10 +32,9 @@ import sonia.scm.repository.Changeset;
|
||||
import sonia.scm.repository.ChangesetPagingResult;
|
||||
import sonia.scm.repository.Modifications;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
@@ -56,11 +55,36 @@ public class SvnLogCommandTest extends AbstractSvnCommandTestBase
|
||||
assertEquals(5, result.getChangesets().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldNotReturnChangesetWithIdZero() {
|
||||
ChangesetPagingResult result = createCommand().getChangesets(new LogCommandRequest());
|
||||
boolean found = StreamSupport.stream(result.spliterator(), false).anyMatch(c -> "0".equals(c.getId()));
|
||||
assertFalse(found);
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void shouldThrowIllegalArgumentExceptionForChangesetZero() {
|
||||
createCommand().getChangeset("0", new LogCommandRequest());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldNotReturnChangesetZeroAsParent() {
|
||||
Changeset changeset = createCommand().getChangeset("1", new LogCommandRequest());
|
||||
assertTrue(changeset.getParents().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldAppendParentChangeset() {
|
||||
Changeset changeset = createCommand().getChangeset("2", new LogCommandRequest());
|
||||
assertEquals(1, changeset.getParents().size());
|
||||
assertEquals("1", changeset.getParents().get(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testShouldStartWithRevisionOne() {
|
||||
ChangesetPagingResult result = createCommand().getChangesets(new LogCommandRequest());
|
||||
Changeset first = Iterables.getLast(result);
|
||||
assertEquals(first.getId(), "1");
|
||||
assertEquals("1", first.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user