https://github.com/miho/vgitarchive
https://github.com/miho/vgitarchive
Last synced: 9 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/miho/vgitarchive
- Owner: miho
- License: other
- Created: 2014-03-26T13:50:04.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2014-03-31T12:58:36.000Z (almost 12 years ago)
- Last Synced: 2025-02-15T21:20:02.895Z (11 months ago)
- Language: Java
- Size: 332 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE-TEMPLATE
Awesome Lists containing this project
README
VGitArchive
===========
[](https://travis-ci.org/miho/VGitArchive)
Library for creating versioned archive files (zip archive with internal Git repository). Use this library to add versioning support without needing additional repositories or external command line tools.
Internally VGitArchive uses [JGit](http://eclipse.org/jgit/). No external Git tools are necessary.
## How to Build VGitArchive
### Requirements
- Java >= 1.7
- Internet connection (dependencies are downloaded automatically)
- IDE: [Gradle](http://www.gradle.org/) Plugin (not necessary for command line usage)
### IDE
Open the `VGitArchive` [Gradle](http://www.gradle.org/) project in your favourite IDE (tested with NetBeans 7.4) and build it
by calling the `assemble` task.
### Command Line
Navigate to the [Gradle](http://www.gradle.org/) project (e.g., `path/to/VGitArchive`) and enter the following command
#### Bash (Linux/OS X/Cygwin/other Unix-like shell)
sh gradlew assemble
#### Windows (CMD)
gradlew assemble
## Code Sample:
```java
public class Main {
public static void main(String[] args) {
try (
// create and open the file
VersionedFile f = new VersionedFile(new File("project.vfile")).
create().open();
// prepare writing to a text file
BufferedWriter writer = new BufferedWriter(
new FileWriter(f.getContent().
getPath() + "/file1.txt"))) {
// first version
f.commit("empty file created");
// second version
writer.write("NanoTime 1: " + System.nanoTime() + "\n");
writer.flush();
f.commit("timestamp added");
// third version
writer.write("NanoTime 2: " + System.nanoTime() + "\n");
writer.flush();
f.commit("another timestamp added");
// checkout latest/newest version
f.checkoutLatestVersion();
// checkout previous versions one by one
while (f.hasPreviousVersion()) {
System.out.println("-> press enter to checkout the previous version");
System.in.read(); // waiting for user input
f.checkoutPreviousVersion();
}
} catch (IOException ex) {
ex.printStackTrace(System.out);
}
}
}
```