Skip to content

Commit cbf60be

Browse files
committed
Merge branch 'master' into B1
# Conflicts: # build.gradle
2 parents eff5401 + 4d524b2 commit cbf60be

23 files changed

+80
-74
lines changed

README.md

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
[![Release](https://jitpack.io/v/ProjectKaiser/pk-vcs-api.svg)](https://jitpack.io/#ProjectKaiser/pk-vcs-api)
1+
[![Release](https://jitpack.io/v/scm4j/scm4j-vcs-api.svg)](https://jitpack.io/#scm4j/scm4j-vcs-api)
22

33
# Overview
4-
Pk-vcs-api is set of base classes and interfaces to build VCS support (Git, SVN, etc) libraries which exposes basic vcs-related operations: merge, branch create etc. Pk-vcs-api consists of:
5-
Pk-vcs-api provides:
4+
scm4j-vcs-api is set of base classes and interfaces to build VCS support (Git, SVN, etc) libraries which exposes basic vcs-related operations: merge, branch create etc.
5+
scm4j-vcs-api provides:
66
- A simple interface to implement basic VCS-related operations
7-
- Set of functional tests which are common to each VCS implementation. Functional tests for a certain VCS implementation are done by implementing few abstract methods of base test class. Implemented in [pk-vcs-test](https://github.com/ProjectKaiser/pk-vcs-test)
7+
- Set of functional tests which are common to each VCS implementation. Functional tests for a certain VCS implementation are done by implementing few abstract methods of base test class. Implemented in [scm4j-vcs-test](https://github.com/scm4j/scm4j-vcs-test)
88
- Working copy management for operations which must be executed on local file system
99

1010
# Terms
@@ -19,15 +19,15 @@ Pk-vcs-api provides:
1919
- Locked Working Copy, LWC
2020
- A separate folder used to execute VCS-related operations which are need to be executed on a local file system. E.g. in Git it is need to make checkout somewhere on local file system before making a merge.
2121
- Named automatically as uuid, located within Repository Workspace folder
22-
- Can be reused for another vcs-related operation automatically. I.e. checkouted once, then switches between branches.
22+
- Can be reused for another vcs-related operation automatically. I.e. checked out once, then switches between branches.
2323
- Deletes automatically if last VCS-related operation left the Working Copy in corrupted state, i.e. can not be reverted, re-checked out and so on
2424
- Lock File
2525
- A special empty file which is used to show if according LWC locked or free. If a Lock File has exclusive file system lock then the according LWC folder is considered as locked, otherwise as free
2626
- Lock way: `new FileOutputStream(lockFile, false).getChannel.lock()`
2727
- named as "lock_" + <LWC folder name>
2828
- Abstract Test
2929
- Base functional tests of VCS-related functions which are exposed by IVCS. To implement functional test for a certain IVCS implementation (Git, SVN, etc) just implement VCSAbstractTest subclass
30-
- Implemented as [pk-vcs-test](https://github.com/ProjectKaiser/pk-vcs-test) separate project
30+
- Implemented as [scm4j-vcs-test](https://github.com/scm4j/scm4j-vcs-test) separate project
3131
- `VCSMergeResult`, Merge Result
3232
- Result of vcs merge operation. Could be successful or failed. Provides list of conflicting files if failed.
3333
- `VCSDiffEntry`, Diff Entry
@@ -82,6 +82,8 @@ Note: null passed as a branch name is considered as Master Branch. Any non-null
8282
- Returns commit id (hash, revision number etc)
8383
- `List<VCSCommit> getCommitsRange(String branchName, String afterCommitId, String untilCommitId);`
8484
- Returns ordered list of all commits located between commits specified by `aftercommitId` and `untilCommitId` within branch `branchName`
85+
- If `aftercommitId` is null then all commits until commit specified by `untilCommitId` are fetched
86+
- If `untilCommitId` is null then all commits after commit specified by `afterCommitId` are fetched
8587

8688
# Using Locked Working Copy
8789
Let's assume we developing a multiuser server which has ability to merge branches of user's repositories. So few users could request to merge theirs branches of different repositories simultaneously. For example, Git merge operation consists of few underlying operations (check in\out, merge itself, push) which must be executed on a local file system in a certain folder. So we have following requirements:
@@ -94,14 +96,14 @@ Locked Working Copy is a solution which solves these requirements by providing a
9496
LWC usage scenario:
9597
- 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)
9698
```java
97-
public static final String WORKSPACE_DIR = System.getProperty("java.io.tmpdir") + "pk-vcs-workspaces";
99+
public static final String WORKSPACE_DIR = System.getProperty("java.io.tmpdir") + "scm4j-vcs-workspaces";
98100
...
99101
IVCSWorkspace workspace = new VCSWorkspace(WORKSPACE_DIR);
100102
...
101103
```
102104
- 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
103105
```java
104-
String repoUrl = "https://github.com/ProjectKaiser/pk-vcs-api";
106+
String repoUrl = "https://github.com/scm4j/scm4j-vcs-api";
105107
IVCSRepositoryWorkspace repoWorkspace = workspace.getVCSRepositoryWorkspace(repoUrl);
106108
```
107109
- Obtain Locked Working Copy from Repository Workspace when necessary. The obtained LWC will represent a locked folder within Workspace Repository. The folder is protected from simultaneously execute different vcs-related operations by another thread or even process. Use try-with-resources or try...finally to release Working Copy after vcs-related operations will be completed
@@ -120,8 +122,8 @@ LWC usage scenario:
120122
- If a Working copy can not be reused due of VCS system data damage (e.g. .git, .svn folders) or due of vcs Working Copy can not be cleaned, reverted, switched, checked out etc, execute `IVCSLockedWorkingCopy.setCorrupted(true)`. LWC folder will be deleted on close.
121123

122124
# Folder structure
123-
- Workspace Home folder (e.g. c:\temp\pk-vcs-workspces\)
124-
- Repository Workspace 2 (e.g. <Workspace Home>\https_github_com_projectkaiser\
125+
- Workspace Home folder (e.g. c:\temp\scm4j-vcs-workspces\)
126+
- Repository Workspace 2 (e.g. <Workspace Home>\https_github_com_scm4j\
125127
- Working Copy 1
126128
- Branch1 is checked out, merging executes
127129
- Working Copy 2
@@ -138,7 +140,7 @@ So actually a Lock File is locked, not the LWC folder itself.
138140
Lock way: `new FileOutputStream(lockFile, false).getChannel.lock()`
139141

140142
# Developing IVCS implementation
141-
- Add github-hosted VCS API as maven artifact using [jitpack.io](https://jitpack.io/). As an example, add following to gradle.build file:
143+
- Add github-hosted scm4j-vcs-api and scm4j-vcs-test projects as maven artifacts using [jitpack.io](https://jitpack.io/). As an example, add following to gradle.build file:
142144
```gradle
143145
allprojects {
144146
repositories {
@@ -148,12 +150,12 @@ Lock way: `new FileOutputStream(lockFile, false).getChannel.lock()`
148150

149151
dependencies {
150152
// versioning: master-SNAPSHOT (lastest build, unstable), + (lastest release, stable) or certain version (e.g. 1.0)
151-
compile 'com.github.ProjectKaiser:pk-vcs-api:+'
152-
testCompile 'com.github.ProjectKaiser:pk-vcs-test:+'
153+
compile 'com.github.scm4j:scm4j-vcs-api:+'
154+
testCompile 'com.github.scm4j:scm4j-vcs-test:+'
153155
}
154156
```
155157
This will include VCS API (IVCS, LWC) and Abstract Test to your project.
156-
Also you can download release jars from https://github.com/ProjectKaiser/pk-vcs-api/releases, https://github.com/ProjectKaiser/pk-vcs-test/releases
158+
Also you can download release jars from https://github.com/scm4j/scm4j-vcs-api/releases, https://github.com/scm4j/scm4j-vcs-test/releases
157159
- Implement IVCS interface
158160
- IVCS implementation should be separate object which normally holds all VCS-related data within
159161
- Normally IVCSRepositoryWorkspace instance is passed to constructor and stored within IVCS implementation.
@@ -181,11 +183,11 @@ Lock way: `new FileOutputStream(lockFile, false).getChannel.lock()`
181183
// ...
182184
}
183185
```
184-
- Throw exceptions from exceptions package. Abstract Test checks throwning of these exceptions.
186+
- Throw exceptions from scm4j.vcs.api.exceptions package. Abstract Test checks throwning of these exceptions.
185187
- Implement functional tests
186188
- Create VCSAbstractTest subclass within test package, implement all abstract methods
187189
- Normally test class should not include any test, just @After\@Before methods. All necessary functional testing is implemented within VCSAbstractTest
188-
- See [pk-vcs-test](https://github.com/ProjectKaiser/pk-vcs-test) for details
190+
- See [scm4j-vcs-test](https://github.com/scm4j/scm4j-vcs-test) for details
189191
- Example of gradle usage to export IVCS implementation, its sources and javadoc as separate single JARs:
190192
```gradle
191193
task sourcesJar(type: Jar, dependsOn: classes) {
@@ -206,6 +208,6 @@ artifacts {
206208
After that the `gralde build` command will produce 3 JARs.
207209

208210
# See also
209-
- [pk-vcs-test](https://github.com/ProjectKaiser/pk-vcs-test)
210-
- [pk-vcs-git](https://github.com/ProjectKaiser/pk-vcs-git)
211-
- [pk-vcs-svn](https://github.com/ProjectKaiser/pk-vcs-svn)
211+
- [scm4j-vcs-test](https://github.com/scm4j/scm4j-vcs-test)
212+
- [scm4j-vcs-git](https://github.com/scm4j/scm4j-vcs-git)
213+
- [scm4j-vcs-svn](https://github.com/scm4j/scm4j-vcs-svn)

build.gradle

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@ 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 {
1111
mavenCentral()
1212
}
1313

1414
dependencies {
15-
testCompile 'junit:junit:4.12'
16-
testCompile 'org.mockito:mockito-core:2.0.62-beta'
17-
18-
compile 'commons-io:commons-io:2.4'
15+
testCompile 'junit:junit:4.12'
16+
testCompile 'org.mockito:mockito-core:2.0.62-beta'
17+
18+
compile 'commons-io:commons-io:[0,)'
1919
}
2020

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

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-3.4-bin.zip

settings.gradle

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

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
package com.projectkaiser.scm.vcs.api;
1+
package org.scm4j.vcs.api;
22

33
import java.util.List;
44
import java.util.Set;
55

6-
import com.projectkaiser.scm.vcs.api.exceptions.EVCSFileNotFound;
6+
import org.scm4j.vcs.api.exceptions.EVCSFileNotFound;
7+
import org.scm4j.vcs.api.workingcopy.IVCSWorkspace;
78

89
public interface IVCS {
910
void createBranch(String srcBranchName, String dstBranchName, String commitMessage);
@@ -35,4 +36,6 @@ public interface IVCS {
3536
String removeFile(String branchName, String filePath, String commitMessage);
3637

3738
List<VCSCommit> getCommitsRange(String branchName, String afterCommitId, String untilCommitId);
39+
40+
IVCSWorkspace getWorkspace();
3841
}

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

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

33
public enum VCSChangeType {
44

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

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

33
public class VCSCommit {
4-
private String id;
5-
private String logMessage;
6-
private String author;
4+
private final String id;
5+
private final String logMessage;
6+
private final String author;
77

88
public String getAuthor() {
99
return author;

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

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

33
public class VCSDiffEntry {
44

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

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

33
import java.util.ArrayList;
44
import java.util.List;
55

66
public class VCSMergeResult {
77

88
private Boolean success;
9-
private List<String> conflictingFiles = new ArrayList<String>();
9+
private List<String> conflictingFiles = new ArrayList<>();
1010

1111
public Boolean getSuccess() {
1212
return success;

src/main/java/com/projectkaiser/scm/vcs/api/exceptions/EVCSBranchExists.java renamed to src/main/java/org/scm4j/vcs/api/exceptions/EVCSBranchExists.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.projectkaiser.scm.vcs.api.exceptions;
1+
package org.scm4j.vcs.api.exceptions;
22

33
public class EVCSBranchExists extends EVCSException {
44

0 commit comments

Comments
 (0)