|
1 | | -[](https://jitpack.io/#scm4j/scm4j-vcs-api) |
| 1 | +[](https://jitpack.io/#scm4j/scm4j-vcs-api) |
| 2 | +[](https://travis-ci.org/scm4j/scm4j-ai) |
| 3 | +[](https://coveralls.io/github/scm4j/scm4j-vcs-api?branch=master) |
2 | 4 |
|
3 | 5 | # Overview |
4 | 6 | 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 | 7 | scm4j-vcs-api provides: |
6 | 8 | - 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 [scm4j-vcs-test](https://github.com/scm4j/scm4j-vcs-test) |
| 9 | +- Set of functional tests wchich 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) |
8 | 10 | - Working copy management for operations which must be executed on local file system |
9 | 11 |
|
10 | 12 | # Terms |
@@ -36,6 +38,8 @@ scm4j-vcs-api provides: |
36 | 38 | - The latest commit or state of a branch |
37 | 39 | - Master Branch |
38 | 40 | - "Master" for Git, "Trunk" for SVN etc |
| 41 | +- `VCSTag`, Tag |
| 42 | + - Contains tag name, tag log message, tag author and `VCSCommit` instance which represents the tagged commit |
39 | 43 |
|
40 | 44 | # Using VCS interface |
41 | 45 | IVCS interface consists of few basic vcs functions. |
@@ -64,27 +68,38 @@ Note: null passed as a branch name is considered as Master Branch. Any non-null |
64 | 68 | - `fileRelativePath` is a path to file within `branchName` branch |
65 | 69 | - The Head file state is used |
66 | 70 | - Use `String getFileContent(String branchName, String fileRelativePath)` overload to use UTF-8 encoding by default |
67 | | -- `String setFileContent(String branchName, String filePath, String content, String commitMessage)` |
| 71 | +- `VCSCommit setFileContent(String branchName, String filePath, String content, String commitMessage)` |
68 | 72 | - Rewrites a file with path `filePath` within branch `branchName` with content `content` and applies `commitMessage` message to commit |
69 | 73 | - Creates the file and its parent folders if doesn't exists |
70 | | - - Returns commit id (hash, revision number etc) |
71 | 74 | - `List<VCSDiffEntry> getBranchesDiff(String srcBranchName, String destBranchName)` |
72 | 75 | - Returns list of `VCSDiffEntry` showing what was made within branch `srcBranchName` relative to branch `destBranchName` |
73 | | - - Note: result is a commit which would be made on merging the branch `srcBranchName` into `destBranchName` |
| 76 | + - Note: result could be considered as a commit which would be made on merging the branch `srcBranchName` into `destBranchName` |
74 | 77 | - `Set<String> getBranches()` |
75 | 78 | - Returns list of names of all branches. Branches here are considered as user-created branches and Master Branch. I.e. any branch for Git, "Trunk" and any branch within "Branches" branch (not "Tags" branches) for SVN etc |
76 | 79 | - `List<String> getCommitMessages(Sting branchName, Integer limit)` |
77 | 80 | - Returns list of commit messages of branch `branchName` limited by `limit` in descending order |
78 | 81 | - `String getVCSTypeString` |
79 | 82 | - Returns short name of current IVCS implementation: "git", "svn" etc |
80 | | -- `String removeFile(String branchName, String filePath, String commitMessage)` |
81 | | - - 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` |
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 |
87 | | - |
| 83 | +- `VCSCommit removeFile(String branchName, String filePath, String commitMessage)` |
| 84 | + - Removes the file with path `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 |
| 85 | +- `List<VCSCommit> getCommitsRange(String branchName, String firstCommitId, String untilCommitId)` |
| 86 | + - Returns ordered list of all commits located between commits specified by `firstCommitId` and `untilCommitId` inclusively within branch `branchName` |
| 87 | + - If `firstCommitId` is null then all commits until commit specified by `untilCommitId` inclusively are fetched |
| 88 | + - If `untilCommitId` is null then all commits starting from commit specified by `firstCommitId` are fetched |
| 89 | +- `List<VCSCommit> getCommitsRange(String branchName, String firstCommitId, WalkDirection direction, int limit)` |
| 90 | + - Returns ordered list of `limit` commits (0 is unlimited) starting from commit specified by `firstCommitId` in direction specified by `direction` |
| 91 | + - If `firstCommitId` is null then commits are starting at branch `branchName` first commit (for ASC direction) or at head of branch (for DESC direction) |
| 92 | +- `VCSCommit getHeadCommit(String branchName)` |
| 93 | + - Returns `VCSCommit` instance pointing to the head (last) commit of the branch `branchName` |
| 94 | +- `Boolean fileExists(String branchName, String filePath)` |
| 95 | + - Returns true if the file with path `filePath` exists in repository in branch `branchName`, false otherwise |
| 96 | +- `VCSTag createTag(String branchName, String tagName, String tagMessage) throws EVCSTagExists` |
| 97 | + - Creates a tag named `tagName` with log message `tagMessage` on a Head of branch `branchName` |
| 98 | +- `List<VCSTag> getTags()` |
| 99 | + - Returns list of all tags |
| 100 | +- `VCSTag getLastTag()` |
| 101 | + - Returns the last created tag |
| 102 | + |
88 | 103 | # Using Locked Working Copy |
89 | 104 | 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: |
90 | 105 | - The simple way to allocate place for vcs operations execution |
@@ -186,7 +201,7 @@ Lock way: `new FileOutputStream(lockFile, false).getChannel.lock()` |
186 | 201 | - Throw exceptions from scm4j.vcs.api.exceptions package. Abstract Test checks throwning of these exceptions. |
187 | 202 | - Implement functional tests |
188 | 203 | - Create VCSAbstractTest subclass within test package, implement all abstract methods |
189 | | - - Normally test class should not include any test, just @After\@Before methods. All necessary functional testing is implemented within VCSAbstractTest |
| 204 | + - Normally test class should not include any test, just @After and @Before methods. All necessary functional testing is implemented within VCSAbstractTest |
190 | 205 | - See [scm4j-vcs-test](https://github.com/scm4j/scm4j-vcs-test) for details |
191 | 206 | - Example of gradle usage to export IVCS implementation, its sources and javadoc as separate single JARs: |
192 | 207 | ```gradle |
|
0 commit comments