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
32 changes: 32 additions & 0 deletions task1_git/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Compiled class file
*.class

# Log file
*.log

# BlueJ files
*.ctxt

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

build
.gradle
.idea
*.iml
out/

.m_git
kek/
44 changes: 44 additions & 0 deletions task1_git/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Git

### Description

This repository contains simple draft of **git**.

### Usage

The following commands are available:<br/>
```
init
add <file>
commit <message> <files>
reset <to_commit>
log [from_commit]
checkout <commit>
```
where *&lt;smth&gt;* means mandatory argument while *[smth]*
implies he optional one.<br/>
*commit* is represented as short (at least 7 symbols) or entire hash code.


### File hierarchy

.m_git/
logs/
[log_file_for_branch]
storage/
[dir_as_hashcode]
[file]
index/
[file]
HEAD - file with information about current state


### How to build and run

In order to run this app, follow this steps:

* clone this repository
* checkout on branch *task1_git*
* run `./gradlew installDist`
* go to the `./build/install/task1_git/bin/`
* execute `task1_git` (or `task1_git.bat` on Windows)
21 changes: 21 additions & 0 deletions task1_git/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
group 'ru.ifmo'
version '1.0-SNAPSHOT'

apply plugin: 'java'
apply plugin: 'application'

mainClassName = "ru.ifmo.git.Git"

sourceCompatibility = 1.8

repositories {
mavenCentral()
}

dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
compile group: 'net.sourceforge.argparse4j', name: 'argparse4j', version: '0.2.0'
compile group: 'org.apache.commons', name: 'commons-io', version: '1.3.2'
implementation 'com.google.code.gson:gson:2.8.5'
}

6 changes: 6 additions & 0 deletions task1_git/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#Fri Sep 14 13:38:27 MSK 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.0-all.zip
172 changes: 172 additions & 0 deletions task1_git/gradlew

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

84 changes: 84 additions & 0 deletions task1_git/gradlew.bat

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

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

27 changes: 27 additions & 0 deletions task1_git/src/main/java/ru/ifmo/git/Git.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package ru.ifmo.git;

import ru.ifmo.git.masters.GitParser;
import ru.ifmo.git.util.*;

import net.sourceforge.argparse4j.inf.*;

public class Git {

public static void main(String[] args) {
GitParser gitParser = new GitParser();
try {
Namespace ns = gitParser.parseArgs(args);
Command command = (Command) ns.getAttrs().remove("cmd");
CommandResult result = command.execute(ns.getAttrs());
if(result.getStatus() != ExitStatus.SUCCESS) {
System.out.println("exit with code " + result.getStatus());
}
System.out.print(result.getMessage().read());
} catch (ArgumentParserException e) {
gitParser.handleError(e);
} catch (GitException e) {
System.out.print(e.getMessage());
}
}

}
Loading