Skip to content

Commit 695892f

Browse files
committed
Merge branch 'master' into B1
# Conflicts: # build.gradle
2 parents f708daa + 20c26dc commit 695892f

File tree

8 files changed

+106
-104
lines changed

8 files changed

+106
-104
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ hs_err_pid*
1313
/.*
1414
/build/
1515
/bin/
16-
16+
*.iml

README.md

Lines changed: 74 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,74 @@
1-
[![Release](https://jitpack.io/v/ProjectKaiser/pk-vcs-git.svg)](https://jitpack.io/#ProjectKaiser/pk-vcs-git)
2-
3-
# Overview
4-
Pk-vcs-git is lightweight library for execute basic Git VCS operations (merge, branch create etc). It uses [pk-vcs-api](https://github.com/ProjectKaiser/pk-vcs-api) exposing IVCS implementation for Git repositories and [JGit](https://eclipse.org/jgit/) as framework to work with Git repositories.
5-
Features:
6-
- Branch create and remove
7-
- Branch merge with result return (success or list of conflicted files)
8-
- Branch commits messages list
9-
- Summarized diff between branches
10-
- Branches list
11-
- File content getting and setting
12-
- File create and remove
13-
14-
# Terms
15-
- Workspace Home
16-
- Home folder of all folders used by vcs-related operations. See [pk-vcs-api](https://github.com/ProjectKaiser/pk-vcs-api) for details
17-
- Repository Workspace
18-
- Folder for LWC folders related to Repository of one type. See [pk-vcs-api](https://github.com/ProjectKaiser/pk-vcs-api) for details
19-
- Locked Working Copy, LWC
20-
- Folder where vcs-related operations are executed. Provides thread- and process-safe repository of working folders. See [pk-vcs-api](https://github.com/ProjectKaiser/pk-vcs-api) for details
21-
- Test Repository
22-
- Git repository which is used to execute functional tests
23-
- File-based repository is used
24-
- Generates new before and deletes after each test
25-
- Named randomly (uuid is used)
26-
27-
# Using pk-vcs-git
28-
- Add github-hosted pk-vcs-git and pk-vcs-api projects as maven dependencies using [jitpack.io](https://jitpack.io/). As an example, add following to gradle.build file:
29-
```gradle
30-
allprojects {
31-
repositories {
32-
maven { url "https://jitpack.io" }
33-
}
34-
}
35-
36-
dependencies {
37-
// versioning: master-SNAPSHOT (lastest build, unstable), + (lastest release, stable) or certain version (e.g. 1.1)
38-
compile 'com.github.ProjectKaiser:pk-vcs-git:+'
39-
compile 'com.github.ProjectKaiser:pk-vcs-api:+'
40-
}
41-
```
42-
Or download release jars from https://github.com/ProjectKaiser/pk-vcs-git/releases, https://github.com/ProjectKaiser/pk-vcs-api/releases
43-
- Create Workspace Home instance providing path to any folder as Workspace Home folder path. This folder will contain repositories folders (if different vcs or repositories are used)
44-
```java
45-
public static final String WORKSPACE_DIR = System.getProperty("java.io.tmpdir") + "git-workspaces";
46-
...
47-
IVCSWorkspace workspace = new VCSWorkspace(WORKSPACE_DIR);
48-
...
49-
```
50-
- Obtain Repository Workspace from Workspace Home providing a certain Repository's url. The obtained Repository Workspace will represent a folder within Workspace Home dir which will contain all Working Copies relating to the provided VCS Repository
51-
```java
52-
String repoUrl = "https://github.com/ProjectKaiser/pk-vcs-api";
53-
IVCSRepositoryWorkspace repoWorkspace = workspace.getVCSRepositoryWorkspace(repoUrl);
54-
```
55-
- Create `GitVCS` instance providing Repository Workspace
56-
```java
57-
IVCS vcs = new GitVCS(repoWorkspace);
58-
```
59-
- Use methods of `IVCS` interface. See [pk-vcs-api](https://github.com/ProjectKaiser/pk-vcs-api) for details
60-
- Use `vcs.setProxy()` and `vcs.setCredentials()` if necessary
61-
62-
# Implementation details
63-
- [JGit](https://eclipse.org/jgit/) is used as framework to work with Git repositories
64-
- [Github](https://github.com/) is used as hosting of a Test Repository
65-
- LWC is obtained for each vcs operation.
66-
- `getLocalGit(IVCSLockedWorkingCopy wc)` method is used to create a Git implementation to execute vcs operations within `wc` Working Copy
67-
- If provided LWC is empty then current Test Repository is cloned into this LWC, otherwise just Git object is created
68-
- If `IVCS.setProxy()` is called then provided proxy is used for each url which contains `repoUrl`
69-
70-
# Functional testing
71-
- New local file-based Test Repository is created before each test and deletes automatically after each test
72-
- To execute tests just run GitVCSTest class as JUnit test. Tests from VCSAbstractTest class will be executed. See [pk-vcs-test](https://github.com/ProjectKaiser/pk-vcs-test) for details
73-
- Run `gradle test` to execute tests
74-
75-
# Limitations
76-
- Commit messages can not be attached to branch create and delete operations because Git does not exposes these operations as separate commits
1+
[![Release](https://jitpack.io/v/scm4j/scm4j-vcs-git.svg)](https://jitpack.io/#scm4j/scm4j-vcs-git)
2+
3+
# Overview
4+
scm4j-vcs-git is lightweight library for execute basic Git VCS operations (merge, branch create etc). It uses [scm4j-vcs-api](https://github.com/scm4j/scm4j-vcs-api) exposing IVCS implementation for Git repositories and [JGit](https://eclipse.org/jgit/) as framework to work with Git repositories.
5+
Features:
6+
- Branch create and remove
7+
- Branch merge with result return (success or list of conflicted files)
8+
- Branch commits messages list
9+
- Summarized diff between branches
10+
- Branches list
11+
- File content getting and setting
12+
- File create and remove
13+
14+
# Terms
15+
- Workspace Home
16+
- Home local folder of all folders used by vcs-related operations. See [scm4j-vcs-api](https://github.com/scm4j/scm4j-vcs-api) for details
17+
- Repository Workspace
18+
- Local folder for LWC folders related to Repository of one type. See [scm4j-vcs-api](https://github.com/scm4j/scm4j-vcs-api) for details
19+
- Locked Working Copy, LWC
20+
- Local folder where vcs-related operations are executed. Provides thread- and process-safe repository of working folders. See [scm4j-vcs-api](https://github.com/scm4j/scm4j-vcs-api) for details
21+
- Test Repository
22+
- Git repository which is used to execute functional tests
23+
- File-based repository is used
24+
- Generates new one before and deletes after each test
25+
- Named randomly (uuid is used)
26+
27+
# Using scm4j-vcs-git
28+
- Add github-hosted scm4j-vcs-git project as maven dependency using [jitpack.io](https://jitpack.io/). As an example, add following to gradle.build file:
29+
```gradle
30+
allprojects {
31+
repositories {
32+
maven { url "https://jitpack.io" }
33+
}
34+
}
35+
36+
dependencies {
37+
// versioning: master-SNAPSHOT (lastest build, unstable), + (lastest release, stable) or certain version (e.g. 1.1)
38+
compile 'com.github.scm4j:scm4j-vcs-git:+'
39+
}
40+
```
41+
Or download release jars from https://github.com/scm4j/scm4j-vcs-git/releases
42+
- Create Workspace Home instance providing path to any folder as Workspace Home folder path. This folder will contain repositories folders (if different vcs or repositories are used)
43+
```java
44+
public static final String WORKSPACE_DIR = System.getProperty("java.io.tmpdir") + "git-workspaces";
45+
...
46+
IVCSWorkspace workspace = new VCSWorkspace(WORKSPACE_DIR);
47+
...
48+
```
49+
- Obtain Repository Workspace from Workspace Home providing a certain Repository's url. The obtained Repository Workspace will represent a folder within Workspace Home dir which will contain all Working Copies relating to the provided VCS Repository
50+
```java
51+
String repoUrl = "https://github.com/MyUser/MyRepo";
52+
IVCSRepositoryWorkspace repoWorkspace = workspace.getVCSRepositoryWorkspace(repoUrl);
53+
```
54+
- Create `GitVCS` instance providing Repository Workspace
55+
```java
56+
IVCS vcs = new GitVCS(repoWorkspace);
57+
```
58+
- Use methods of `IVCS` interface. See [scm4j-vcs-api](https://github.com/scm4j/scm4j-vcs-api) for details
59+
- Use `vcs.setProxy()` and `vcs.setCredentials()` if necessary
60+
61+
# Implementation details
62+
- [JGit](https://eclipse.org/jgit/) is used as framework to work with Git repositories
63+
- Each vcs operation is executed within a LWC
64+
- `getLocalGit(IVCSLockedWorkingCopy wc)` method is used to create a Git implementation to execute vcs operations within `wc` Working Copy
65+
- If provided LWC is empty then current Test Repository is cloned into this LWC, otherwise existing repository is just switched to required branch
66+
- If `IVCS.setProxy()` is called then provided proxy is used for each url which contains `repoUrl`
67+
68+
# Functional testing
69+
- New local file-based Test Repository is created before each test and deletes automatically after each test
70+
- To execute tests just run GitVCSTest class as JUnit test. Tests from VCSAbstractTest class will be executed. See [scm4j-vcs-test](https://github.com/scm4j/scm4j-vcs-test) for details
71+
- Run `gradle test` to execute tests
72+
73+
# Limitations
74+
- Commit messages can not be attached to branch create and delete operations because Git does not exposes these operations as separate commits

build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ apply plugin: 'maven'
44
sourceCompatibility = JavaVersion.VERSION_1_7
55
targetCompatibility = JavaVersion.VERSION_1_7
66

7-
group = 'com.projectkaiser.scm'
7+
group = 'org.scm4j'
88
version = '1.3'
99

1010
repositories {
@@ -14,13 +14,13 @@ repositories {
1414
}
1515
}
1616

17-
dependencies {
18-
compile 'com.github.ProjectKaiser:pk-vcs-api:1.2'
17+
dependencies {
18+
compile 'com.github.scm4j:scm4j-vcs-api:master-SNAPSHOT'
1919
compile 'org.eclipse.jgit:org.eclipse.jgit:4.3.0.201604071810-r'
2020

2121
testCompile 'org.mockito:mockito-core:2.0.62-beta'
2222
testCompile 'junit:junit:4.12'
23-
testCompile 'com.github.ProjectKaiser:pk-vcs-test:1.2'
23+
testCompile 'com.github.scm4j:scm4j-vcs-test:master-SNAPSHOT'
2424
}
2525

2626
task sourcesJar(type: Jar, dependsOn: classes) {

gradle/wrapper/gradle-wrapper.jar

0 Bytes
Binary file not shown.

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#Fri Apr 07 15:10:42 GMT+03:00 2017
1+
#Fri Apr 07 15:30:56 GMT+03:00 2017
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME

settings.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
rootProject.name = 'pk-vcs-git'
1+
rootProject.name = 'scm4j-vcs-git'

src/main/java/com/projectkaiser/scm/vcs/GitVCS.java renamed to src/main/java/org/scm4j/vcs/GitVCS.java

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.projectkaiser.scm.vcs;
1+
package org.scm4j.vcs;
22

33
import java.io.ByteArrayOutputStream;
44
import java.io.File;
@@ -45,17 +45,17 @@
4545
import org.eclipse.jgit.transport.RefSpec;
4646
import org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider;
4747
import org.eclipse.jgit.treewalk.CanonicalTreeParser;
48-
49-
import com.projectkaiser.scm.vcs.api.IVCS;
50-
import com.projectkaiser.scm.vcs.api.VCSChangeType;
51-
import com.projectkaiser.scm.vcs.api.VCSCommit;
52-
import com.projectkaiser.scm.vcs.api.VCSDiffEntry;
53-
import com.projectkaiser.scm.vcs.api.VCSMergeResult;
54-
import com.projectkaiser.scm.vcs.api.exceptions.EVCSBranchExists;
55-
import com.projectkaiser.scm.vcs.api.exceptions.EVCSException;
56-
import com.projectkaiser.scm.vcs.api.exceptions.EVCSFileNotFound;
57-
import com.projectkaiser.scm.vcs.api.workingcopy.IVCSLockedWorkingCopy;
58-
import com.projectkaiser.scm.vcs.api.workingcopy.IVCSRepositoryWorkspace;
48+
import org.scm4j.vcs.api.IVCS;
49+
import org.scm4j.vcs.api.VCSChangeType;
50+
import org.scm4j.vcs.api.VCSCommit;
51+
import org.scm4j.vcs.api.VCSDiffEntry;
52+
import org.scm4j.vcs.api.VCSMergeResult;
53+
import org.scm4j.vcs.api.exceptions.EVCSBranchExists;
54+
import org.scm4j.vcs.api.exceptions.EVCSException;
55+
import org.scm4j.vcs.api.exceptions.EVCSFileNotFound;
56+
import org.scm4j.vcs.api.workingcopy.IVCSLockedWorkingCopy;
57+
import org.scm4j.vcs.api.workingcopy.IVCSRepositoryWorkspace;
58+
import org.scm4j.vcs.api.workingcopy.IVCSWorkspace;
5959

6060
public class GitVCS implements IVCS {
6161

@@ -618,8 +618,12 @@ private RevObject getInitialCommit(Git git) throws Exception {
618618
RevCommit root = rw.parseCommit(headId);
619619
rw.sort(RevSort.REVERSE);
620620
rw.markStart(root);
621-
RevCommit res = rw.next();
622-
return res;
621+
return rw.next();
623622
}
624623
}
624+
625+
@Override
626+
public IVCSWorkspace getWorkspace() {
627+
return repo.getWorkspace();
628+
}
625629
}

src/test/java/com/projectkaiser/scm/vcs/GitVCSTest.java renamed to src/test/java/org/scm4j/vcs/GitVCSTest.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.projectkaiser.scm.vcs;
1+
package org.scm4j.vcs;
22

33

44
import java.io.File;
@@ -9,15 +9,16 @@
99
import org.eclipse.jgit.lib.Repository;
1010
import org.junit.After;
1111
import org.mockito.Mockito;
12+
import org.scm4j.vcs.GitVCS;
13+
import org.scm4j.vcs.api.abstracttest.VCSAbstractTest;
1214

13-
import com.projectkaiser.scm.vcs.api.IVCS;
14-
import com.projectkaiser.scm.vcs.api.abstracttest.VCSAbstractTest;
15-
import com.projectkaiser.scm.vcs.api.workingcopy.IVCSRepositoryWorkspace;
15+
import org.scm4j.vcs.api.IVCS;
16+
import org.scm4j.vcs.api.workingcopy.IVCSRepositoryWorkspace;
1617

1718
public class GitVCSTest extends VCSAbstractTest {
1819

1920
private Repository localGitRepo;
20-
private RuntimeException testGitResetException = new RuntimeException("test exeption on git.reset()");
21+
private final RuntimeException testGitResetException = new RuntimeException("test exeption on git.reset()");
2122

2223
@Override
2324
public void setUp() throws Exception {
@@ -47,8 +48,7 @@ protected String getTestRepoUrl() {
4748

4849
@Override
4950
protected IVCS getVCS(IVCSRepositoryWorkspace mockedVCSRepo) {
50-
IVCS vcs = Mockito.spy(new GitVCS(mockedVCSRepo));
51-
return vcs;
51+
return Mockito.spy(new GitVCS(mockedVCSRepo));
5252
}
5353

5454
@Override

0 commit comments

Comments
 (0)