michael-o commented on code in PR #135:
URL: https://github.com/apache/maven-scm/pull/135#discussion_r882193477
##########
maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/changelog/GitChangeLogConsumerTest.java:
##########
@@ -178,4 +179,72 @@ public void testConsumer2()
assertTrue( cf.getRevision() != null && cf.getRevision().length() > 0
);
}
+ public void testGitLogConsumer3()
+ throws Exception
+ {
+ GitChangeLogConsumer consumer = new GitChangeLogConsumer( null );
+
+ File f = getTestFile(
"/src/test/resources/git/changelog/gitlog3.gitlog" );
+
+ ConsumerUtils.consumeFile( f, consumer );
+
+ List<ChangeSet> modifications = consumer.getModifications();
+
+ assertEquals( 10, modifications.size() );
+
+ SimpleDateFormat sdf = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss Z" );
+ sdf.setTimeZone( TimeZone.getTimeZone( "GMT" ) );
+
+ ChangeSet first = modifications.get(0);
Review Comment:
spaces
##########
maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/changelog/GitChangeLogConsumerTest.java:
##########
@@ -178,4 +179,72 @@ public void testConsumer2()
assertTrue( cf.getRevision() != null && cf.getRevision().length() > 0
);
}
+ public void testGitLogConsumer3()
+ throws Exception
+ {
+ GitChangeLogConsumer consumer = new GitChangeLogConsumer( null );
+
+ File f = getTestFile(
"/src/test/resources/git/changelog/gitlog3.gitlog" );
+
+ ConsumerUtils.consumeFile( f, consumer );
+
+ List<ChangeSet> modifications = consumer.getModifications();
+
+ assertEquals( 10, modifications.size() );
+
+ SimpleDateFormat sdf = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss Z" );
+ sdf.setTimeZone( TimeZone.getTimeZone( "GMT" ) );
Review Comment:
Use org.apache.maven.scm.ScmTestCase.GMT_TIME_ZONE?
##########
maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/changelog/GitChangeLogConsumerTest.java:
##########
@@ -178,4 +179,72 @@ public void testConsumer2()
assertTrue( cf.getRevision() != null && cf.getRevision().length() > 0
);
}
+ public void testGitLogConsumer3()
+ throws Exception
+ {
+ GitChangeLogConsumer consumer = new GitChangeLogConsumer( null );
+
+ File f = getTestFile(
"/src/test/resources/git/changelog/gitlog3.gitlog" );
+
+ ConsumerUtils.consumeFile( f, consumer );
+
+ List<ChangeSet> modifications = consumer.getModifications();
+
+ assertEquals( 10, modifications.size() );
+
+ SimpleDateFormat sdf = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss Z" );
+ sdf.setTimeZone( TimeZone.getTimeZone( "GMT" ) );
+
+ ChangeSet first = modifications.get(0);
+ assertEquals( "Michael Osipov <[email protected]>",
first.getAuthor() );
+ assertEquals( "2022-01-08 20:02:12 +0000", sdf.format( first.getDate()
) );
+ assertEquals( "[maven-release-plugin] prepare for next development
iteration", first.getComment() );
+ assertEquals( "4fc34cfa14f2e72506187b03a492ce55ed459d4c",
first.getRevision() );
+ assertEquals( Collections.emptyList(), first.getTags() );
+ assertNotNull( first.getFiles() );
+ assertFalse( first.getFiles().isEmpty() );
+
+ ChangeSet second = modifications.get(1);
Review Comment:
ditto
##########
maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/changelog/GitChangeLogConsumerTest.java:
##########
@@ -178,4 +179,72 @@ public void testConsumer2()
assertTrue( cf.getRevision() != null && cf.getRevision().length() > 0
);
}
+ public void testGitLogConsumer3()
+ throws Exception
+ {
+ GitChangeLogConsumer consumer = new GitChangeLogConsumer( null );
+
+ File f = getTestFile(
"/src/test/resources/git/changelog/gitlog3.gitlog" );
+
+ ConsumerUtils.consumeFile( f, consumer );
+
+ List<ChangeSet> modifications = consumer.getModifications();
+
+ assertEquals( 10, modifications.size() );
+
+ SimpleDateFormat sdf = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss Z" );
+ sdf.setTimeZone( TimeZone.getTimeZone( "GMT" ) );
+
+ ChangeSet first = modifications.get(0);
+ assertEquals( "Michael Osipov <[email protected]>",
first.getAuthor() );
+ assertEquals( "2022-01-08 20:02:12 +0000", sdf.format( first.getDate()
) );
+ assertEquals( "[maven-release-plugin] prepare for next development
iteration", first.getComment() );
+ assertEquals( "4fc34cfa14f2e72506187b03a492ce55ed459d4c",
first.getRevision() );
+ assertEquals( Collections.emptyList(), first.getTags() );
+ assertNotNull( first.getFiles() );
+ assertFalse( first.getFiles().isEmpty() );
+
+ ChangeSet second = modifications.get(1);
+ assertEquals( "Michael Osipov <[email protected]>",
second.getAuthor() );
+ assertEquals( "2022-01-08 20:02:01 +0000", sdf.format(
second.getDate() ) );
+ assertEquals( "[maven-release-plugin] prepare release
maven-scm-2.0.0-M1", second.getComment() );
+ assertEquals( "3a6d9817fe809c43eca588d7c0f4428254eae17c",
second.getRevision() );
+ assertEquals( Collections.singletonList("maven-scm-2.0.0-M1"),
second.getTags() );
+ assertNotNull( second.getFiles() );
+ assertFalse( second.getFiles().isEmpty() );
+ }
+
+ public void testTagAndBranchConsumer() {
+ String[] lines = {
+ "commit a6d03ee7bcec7bfd6b0fc890a277f004a1c54077 (HEAD -> main,
tag: TestTag, origin/main, origin/HEAD)",
+ "Author: Niels Basjes <[email protected]>",
+ "Date: 2022-02-06 16:19:01 +0100",
+ "",
+ " This",
+ " is",
+ " a",
+ " multiline",
+ " comment",
+ "",
+ ":100644 100644 2019174 808473f M\tdocumentation/pom.xml",
+ ""
+ };
+ GitChangeLogConsumer consumer = new GitChangeLogConsumer( null );
+
+ for ( String line : lines ) {
+ consumer.consumeLine( line );
+ }
+
+ List<ChangeSet> modifications = consumer.getModifications();
+
+ assertEquals( 1, modifications.size() );
+ ChangeSet changeSet = modifications.get(0);
+ assertEquals( Collections.singletonList("TestTag"),
changeSet.getTags() );
+ assertEquals( "This\nis\na\nmultiline\ncomment",
changeSet.getComment() );
+ List<ChangeFile> files = changeSet.getFiles();
+ assertEquals( 1, files.size() );
+ ChangeFile changeFile = files.get(0);
Review Comment:
ditto
##########
maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/changelog/GitChangeLogConsumerTest.java:
##########
@@ -178,4 +179,72 @@ public void testConsumer2()
assertTrue( cf.getRevision() != null && cf.getRevision().length() > 0
);
}
+ public void testGitLogConsumer3()
+ throws Exception
+ {
+ GitChangeLogConsumer consumer = new GitChangeLogConsumer( null );
+
+ File f = getTestFile(
"/src/test/resources/git/changelog/gitlog3.gitlog" );
+
+ ConsumerUtils.consumeFile( f, consumer );
+
+ List<ChangeSet> modifications = consumer.getModifications();
+
+ assertEquals( 10, modifications.size() );
+
+ SimpleDateFormat sdf = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss Z" );
+ sdf.setTimeZone( TimeZone.getTimeZone( "GMT" ) );
+
+ ChangeSet first = modifications.get(0);
+ assertEquals( "Michael Osipov <[email protected]>",
first.getAuthor() );
+ assertEquals( "2022-01-08 20:02:12 +0000", sdf.format( first.getDate()
) );
+ assertEquals( "[maven-release-plugin] prepare for next development
iteration", first.getComment() );
+ assertEquals( "4fc34cfa14f2e72506187b03a492ce55ed459d4c",
first.getRevision() );
+ assertEquals( Collections.emptyList(), first.getTags() );
+ assertNotNull( first.getFiles() );
+ assertFalse( first.getFiles().isEmpty() );
+
+ ChangeSet second = modifications.get(1);
+ assertEquals( "Michael Osipov <[email protected]>",
second.getAuthor() );
+ assertEquals( "2022-01-08 20:02:01 +0000", sdf.format(
second.getDate() ) );
+ assertEquals( "[maven-release-plugin] prepare release
maven-scm-2.0.0-M1", second.getComment() );
+ assertEquals( "3a6d9817fe809c43eca588d7c0f4428254eae17c",
second.getRevision() );
+ assertEquals( Collections.singletonList("maven-scm-2.0.0-M1"),
second.getTags() );
+ assertNotNull( second.getFiles() );
+ assertFalse( second.getFiles().isEmpty() );
+ }
+
+ public void testTagAndBranchConsumer() {
+ String[] lines = {
+ "commit a6d03ee7bcec7bfd6b0fc890a277f004a1c54077 (HEAD -> main,
tag: TestTag, origin/main, origin/HEAD)",
+ "Author: Niels Basjes <[email protected]>",
+ "Date: 2022-02-06 16:19:01 +0100",
+ "",
+ " This",
+ " is",
+ " a",
+ " multiline",
+ " comment",
+ "",
+ ":100644 100644 2019174 808473f M\tdocumentation/pom.xml",
+ ""
+ };
+ GitChangeLogConsumer consumer = new GitChangeLogConsumer( null );
+
+ for ( String line : lines ) {
+ consumer.consumeLine( line );
+ }
+
+ List<ChangeSet> modifications = consumer.getModifications();
+
+ assertEquals( 1, modifications.size() );
+ ChangeSet changeSet = modifications.get(0);
+ assertEquals( Collections.singletonList("TestTag"),
changeSet.getTags() );
Review Comment:
ditto
##########
maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/changelog/ChangeLogCommandTckTest.java:
##########
@@ -49,6 +53,16 @@
extends ScmTckTestCase
{
private static final String COMMIT_MSG = "Second changelog";
+ private static final String COMMIT_TAG = "v3.14";
+
+ /**
+ * In some SCMs (HG) adding a tag creates an extra commit which offsets
the expectations.
Review Comment:
Hg
##########
maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/changelog/GitChangeLogConsumerTest.java:
##########
@@ -178,4 +179,72 @@ public void testConsumer2()
assertTrue( cf.getRevision() != null && cf.getRevision().length() > 0
);
}
+ public void testGitLogConsumer3()
+ throws Exception
+ {
+ GitChangeLogConsumer consumer = new GitChangeLogConsumer( null );
+
+ File f = getTestFile(
"/src/test/resources/git/changelog/gitlog3.gitlog" );
+
+ ConsumerUtils.consumeFile( f, consumer );
+
+ List<ChangeSet> modifications = consumer.getModifications();
+
+ assertEquals( 10, modifications.size() );
+
+ SimpleDateFormat sdf = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss Z" );
+ sdf.setTimeZone( TimeZone.getTimeZone( "GMT" ) );
+
+ ChangeSet first = modifications.get(0);
+ assertEquals( "Michael Osipov <[email protected]>",
first.getAuthor() );
+ assertEquals( "2022-01-08 20:02:12 +0000", sdf.format( first.getDate()
) );
+ assertEquals( "[maven-release-plugin] prepare for next development
iteration", first.getComment() );
+ assertEquals( "4fc34cfa14f2e72506187b03a492ce55ed459d4c",
first.getRevision() );
+ assertEquals( Collections.emptyList(), first.getTags() );
+ assertNotNull( first.getFiles() );
+ assertFalse( first.getFiles().isEmpty() );
+
+ ChangeSet second = modifications.get(1);
+ assertEquals( "Michael Osipov <[email protected]>",
second.getAuthor() );
+ assertEquals( "2022-01-08 20:02:01 +0000", sdf.format(
second.getDate() ) );
+ assertEquals( "[maven-release-plugin] prepare release
maven-scm-2.0.0-M1", second.getComment() );
+ assertEquals( "3a6d9817fe809c43eca588d7c0f4428254eae17c",
second.getRevision() );
+ assertEquals( Collections.singletonList("maven-scm-2.0.0-M1"),
second.getTags() );
+ assertNotNull( second.getFiles() );
+ assertFalse( second.getFiles().isEmpty() );
+ }
+
+ public void testTagAndBranchConsumer() {
+ String[] lines = {
+ "commit a6d03ee7bcec7bfd6b0fc890a277f004a1c54077 (HEAD -> main,
tag: TestTag, origin/main, origin/HEAD)",
+ "Author: Niels Basjes <[email protected]>",
+ "Date: 2022-02-06 16:19:01 +0100",
+ "",
+ " This",
+ " is",
+ " a",
+ " multiline",
+ " comment",
+ "",
+ ":100644 100644 2019174 808473f M\tdocumentation/pom.xml",
+ ""
+ };
+ GitChangeLogConsumer consumer = new GitChangeLogConsumer( null );
+
+ for ( String line : lines ) {
+ consumer.consumeLine( line );
+ }
+
+ List<ChangeSet> modifications = consumer.getModifications();
+
+ assertEquals( 1, modifications.size() );
+ ChangeSet changeSet = modifications.get(0);
Review Comment:
ditto
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]