Skip to content

Commit f164dba

Browse files
author
Denis
committed
tests done, gradle binaries added
1 parent 3279481 commit f164dba

File tree

6 files changed

+106
-301
lines changed

6 files changed

+106
-301
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
hs_err_pid*
1313
/.gradle/
1414
/.settings
15-
/gradle
1615
/.classpath
1716
/.project
1817
/build/

build.gradle

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,20 @@ repositories {
1616
}
1717

1818
defaultTasks 'build';
19-
20-
dependencies {
21-
compile 'com.github.ProjectKaiser:pk-vcs-api:master-SNAPSHOT'
19+
20+
dependencies {
21+
compile 'com.github.ProjectKaiser:pk-vcs-api:master-SNAPSHOT'
2222
compile 'commons-logging:commons-logging:1.2'
2323
compile 'org.eclipse.jgit:org.eclipse.jgit:4.3.0.201604071810-r'
2424

2525
testCompile 'org.kohsuke:github-api:1.75'
2626
testCompile 'org.mockito:mockito-core:2.0.62-beta'
2727
testCompile 'junit:junit:4.12'
28-
28+
testCompile 'com.github.ProjectKaiser:pk-vcs-test:master-SNAPSHOT'
2929
}
3030

31+
32+
3133
task sourcesJar(type: Jar, dependsOn: classes) {
3234
classifier = 'sources'
3335
from sourceSets.main.allSource

gradle/wrapper/gradle-wrapper.jar

52.4 KB
Binary file not shown.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#Fri Apr 22 10:26:49 GMT+03:00 2016
2+
distributionBase=GRADLE_USER_HOME
3+
distributionPath=wrapper/dists
4+
zipStoreBase=GRADLE_USER_HOME
5+
zipStorePath=wrapper/dists
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-2.12-bin.zip

src/main/java/com/projectkaiser/scm/vcs/GitVCS.java

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,19 @@
3131
import com.projectkaiser.scm.vcs.api.exceptions.EVCSException;
3232
import com.projectkaiser.scm.vcs.api.exceptions.EVCSFileNotFound;
3333
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;
3535

3636
public class GitVCS implements IVCS {
3737

3838
private CredentialsProvider credentials;
3939

40-
IVCSRepository repo;
40+
IVCSRepositoryWorkspace repo;
4141

4242
public CredentialsProvider getCredentials() {
4343
return credentials;
4444
}
4545

46-
public GitVCS(IVCSRepository repo) {
46+
public GitVCS(IVCSRepositoryWorkspace repo) {
4747
this.repo = repo;
4848
}
4949

@@ -77,6 +77,7 @@ public void createBranch(String srcBranchName, String newBranchName, String comm
7777
.setRefSpecs(refSpec)
7878
.setCredentialsProvider(credentials)
7979
.call();
80+
git.getRepository().close();
8081
}
8182
}
8283
} catch (RefAlreadyExistsException e) {
@@ -119,6 +120,7 @@ public void deleteBranch(String branchName, String commitMessage) {
119120
.setRemote("origin")
120121
.setCredentialsProvider(credentials)
121122
.call();
123+
git.getRepository().close();
122124
}
123125
}
124126
} catch (GitAPIException e) {
@@ -149,14 +151,15 @@ public Git getLocalGit(IVCSLockedWorkingCopy wc) {
149151
.setURI(repo.getRepoUrl())
150152
.setCredentialsProvider(credentials)
151153
.setNoCheckout(true)
152-
.call();
154+
.call()
155+
.close();
153156
} catch (GitAPIException e) {
154157
throw new EVCSException(e);
155158
}
156159

157160
}
158-
159-
return new Git(gitRepo);
161+
Git res = new Git(gitRepo);
162+
return res;
160163
}
161164

162165
@Override
@@ -170,7 +173,11 @@ public PKVCSMergeResult merge(String sourceBranchUrl, String destBranchUrl, Stri
170173
.setCredentialsProvider(credentials)
171174
.call();
172175

173-
checkout(destBranchUrl, git);
176+
git
177+
.checkout()
178+
.setCreateBranch(false)
179+
.setName(destBranchUrl)
180+
.call();
174181

175182
MergeResult mr = git
176183
.merge()
@@ -195,7 +202,7 @@ public PKVCSMergeResult merge(String sourceBranchUrl, String destBranchUrl, Stri
195202
.setMode(ResetType.HARD)
196203
.call();
197204
} catch(Exception e) {
198-
wc.setCorrupt(true);
205+
wc.setCorrupted(true);
199206
}
200207
} else {
201208
git
@@ -205,7 +212,7 @@ public PKVCSMergeResult merge(String sourceBranchUrl, String destBranchUrl, Stri
205212
.setCredentialsProvider(credentials)
206213
.call();
207214
}
208-
215+
git.getRepository().close();
209216
return res;
210217
}
211218
}
@@ -216,14 +223,6 @@ public PKVCSMergeResult merge(String sourceBranchUrl, String destBranchUrl, Stri
216223
}
217224
}
218225

219-
private void checkout(String destBranchUrl, Git git) throws GitAPIException {
220-
git
221-
.checkout()
222-
.setCreateBranch(false)
223-
.setName(destBranchUrl)
224-
.call();
225-
}
226-
227226
@Override
228227
public void setCredentials(String user, String password) {
229228
credentials = new UsernamePasswordCredentialsProvider(user, password);
@@ -237,7 +236,7 @@ public void setProxy(final String host, final int port, String proxyUser, String
237236

238237
@Override
239238
public List<Proxy> select(URI uri) {
240-
if (uri.toString().contains(repo.getRepoUrl())) {
239+
if (uri.toString().toLowerCase().contains(repo.getRepoUrl().toLowerCase())) {
241240
return Arrays.asList(new Proxy(Type.HTTP, InetSocketAddress
242241
.createUnresolved(host, port)));
243242
} else {
@@ -276,6 +275,8 @@ public String getFileContent(String branchName, String fileRelativePath, String
276275
.addPath(fileRelativePath)
277276
.setName(branchName)
278277
.call();
278+
git.getRepository().close();
279+
279280
File file = new File(wc.getFolder(), fileRelativePath);
280281

281282
try {
@@ -330,6 +331,7 @@ public void setFileContent(String branchName, String filePath, String content, S
330331
.setRemote("origin")
331332
.setCredentialsProvider(credentials)
332333
.call();
334+
git.getRepository().close();
333335
}
334336
}
335337
} catch (GitAPIException e) {

0 commit comments

Comments
 (0)