1 package org.apache.maven.scm.provider.git.jgit;
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
24 import org.apache.maven.scm.ScmException;
25 import org.apache.maven.scm.ScmFileSet;
26 import org.apache.maven.scm.command.info.InfoScmResult;
27 import org.apache.maven.scm.provider.git.AbstractGitScmProvider;
28 import org.apache.maven.scm.provider.git.command.GitCommand;
29 import org.apache.maven.scm.provider.git.command.info.GitInfoItem;
30 import org.apache.maven.scm.provider.git.jgit.command.add.JGitAddCommand;
31 import org.apache.maven.scm.provider.git.jgit.command.blame.JGitBlameCommand;
32 import org.apache.maven.scm.provider.git.jgit.command.branch.JGitBranchCommand;
33 import org.apache.maven.scm.provider.git.jgit.command.changelog.JGitChangeLogCommand;
34 import org.apache.maven.scm.provider.git.jgit.command.checkin.JGitCheckInCommand;
35 import org.apache.maven.scm.provider.git.jgit.command.checkout.JGitCheckOutCommand;
36 import org.apache.maven.scm.provider.git.jgit.command.diff.JGitDiffCommand;
37 import org.apache.maven.scm.provider.git.jgit.command.info.JGitInfoCommand;
38 import org.apache.maven.scm.provider.git.jgit.command.list.JGitListCommand;
39 import org.apache.maven.scm.provider.git.jgit.command.remoteinfo.JGitRemoteInfoCommand;
40 import org.apache.maven.scm.provider.git.jgit.command.status.JGitStatusCommand;
41 import org.apache.maven.scm.provider.git.jgit.command.tag.JGitTagCommand;
42 import org.apache.maven.scm.repository.ScmRepositoryException;
43
44
45
46
47
48
49
50 public class JGitScmProvider
51 extends AbstractGitScmProvider
52 {
53
54
55
56 protected GitCommand getAddCommand()
57 {
58 return new JGitAddCommand();
59 }
60
61
62
63
64 protected GitCommand getBranchCommand()
65 {
66 return new JGitBranchCommand();
67 }
68
69
70
71
72 protected GitCommand getChangeLogCommand()
73 {
74 return new JGitChangeLogCommand();
75 }
76
77
78
79
80 protected GitCommand getCheckInCommand()
81 {
82 return new JGitCheckInCommand();
83 }
84
85
86
87
88 protected GitCommand getCheckOutCommand()
89 {
90 return new JGitCheckOutCommand();
91 }
92
93
94
95
96 protected GitCommand getDiffCommand()
97 {
98 return new JGitDiffCommand();
99 }
100
101
102
103
104 protected GitCommand getExportCommand()
105 {
106 throw new UnsupportedOperationException( "getExportCommand" );
107 }
108
109
110
111
112 protected GitCommand getRemoveCommand()
113 {
114 throw new UnsupportedOperationException( "getRemoveCommand" );
115 }
116
117
118
119
120 protected GitCommand getStatusCommand()
121 {
122 return new JGitStatusCommand();
123 }
124
125
126
127
128 protected GitCommand getTagCommand()
129 {
130 return new JGitTagCommand();
131 }
132
133
134
135
136 protected GitCommand getUpdateCommand()
137 {
138 throw new UnsupportedOperationException( "getUpdateCommand" );
139 }
140
141
142
143
144 protected GitCommand getListCommand()
145 {
146 return new JGitListCommand();
147 }
148
149
150
151
152 public GitCommand getInfoCommand()
153 {
154 return new JGitInfoCommand();
155 }
156
157
158
159
160 protected String getRepositoryURL( File path )
161 throws ScmException
162 {
163
164
165
166 InfoScmResult result = info( null, new ScmFileSet( new File( "" ), path ), null );
167
168 if ( result.getInfoItems().size() != 1 )
169 {
170 throw new ScmRepositoryException(
171 "Cannot find URL: " + ( result.getInfoItems().size() == 0 ? "no" : "multiple" )
172 + " items returned by the info command" );
173 }
174
175 return ( (GitInfoItem) result.getInfoItems().get( 0 ) ).getURL();
176 }
177
178
179
180
181 protected GitCommand getBlameCommand()
182 {
183 return new JGitBlameCommand();
184 }
185
186
187
188
189 protected GitCommand getRemoteInfoCommand()
190 {
191 return new JGitRemoteInfoCommand();
192 }
193 }