Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
build
.idea
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
language: java

jdk:
- oraclejdk8
15 changes: 15 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
group 'ru.spbau.shevchenko'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

а ещё по условию требовалось, кстати, краткое техническое описание внутреннего устройства.
-0.5

version '1.0-SNAPSHOT'

apply plugin: 'java'

sourceCompatibility = 1.8

repositories {
mavenCentral()
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

сюда бы хорошо добавить что-то для сборки jar' а с зависимостями. например, такое

dependencies {
testCompile group: 'junit', name: 'junit', version: '4.11'
compile group: 'org.jetbrains', name: 'annotations', version: '13.0'
}
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
6 changes: 6 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#Tue Mar 21 12:37:10 MSK 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.13-bin.zip
164 changes: 164 additions & 0 deletions gradlew

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

90 changes: 90 additions & 0 deletions gradlew.bat

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
rootProject.name = 'VCS'
rootProject.name = 'VCS'

97 changes: 97 additions & 0 deletions src/main/java/console/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
package console;

import vcs.EmptyCommitMessageException;
import vcs.NothingToCommitException;
import vcs.VCS;
import vcs.VCSException;

import java.io.IOException;
import java.util.List;

public class Main {
public static void main(String[] args) {
for (String arg : args) {
System.out.println(arg);
}
VCS vcs;
try {
vcs = new VCS();
} catch (Exception e) {
System.out.println(e.getMessage());
return;
}
switch (args[0]) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

а ещё нелплохо бы выводить help по набору команд и аргументов к ним

case "add": {
try {
vcs.add(args[1]);
} catch (IOException e) {
printException(e);
}
break;
}
case "commit": {
try {
vcs.commit(args[1]);
} catch (Exception e) {
printException(e);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ну, это как-то жёстко. пользователю лучше всё же говорить что-то более определённое, чем просто что случилось что-то плохое

}
break;
}
case "branch": {
if (args[1].equals("-d")) {
try {
vcs.deleteBranch(args[2]);
} catch (VCSException | IOException e) {
printException(e);
}
}
else {
try {
vcs.createBranch(args[1]);
} catch (Exception e) {
printException(e);
}
}
break;
}
case "log": {
try {
List<String> log = vcs.log();
for (String record : log) {
System.out.print(record);
System.out.println("\n---------------------\n");
}
} catch (IOException | ClassNotFoundException e) {
printException(e);
}
break;
}
case "checkout": {
try {
vcs.checkout(args[1]);
} catch (Exception e) {
printException(e);
}
break;
}
case "merge": {
try {
List<String> conflicts = vcs.merge(args[1]);
if (conflicts.isEmpty()) {
System.out.println("Merged successfully");
}
else {
System.out.println("Following files conflict:");
conflicts.forEach(System.out::println);
}
} catch (Exception e) {
printException(e);
}
}
}
}

private static void printException(Exception e) {
System.out.println(e.getClass().toString() + " " + e.getMessage());
}
}
4 changes: 4 additions & 0 deletions src/main/java/console/package-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/**
* Provides Main class for console interface.
*/
package console;
Loading