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