Skip to content

Commit b57b28a

Browse files
committed
getCommitsRange method added
1 parent 331e425 commit b57b28a

File tree

3 files changed

+41
-4
lines changed

3 files changed

+41
-4
lines changed

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:

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
}
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+
}

0 commit comments

Comments
 (0)