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
48 changes: 48 additions & 0 deletions lgit/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# LGit

### Description

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

### Usage

The following commands are available:<br/>
```
init
add <files>
rm <files>
status
commit <message> <files>
reset <to_revision>
log [from_revision]
checkout <revision>
checkout -r <files>
```

where *&lt;smth&gt;* means mandatory argument while *[smth]*
implies he optional one.<br/>
*revision* is represented as short (at least 7 symbols) or entire hash code.<br/>
*checkout -r <files>* is the replacement of *checkout -- <files>*.<br/>

### File hierarchy

.l_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 *git_milestone_2*
* run `./gradlew installDist`
* go to the `./build/install/l_git/bin/`
* execute `l_git` (or `l_git.bat` on Windows)
22 changes: 22 additions & 0 deletions lgit/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
group 'ru.ifmo'
version '1.0-SNAPSHOT'

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

mainClassName = "ru.ifmo.git.LGit"

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'
compile group: 'commons-codec', name: 'commons-codec', version: '1.11'
compile group: 'info.picocli', name: 'picocli', version: '3.6.0'
}
6 changes: 6 additions & 0 deletions lgit/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#Mon Oct 15 04:46:20 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 lgit/gradlew

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

84 changes: 84 additions & 0 deletions lgit/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 lgit/settings.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
rootProject.name = 'l_git'

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

import picocli.CommandLine;

import java.nio.file.Path;
import java.nio.file.Paths;

import java.util.List;

import ru.ifmo.git.commands.Git;
import ru.ifmo.git.entities.GitManager;
import ru.ifmo.git.util.CommandResult;

public class LGit {

private static Path cwd() {
return Paths.get(System.getProperty("user.dir"));
}

public static void main(String[] args) {
CommandLine commandLine = new CommandLine(new Git());
try {
List<CommandLine> parsed = commandLine.parse(args);

if (parsed.size() == 2) {
CommandLine command = parsed.get(1);
GitManager manager = new GitManager(cwd());
if (command.isUsageHelpRequested()) {
command.usage(System.out);
return;
}
CommandResult result = manager.executeCommand(command);
result.print();
} else {
commandLine.usage(System.out);
}
} catch (CommandLine.UnmatchedArgumentException e) {
System.out.println("l_git: no such command. See 'l_git --help'.");
}
}

}
Loading