1 | |
package org.apache.maven.scm.provider.tfs.command; |
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
import java.io.File; |
23 | |
import java.util.ArrayList; |
24 | |
import java.util.List; |
25 | |
|
26 | |
import org.apache.maven.scm.ScmException; |
27 | |
import org.apache.maven.scm.ScmFile; |
28 | |
import org.apache.maven.scm.ScmFileSet; |
29 | |
import org.apache.maven.scm.ScmFileStatus; |
30 | |
import org.apache.maven.scm.ScmResult; |
31 | |
import org.apache.maven.scm.ScmTagParameters; |
32 | |
import org.apache.maven.scm.command.tag.AbstractTagCommand; |
33 | |
import org.apache.maven.scm.command.tag.TagScmResult; |
34 | |
import org.apache.maven.scm.provider.ScmProviderRepository; |
35 | |
import org.apache.maven.scm.provider.tfs.TfsScmProviderRepository; |
36 | |
import org.apache.maven.scm.provider.tfs.command.consumer.ErrorStreamConsumer; |
37 | |
import org.codehaus.plexus.util.cli.CommandLineUtils.StringStreamConsumer; |
38 | |
|
39 | |
|
40 | |
|
41 | |
|
42 | |
|
43 | 1 | public class TfsTagCommand |
44 | |
extends AbstractTagCommand |
45 | |
{ |
46 | |
|
47 | |
protected ScmResult executeTagCommand( ScmProviderRepository r, ScmFileSet f, String tag, String message ) |
48 | |
throws ScmException |
49 | |
{ |
50 | 0 | return executeTagCommand( r, f, tag, new ScmTagParameters( message ) ); |
51 | |
} |
52 | |
|
53 | |
protected ScmResult executeTagCommand( ScmProviderRepository r, ScmFileSet f, String tag, |
54 | |
ScmTagParameters scmTagParameters ) |
55 | |
throws ScmException |
56 | |
{ |
57 | 0 | TfsCommand command = createCommand( r, f, tag, scmTagParameters ); |
58 | |
|
59 | 0 | StringStreamConsumer out = new StringStreamConsumer(); |
60 | 0 | ErrorStreamConsumer err = new ErrorStreamConsumer(); |
61 | |
|
62 | 0 | int status = command.execute( out, err ); |
63 | 0 | if ( status != 0 || err.hasBeenFed() ) |
64 | |
{ |
65 | 0 | return new TagScmResult( command.getCommandString(), "Error code for TFS label command - " + status, |
66 | |
err.getOutput(), false ); |
67 | |
} |
68 | 0 | List<ScmFile> files = new ArrayList<ScmFile>(f.getFileList().size()); |
69 | 0 | for (File file : f.getFileList() ) |
70 | |
{ |
71 | 0 | files.add( new ScmFile( file.getPath(), ScmFileStatus.TAGGED ) ); |
72 | |
} |
73 | 0 | return new TagScmResult( command.getCommandString(), files ); |
74 | |
|
75 | |
} |
76 | |
|
77 | |
public TfsCommand createCommand( ScmProviderRepository r, ScmFileSet f, String tag, |
78 | |
ScmTagParameters scmTagParameters ) |
79 | |
{ |
80 | 1 | TfsScmProviderRepository tfsRepo = (TfsScmProviderRepository) r; |
81 | 1 | String url = tfsRepo.getServerPath(); |
82 | |
|
83 | 1 | TfsCommand command = new TfsCommand( "label", r, f, getLogger() ); |
84 | 1 | command.addArgument( tag ); |
85 | 1 | command.addArgument( url ); |
86 | 1 | command.addArgument( "-recursive" ); |
87 | 1 | command.addArgument( "-child:replace" ); |
88 | 1 | String message = scmTagParameters.getMessage(); |
89 | 1 | if ( message != null && !message.equals( "" ) ) |
90 | |
{ |
91 | 1 | command.addArgument( "-comment:" + message ); |
92 | |
} |
93 | 1 | return command; |
94 | |
} |
95 | |
|
96 | |
} |