Skip to content

Commit

Permalink
[MRELEASE-1072] - Reuse original tag for next development version in
Browse files Browse the repository at this point in the history
case translator does not support resolving
  • Loading branch information
kwin committed Jan 2, 2022
1 parent b31b778 commit ff95374
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,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 @@ -427,4 +427,25 @@ public void testRewritePomDependenciesWithoutDependenciesVersionUpdate()

assertTrue( comparePomFiles( reactorProjects ) );
}

// MRELEASE-1072
@Test
public void testKeepScmTagWithUnsupportedTagsInScmTranslator()
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 ) );
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
~ Copyright 2005-2006 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>2.0.4</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 2005-2006 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>2.0.4</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 ff95374

Please sign in to comment.