Skip to content

Commit 36da8bb

Browse files
committed
Merge branch 'master' into B1
# Conflicts: # build.gradle
2 parents f2cbf1a + b57b28a commit 36da8bb

File tree

9 files changed

+48
-15
lines changed

9 files changed

+48
-15
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ hs_err_pid*
1414
/.*
1515
/bin
1616
build
17+
/*.iml

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,10 @@ Note: null passed as a branch name is considered as Master Branch. Any non-null
6464
- `fileRelativePath` is a path to file within `branchName` branch
6565
- The Head file state is used
6666
- Use `String getFileContent(String branchName, String fileRelativePath)` overload to use UTF-8 encoding by default
67-
- `void setFileContent(String branchName, String filePath, String content, String commitMessage)`
67+
- `String setFileContent(String branchName, String filePath, String content, String commitMessage)`
6868
- Rewrites a file with path `filePath` within branch `branchName` with content `content` and applies `commitMessage` message to commit
6969
- Creates the file and its parent folders if doesn't exists
70+
- Returns commit id (hash, revision number etc)
7071
- `List<VCSDiffEntry> getBranchesDiff(String srcBranchName, String destBranchName)`
7172
- Returns list of `VCSDiffEntry` showing what was made within branch `srcBranchName` relative to branch `destBranchName`
7273
- Note: result is a commit which would be made on merging the branch `srcBranchName` into `destBranchName`
@@ -76,8 +77,11 @@ Note: null passed as a branch name is considered as Master Branch. Any non-null
7677
- Returns list of commit messages of branch `branchName` limited by `limit` in descending order
7778
- `String getVCSTypeString`
7879
- Returns short name of current IVCS implementation: "git", "svn" etc
79-
- `void removeFile(String branchName, String filePath, String commitMessage)`
80+
- `String removeFile(String branchName, String filePath, String commitMessage)`
8081
- Removes the file located by `filePath` within branch `branchName`. Operation is executed as separate commit with `commitMessage` message attached. Note: filePath = "folder\file.txt" -> file.txt is removed, folder is kept
82+
- Returns commit id (hash, revision number etc)
83+
- `List<VCSCommit> getCommitsRange(String branchName, String afterCommitId, String untilCommitId);`
84+
- Returns ordered list of all commits located between commits specified by `aftercommitId` and `untilCommitId` within branch `branchName`
8185

8286
# Using Locked Working Copy
8387
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:

build.gradle

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
apply plugin: 'java'
22
apply plugin: 'maven'
33

4-
54
sourceCompatibility = JavaVersion.VERSION_1_7
65
targetCompatibility = JavaVersion.VERSION_1_7
76

87
group = 'com.projectkaiser.scm'
98
version = '1.1'
109

11-
1210
repositories {
1311
mavenCentral()
1412
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Wed Aug 10 11:04:58 GMT+03:00 2016
1+
#Sun Mar 26 13:53:29 MSK 2017
22
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-bin.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip

src/main/java/com/projectkaiser/scm/vcs/api/IVCS.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public interface IVCS {
2222

2323
String getFileContent(String branchName, String fileRelativePath) throws EVCSFileNotFound;
2424

25-
void setFileContent(String branchName, String filePath, String content, String commitMessage);
25+
String setFileContent(String branchName, String filePath, String content, String commitMessage);
2626

2727
List<VCSDiffEntry> getBranchesDiff(String srcBranchName, String destBranchName);
2828

@@ -32,5 +32,7 @@ public interface IVCS {
3232

3333
String getVCSTypeString();
3434

35-
void removeFile(String branchName, String filePath, String commitMessage);
35+
String removeFile(String branchName, String filePath, String commitMessage);
36+
37+
List<VCSCommit> getCommitsRange(String branchName, String afterCommitId, String untilCommitId);
3638
}

src/main/java/com/projectkaiser/scm/vcs/api/VCSChangeType.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ public enum VCSChangeType {
1212
MODIFY,
1313

1414
/** Delete an existing file from the project */
15-
DELETE;
15+
DELETE
1616
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package com.projectkaiser.scm.vcs.api;
2+
3+
public class VCSCommit {
4+
private String id;
5+
private String logMessage;
6+
private String author;
7+
8+
public String getAuthor() {
9+
return author;
10+
}
11+
12+
public String getId() {
13+
return id;
14+
}
15+
16+
public String getLogMessage() {
17+
return logMessage;
18+
}
19+
20+
public VCSCommit(String id, String logMessage, String author) {
21+
super();
22+
this.id = id;
23+
this.logMessage = logMessage;
24+
this.author = author;
25+
}
26+
27+
@Override
28+
public String toString() {
29+
return "VCSCommit [id=" + id + ", logMessage=" + logMessage + ", author=" + author + "]";
30+
}
31+
}

src/main/java/com/projectkaiser/scm/vcs/api/workingcopy/VCSLockedWorkingCopy.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,7 @@ private void init() {
5858
if (!lockFile.exists()) {
5959
continue;
6060
}
61-
if (!tryLockFile(lockFile)) {
62-
continue;
63-
} else {
61+
if (tryLockFile(lockFile)) {
6462
folder = file;
6563
state = VCSLockedWorkingCopyState.LOCKED;
6664
return;

src/test/java/com/projectkaiser/scm/vcs/api/workingcopy/VCSLockedWorkingCopyTest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,12 @@
99
import org.junit.Test;
1010

1111
public class VCSLockedWorkingCopyTest extends VCSWCTestBase {
12-
13-
private IVCSWorkspace w;
12+
1413
private IVCSRepositoryWorkspace r;
1514

1615
@Before
1716
public void setUp() {
18-
w = new VCSWorkspace(WORKSPACE_DIR);
17+
IVCSWorkspace w = new VCSWorkspace(WORKSPACE_DIR);
1918
r = w.getVCSRepositoryWorkspace(TEST_REPO_URL);
2019
}
2120

0 commit comments

Comments
 (0)