1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.scm.command.tag;
20
21 import org.apache.maven.scm.CommandParameter;
22 import org.apache.maven.scm.CommandParameters;
23 import org.apache.maven.scm.CommandParameters.SignOption;
24 import org.apache.maven.scm.ScmException;
25 import org.apache.maven.scm.ScmFileSet;
26 import org.apache.maven.scm.ScmResult;
27 import org.apache.maven.scm.ScmTagParameters;
28 import org.apache.maven.scm.command.AbstractCommand;
29 import org.apache.maven.scm.provider.ScmProviderRepository;
30
31
32
33
34
35 public abstract class AbstractTagCommand extends AbstractCommand {
36
37
38
39
40
41
42
43
44
45 protected ScmResult executeTagCommand(
46 ScmProviderRepository repository, ScmFileSet fileSet, String tagName, String message) throws ScmException {
47 return executeTagCommand(repository, fileSet, tagName, new ScmTagParameters(message));
48 }
49
50 protected abstract ScmResult executeTagCommand(
51 ScmProviderRepository repository, ScmFileSet fileSet, String tagName, ScmTagParameters scmTagParameters)
52 throws ScmException;
53
54
55
56
57 public ScmResult executeCommand(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters)
58 throws ScmException {
59 String tagName = parameters.getString(CommandParameter.TAG_NAME);
60
61 ScmTagParameters scmTagParameters = parameters.getScmTagParameters(CommandParameter.SCM_TAG_PARAMETERS);
62
63 String message = parameters.getString(CommandParameter.MESSAGE, null);
64
65 if (message != null) {
66
67 scmTagParameters.setMessage(message);
68 }
69
70 if (scmTagParameters.getMessage() == null) {
71
72 scmTagParameters.setMessage("[maven-scm] copy for tag " + tagName);
73 }
74
75 SignOption signOption = parameters.getSignOption(CommandParameter.SIGN_OPTION);
76 if (signOption != null) {
77 scmTagParameters.setSignOption(signOption);
78 }
79 return executeTagCommand(repository, fileSet, tagName, scmTagParameters);
80 }
81 }