Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
CvsCheckInConsumer |
|
| 2.6666666666666665;2,667 |
1 | package org.apache.maven.scm.provider.cvslib.command.checkin; | |
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.ScmFile; | |
23 | import org.apache.maven.scm.ScmFileStatus; | |
24 | import org.apache.maven.scm.log.ScmLogger; | |
25 | import org.codehaus.plexus.util.cli.StreamConsumer; | |
26 | ||
27 | import java.util.ArrayList; | |
28 | import java.util.List; | |
29 | ||
30 | /** | |
31 | * @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a> | |
32 | * @author Olivier Lamy | |
33 | * @version $Id: CvsCheckInConsumer.java 1054455 2011-01-02 18:40:29Z olamy $ | |
34 | */ | |
35 | public class CvsCheckInConsumer | |
36 | implements StreamConsumer | |
37 | { | |
38 | 0 | private List<ScmFile> checkedInFiles = new ArrayList<ScmFile>(); |
39 | ||
40 | private String remotePath; | |
41 | ||
42 | private ScmLogger logger; | |
43 | ||
44 | public CvsCheckInConsumer( String remotePath, ScmLogger logger ) | |
45 | 0 | { |
46 | 0 | this.remotePath = remotePath; |
47 | ||
48 | 0 | this.logger = logger; |
49 | 0 | } |
50 | ||
51 | // ---------------------------------------------------------------------- | |
52 | // StreamConsumer Implementation | |
53 | // ---------------------------------------------------------------------- | |
54 | ||
55 | /** {@inheritDoc} */ | |
56 | public void consumeLine( String line ) | |
57 | { | |
58 | /* | |
59 | * The output from "cvs commit" contains lines like this: | |
60 | * | |
61 | * /path/rot/repo/test-repo/check-in/foo/bar,v <-- bar | |
62 | * | |
63 | * so this code assumes that it contains ",v <-- " | |
64 | * it's a committed file. | |
65 | */ | |
66 | ||
67 | 0 | if ( logger.isDebugEnabled() ) |
68 | { | |
69 | 0 | logger.debug( line ); |
70 | } | |
71 | ||
72 | 0 | int end = line.indexOf( ",v <-- " ); |
73 | ||
74 | 0 | if ( end == -1 ) |
75 | { | |
76 | 0 | return; |
77 | } | |
78 | ||
79 | 0 | String fileName = line.substring( 0, end ); |
80 | ||
81 | 0 | if ( !fileName.startsWith( remotePath ) ) |
82 | { | |
83 | 0 | return; |
84 | } | |
85 | ||
86 | 0 | fileName = fileName.substring( remotePath.length() ); |
87 | ||
88 | 0 | checkedInFiles.add( new ScmFile( fileName, ScmFileStatus.CHECKED_IN ) ); |
89 | 0 | } |
90 | ||
91 | public List<ScmFile> getCheckedInFiles() | |
92 | { | |
93 | 0 | return checkedInFiles; |
94 | } | |
95 | } |