31
31
import com .projectkaiser .scm .vcs .api .exceptions .EVCSException ;
32
32
import com .projectkaiser .scm .vcs .api .exceptions .EVCSFileNotFound ;
33
33
import com .projectkaiser .scm .vcs .api .workingcopy .IVCSLockedWorkingCopy ;
34
- import com .projectkaiser .scm .vcs .api .workingcopy .IVCSRepository ;
34
+ import com .projectkaiser .scm .vcs .api .workingcopy .IVCSRepositoryWorkspace ;
35
35
36
36
public class GitVCS implements IVCS {
37
37
38
38
private CredentialsProvider credentials ;
39
39
40
- IVCSRepository repo ;
40
+ IVCSRepositoryWorkspace repo ;
41
41
42
42
public CredentialsProvider getCredentials () {
43
43
return credentials ;
44
44
}
45
45
46
- public GitVCS (IVCSRepository repo ) {
46
+ public GitVCS (IVCSRepositoryWorkspace repo ) {
47
47
this .repo = repo ;
48
48
}
49
49
@@ -77,6 +77,7 @@ public void createBranch(String srcBranchName, String newBranchName, String comm
77
77
.setRefSpecs (refSpec )
78
78
.setCredentialsProvider (credentials )
79
79
.call ();
80
+ git .getRepository ().close ();
80
81
}
81
82
}
82
83
} catch (RefAlreadyExistsException e ) {
@@ -119,6 +120,7 @@ public void deleteBranch(String branchName, String commitMessage) {
119
120
.setRemote ("origin" )
120
121
.setCredentialsProvider (credentials )
121
122
.call ();
123
+ git .getRepository ().close ();
122
124
}
123
125
}
124
126
} catch (GitAPIException e ) {
@@ -149,14 +151,15 @@ public Git getLocalGit(IVCSLockedWorkingCopy wc) {
149
151
.setURI (repo .getRepoUrl ())
150
152
.setCredentialsProvider (credentials )
151
153
.setNoCheckout (true )
152
- .call ();
154
+ .call ()
155
+ .close ();
153
156
} catch (GitAPIException e ) {
154
157
throw new EVCSException (e );
155
158
}
156
159
157
160
}
158
-
159
- return new Git ( gitRepo );
161
+ Git res = new Git ( gitRepo );
162
+ return res ;
160
163
}
161
164
162
165
@ Override
@@ -170,7 +173,11 @@ public PKVCSMergeResult merge(String sourceBranchUrl, String destBranchUrl, Stri
170
173
.setCredentialsProvider (credentials )
171
174
.call ();
172
175
173
- checkout (destBranchUrl , git );
176
+ git
177
+ .checkout ()
178
+ .setCreateBranch (false )
179
+ .setName (destBranchUrl )
180
+ .call ();
174
181
175
182
MergeResult mr = git
176
183
.merge ()
@@ -195,7 +202,7 @@ public PKVCSMergeResult merge(String sourceBranchUrl, String destBranchUrl, Stri
195
202
.setMode (ResetType .HARD )
196
203
.call ();
197
204
} catch (Exception e ) {
198
- wc .setCorrupt (true );
205
+ wc .setCorrupted (true );
199
206
}
200
207
} else {
201
208
git
@@ -205,7 +212,7 @@ public PKVCSMergeResult merge(String sourceBranchUrl, String destBranchUrl, Stri
205
212
.setCredentialsProvider (credentials )
206
213
.call ();
207
214
}
208
-
215
+ git . getRepository (). close ();
209
216
return res ;
210
217
}
211
218
}
@@ -216,14 +223,6 @@ public PKVCSMergeResult merge(String sourceBranchUrl, String destBranchUrl, Stri
216
223
}
217
224
}
218
225
219
- private void checkout (String destBranchUrl , Git git ) throws GitAPIException {
220
- git
221
- .checkout ()
222
- .setCreateBranch (false )
223
- .setName (destBranchUrl )
224
- .call ();
225
- }
226
-
227
226
@ Override
228
227
public void setCredentials (String user , String password ) {
229
228
credentials = new UsernamePasswordCredentialsProvider (user , password );
@@ -237,7 +236,7 @@ public void setProxy(final String host, final int port, String proxyUser, String
237
236
238
237
@ Override
239
238
public List <Proxy > select (URI uri ) {
240
- if (uri .toString ().contains (repo .getRepoUrl ())) {
239
+ if (uri .toString ().toLowerCase (). contains (repo .getRepoUrl (). toLowerCase ())) {
241
240
return Arrays .asList (new Proxy (Type .HTTP , InetSocketAddress
242
241
.createUnresolved (host , port )));
243
242
} else {
@@ -276,6 +275,8 @@ public String getFileContent(String branchName, String fileRelativePath, String
276
275
.addPath (fileRelativePath )
277
276
.setName (branchName )
278
277
.call ();
278
+ git .getRepository ().close ();
279
+
279
280
File file = new File (wc .getFolder (), fileRelativePath );
280
281
281
282
try {
@@ -330,6 +331,7 @@ public void setFileContent(String branchName, String filePath, String content, S
330
331
.setRemote ("origin" )
331
332
.setCredentialsProvider (credentials )
332
333
.call ();
334
+ git .getRepository ().close ();
333
335
}
334
336
}
335
337
} catch (GitAPIException e ) {
0 commit comments