Skip to content

Commit

Permalink
[MRELEASE-1072] Reuse original tag for next development version in ca…
Browse files Browse the repository at this point in the history
…se translator does not support resolution

This closes #86
  • Loading branch information
kwin authored and michael-o committed Oct 29, 2022
1 parent 951aba3 commit 0615a4c
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,19 @@ protected void transformScm( MavenProject project, Model modelTarget, ReleaseDes
scmRoot.setConnection( scm.getConnection() );
scmRoot.setDeveloperConnection( scm.getDeveloperConnection() );
scmRoot.setUrl( scm.getUrl() );
scmRoot.setTag( translator.resolveTag( scm.getTag() ) );
String tag = translator.resolveTag( scm.getTag() );
// reuse unresolved tag from original in case ScmTranslator does not support tags
if ( tag == null )
{
tag = scm.getTag();
// never give out default value as there is no way to distinguish it from an the
// explicitly set tag with the same value
if ( "HEAD".equals( tag ) )
{
tag = null;
}
}
scmRoot.setTag( tag );
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,26 @@ public void testRewriteBasicPomWithGitFromTag()
assertTrue( comparePomFiles( reactorProjects ) );
}

@Test
public void testRewriteBasicPomWithSvnFromTag()
throws Exception
{
List<MavenProject> reactorProjects = createReactorProjects( "basic-pom-with-svn-from-tag" );
ReleaseDescriptorBuilder builder = createDescriptorFromProjects( reactorProjects, "basic-pom-with-svn-from-tag" );
mapNextVersion( builder, "groupId:artifactId" );

Scm scm = new Scm();
scm.setConnection( "scm:svn:file://localhost/svnroot/trunk/" );
scm.setDeveloperConnection( "scm:svn:file://localhost/svnroot/trunk/" );
scm.setUrl( "http://localhost/svn" );
scm.setTag( "trunk" );
builder.addOriginalScmInfo( "groupId:artifactId", scm );

phase.execute( ReleaseUtils.buildReleaseDescriptor( builder ), new DefaultReleaseEnvironment(), reactorProjects );

assertTrue( comparePomFiles( reactorProjects ) );
}

@Test
public void testRewriteBasicPomWithInheritedScm()
throws Exception
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
~ Copyright 2022 The Apache Software Foundation.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<project>
<modelVersion>4.0.0</modelVersion>
<groupId>groupId</groupId>
<artifactId>artifactId</artifactId>
<version>1.1-SNAPSHOT</version>

<prerequisites>
<maven>3.2.5</maven>
</prerequisites>

<scm>
<connection>scm:svn:file://localhost/svnroot/trunk/</connection>
<developerConnection>scm:svn:file://localhost/svnroot/trunk/</developerConnection>
<url>http://localhost/svn</url>
<tag>trunk</tag>
</scm>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
~ Copyright 2022 The Apache Software Foundation.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<project>
<modelVersion>4.0.0</modelVersion>
<groupId>groupId</groupId>
<artifactId>artifactId</artifactId>
<version>1.0</version>

<prerequisites>
<maven>3.2.5</maven>
</prerequisites>

<scm>
<connection>scm:svn:file://localhost/svnroot/trunk/</connection>
<developerConnection>scm:svn:file://localhost/svnroot/trunk/</developerConnection>
<url>http://localhost/svn</url>
<tag>trunk</tag>
</scm>
</project>

0 comments on commit 0615a4c

Please sign in to comment.