1 package org.apache.maven.scm.provider.git.gitexe.command.update;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.maven.scm.util.AbstractConsumer;
23 import org.codehaus.plexus.util.StringUtils;
24
25 import java.util.regex.Matcher;
26 import java.util.regex.Pattern;
27
28
29
30
31
32 public class GitLatestRevisionCommandConsumer
33 extends AbstractConsumer
34 {
35
36
37
38
39 private static final Pattern LATESTREV_PATTERN = Pattern.compile( "^commit \\s*(.*)" );
40
41 private String latestRevision;
42
43
44 public void consumeLine( String line )
45 {
46 if ( logger.isDebugEnabled() )
47 {
48 logger.debug( "GitLatestRevisionCommandConsumer consumeLine : " + line );
49 }
50 if ( line == null || StringUtils.isEmpty( line ) )
51 {
52 return;
53 }
54
55 processGetLatestRevision( line );
56 }
57
58 public String getLatestRevision()
59 {
60 return latestRevision;
61 }
62
63
64
65
66
67
68 private void processGetLatestRevision( String line )
69 {
70 Matcher matcher = LATESTREV_PATTERN.matcher( line );
71 if ( matcher.matches() )
72 {
73 latestRevision = matcher.group( 1 );
74
75 }
76 }
77
78 }