| 1 |
package org.apache.maven.scm.command.branch; |
| 2 |
|
| 3 |
/* |
| 4 |
* Licensed to the Apache Software Foundation (ASF) under one |
| 5 |
* or more contributor license agreements. See the NOTICE file |
| 6 |
* distributed with this work for additional information |
| 7 |
* regarding copyright ownership. The ASF licenses this file |
| 8 |
* to you under the Apache License, Version 2.0 (the |
| 9 |
* "License"); you may not use this file except in compliance |
| 10 |
* with the License. You may obtain a copy of the License at |
| 11 |
* |
| 12 |
* http://www.apache.org/licenses/LICENSE-2.0 |
| 13 |
* |
| 14 |
* Unless required by applicable law or agreed to in writing, |
| 15 |
* software distributed under the License is distributed on an |
| 16 |
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 17 |
* KIND, either express or implied. See the License for the |
| 18 |
* specific language governing permissions and limitations |
| 19 |
* under the License. |
| 20 |
*/ |
| 21 |
|
| 22 |
import org.apache.maven.scm.CommandParameter; |
| 23 |
import org.apache.maven.scm.CommandParameters; |
| 24 |
import org.apache.maven.scm.ScmBranchParameters; |
| 25 |
import org.apache.maven.scm.ScmException; |
| 26 |
import org.apache.maven.scm.ScmFileSet; |
| 27 |
import org.apache.maven.scm.ScmResult; |
| 28 |
import org.apache.maven.scm.command.AbstractCommand; |
| 29 |
import org.apache.maven.scm.provider.ScmProviderRepository; |
| 30 |
import org.codehaus.plexus.util.StringUtils; |
| 31 |
|
| 32 |
/** |
| 33 |
* @author <a href="mailto:[email protected]">Emmanuel Venisse</a> |
| 34 |
* @author <a href="mailto:[email protected]">Trygve Laugstøl</a> |
| 35 |
* |
| 36 |
*/ |
| 37 |
public abstract class AbstractBranchCommand |
| 38 |
extends AbstractCommand |
| 39 |
{ |
| 40 |
protected abstract ScmResult executeBranchCommand( ScmProviderRepository repository, ScmFileSet fileSet, |
| 41 |
String branchName, String message ) |
| 42 |
throws ScmException; |
| 43 |
|
| 44 |
/** |
| 45 |
* default impl to provide backward comp |
| 46 |
* @since 1.3 |
| 47 |
* @param repository TODO |
| 48 |
* @param fileSet TODO |
| 49 |
* @param branchName TODO |
| 50 |
* @param scmBranchParameters TODO |
| 51 |
* @return TODO |
| 52 |
* @throws ScmException if any |
| 53 |
*/ |
| 54 |
protected ScmResult executeBranchCommand( ScmProviderRepository repository, ScmFileSet fileSet, String branchName, |
| 55 |
ScmBranchParameters scmBranchParameters ) |
| 56 |
throws ScmException |
| 57 |
{ |
| 58 |
return executeBranchCommand( repository, fileSet, branchName, scmBranchParameters.getMessage() ); |
| 59 |
} |
| 60 |
|
| 61 |
/** {@inheritDoc} */ |
| 62 |
public ScmResult executeCommand( ScmProviderRepository repository, ScmFileSet fileSet, |
| 63 |
CommandParameters parameters ) |
| 64 |
throws ScmException |
| 65 |
{ |
| 66 |
String branchName = parameters.getString( CommandParameter.BRANCH_NAME ); |
| 67 |
|
| 68 |
ScmBranchParameters scmBranchParameters = |
| 69 |
parameters.getScmBranchParameters( CommandParameter.SCM_BRANCH_PARAMETERS ); |
| 70 |
|
| 71 |
String message = parameters.getString( CommandParameter.MESSAGE, "[maven-scm] copy for branch " + branchName ); |
| 72 |
|
| 73 |
if ( StringUtils.isBlank( scmBranchParameters.getMessage() ) && StringUtils.isNotBlank( message ) ) |
| 74 |
{ |
| 75 |
scmBranchParameters.setMessage( message ); |
| 76 |
} |
| 77 |
|
| 78 |
return executeBranchCommand( repository, fileSet, branchName, scmBranchParameters ); |
| 79 |
} |
| 80 |
} |