Skip to content

Commit

Permalink
Initial commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
kaitoy committed Dec 15, 2016
0 parents commit 00f72e6
Show file tree
Hide file tree
Showing 43 changed files with 2,637 additions and 0 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**/*
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Eclipse
.project
.classpath
.settings/
bin/

# Gradle
build/
.gradle/
gradle-app.setting
.gradletasknamecache

3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "goslings-client"]
path = goslings-client
url = https://github.com/kaitoy/goslings-client.git
18 changes: 18 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#
# Dockerfile for Goslings
#

FROM java:8
MAINTAINER Kaito Yamada <kaitoy@pcap4j.org>

# Build Goslings.
RUN cd /usr/local/src/ && \
git clone --recursive -b master git://github.com/kaitoy/goslings.git
WORKDIR /usr/local/src/goslings
RUN ./gradlew --no-daemon build --info 2>&1 | tee build.log

# Generate sample script. (/usr/local/src/goslings/build/script/start.sh)
RUN ./gradlew --no-daemon genScript
RUN chmod +x build/script/start.sh

ENTRYPOINT ["/bin/sh", "/usr/local/src/goslings/build/script/start.sh"]
107 changes: 107 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
<img alt="Goslings" title="Goslings" src="https://github.com/kaitoy/goslings/raw/master/www/images/goslings-logo.png" width="70%" style="margin: 0px auto; display: block;" />

Goslings - Git Repository Visualizer
====================================

Contents
--------

* [What's Goslings](#whats-goslings)
* [Download](#download)
* [Build](#build)
* [How to Use](#how-to-use)
* [License](#license)
* [Contact](#contact)

What's Goslings
---------------
Goslings visualizes a Git repository.

A Git repository consists of objects, references, and an index.

* Object
* Blob: Represents a file, and contains the entire contents of the file.
* Tree: Represents a directory, and contains pointers to other trees and blobs.
* Commit: Represents a commit, and contains pointers to the parent commits and a pointer to a tree which represents the project's root directory.
* Annotated Tag: Represents an annotation of a tag, and contains a pointer to a commit.
* Reference
* Branch: A pointer to a commit.
* Tag: A pointer to a commit or a tag object.
* Symbolic Reference: A pointer to a branch or commit.
* Index: A structure containing paths to files and pointers to blobs.

Understanding this repository architecture helps you to master Git.
Goslings was created as a tool to learn the architecture.

![goslings.gif](https://github.com/kaitoy/goslings/raw/master/www/images/goslings.gif)

Download
--------

You can download Goslings from [GitHub Releases](https://github.com/kaitoy/goslings/releases)

Build
-----
1. Install [Git](https://git-scm.com/) and JDK 8+.
2. Download the project by `git clone --recursive https://github.com/kaitoy/goslings.git`.
3. In the project root directory, run `./gradlew build`.

How to Use
----------
JRE 8+ is required to run Goslings server.

Run `java -jar goslings/goslings-server/build/libs/goslings-server-0.0.1.jar --server.port 80` to start Goslings server.
After the startup completes, open `http://localhost` by a Web browser. You will see Goslings GUI like below:

![goslings-form](https://github.com/kaitoy/goslings/raw/master/www/images/goslings-form.png)

In the GUI, enter the path to or the URL of a Git repository (e.g. `C:\tmp\goslings\.git`, `/tmp/goslings/.git`, `https://github.com/kaitoy/goslings.git`, etc.)
and press the `Browse` button.
Then, Goslings server creates a symlink (if local) or a clone (if remote) of the repository into the working directory `goslings` in the tmp directory which `java.io.tmpdir` points to,
and shows the Git [objects](https://git-scm.com/book/en/v2/Git-Internals-Git-Objects) and [references](https://git-scm.com/book/en/v2/Git-Internals-Git-Objects) like below:

![goslings.png](https://github.com/kaitoy/goslings/raw/master/www/images/goslings.png)

* Legend:
* Pink Circle : Commit
* Green Triangle: Tree
* Purple Box : Blob
* Red Diamond : Tag Object
* Blue Box : (Symbolic) Reference
* Green Box : Index

* Operations
* Use your mouse wheel to zoom in and out.
* Drag and drop an object, a reference, or the index to move it.
* Drag and drop the background to slide the view.
* Single click on an object, a reference, or the index shows its contents.
* And double click on a commit or a tree shows trees and blobs under it.

* Configurations
* `com.github.kaitoy.goslings.server.reposDir`: Set this property to change the path of the working directory.
* `com.github.kaitoy.goslings.server.uriPrefix`: If this property is set, the Goslings server returns an error for a repository URI which doesn't start with the value of the property.

License
-------

Goslings is distributed under the MIT license.

Copyright (c) 2016 Kaito Yamada

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Contact
-------

Kaito Yamada (kaitoy@pcap4j.org)
90 changes: 90 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/*
* Goslings - Git Objects Browser
* https://github.com/kaitoy/goslings
* MIT licensed
*
* Copyright (C) 2016 Kaito Yamada
*/

buildscript {
repositories {
maven {
url 'https://plugins.gradle.org/m2/'
}
}
dependencies {
classpath "com.moowork.gradle:gradle-node-plugin:${nodePluginVer}"
}
}

allprojects {
version = '0.0.1'
}

project(':goslings-client') {
apply plugin: 'com.moowork.node'

node {
version = nodeVer
yarnVersion = yarnVer
download = true
}

def logsDir = file 'logs'
def log = new File(logsDir, 'build.log')
def errLog = new File(logsDir, 'build.err.log')
def lsep = System.properties['line.separator']
def cacheDir = file '.gradle'
def buildDir = file 'dist'
def nodeModsDir = file 'node_modules'

if (!logsDir.exists()) {
logsDir.mkdir()
}
else {
delete log
delete errLog
}

yarnSetup {
execOverrides {
it.standardOutput = new FileOutputStream(log, true)
it.errorOutput = new FileOutputStream(errLog, true)
}
doFirst { log << "### ${name} ###${lsep}" }
}

yarn {
execOverrides {
it.standardOutput = new FileOutputStream(log, true)
it.errorOutput = new FileOutputStream(errLog, true)
}
doFirst { log << "### ${name} ###${lsep}" }
}

task build(type: YarnTask, dependsOn: yarn) {
description "Build ${project.name}."
args = ['run', devBuild ? 'devBuild' : 'build']
execOverrides {
it.standardOutput = new FileOutputStream(log, true)
// it.errorOutput = new FileOutputStream(errLog, true)
}
inputs.property 'devBuild', devBuild
inputs.dir nodeModsDir
inputs.dir 'src'
inputs.file 'package.json'
inputs.file 'webpack.config.js'
outputs.dir buildDir
doFirst { log << "### ${name} ###${lsep}" }
}

task clean {
doLast{
delete cacheDir, logsDir, nodeModsDir, buildDir
}
}
}

if (gradle.startParameter.taskNames.contains('genScript')) {
apply from: 'gradle/genScript.gradle'
}
1 change: 1 addition & 0 deletions goslings-client
Submodule goslings-client added at 664a89
41 changes: 41 additions & 0 deletions goslings-server/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Goslings - Git Objects Browser
* https://github.com/kaitoy/goslings
* MIT licensed
*
* Copyright (C) 2016 Kaito Yamada
*/

buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath "org.springframework.boot:spring-boot-gradle-plugin:${springBootVer}"
}
}

repositories {
mavenCentral()
}

apply plugin: 'java'
apply plugin: 'spring-boot'

archivesBaseName = 'goslings-server'

[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
sourceCompatibility = 1.8
targetCompatibility = 1.8

processResources {
from project(':goslings-client').tasks.build
destinationDir = new File(sourceSets.main.output.resourcesDir, 'static')
}

dependencies {
compile "org.springframework.boot:spring-boot-starter-web:${springBootVer}"
compile "org.springframework.boot:spring-boot-starter-actuator:${springBootVer}"
compile "org.eclipse.jgit:org.eclipse.jgit:${jgitVer}"
compile 'org.springframework.boot:spring-boot-devtools'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Goslings - Git Objects Browser
* https://github.com/kaitoy/goslings
* MIT licensed
*
* Copyright (C) 2016 Kaito Yamada
*/

package com.github.kaitoy.goslings.server;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

/**
* The main class of this application.
*
* @author Kaito Yamada
*/
@SpringBootApplication
public class Application {

/**
* Main method of this application.
*
* @param args command line arguments.
*/
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Goslings - Git Objects Browser
* https://github.com/kaitoy/goslings
* MIT licensed
*
* Copyright (C) 2016 Kaito Yamada
*/

package com.github.kaitoy.goslings.server;

import org.springframework.beans.factory.annotation.Qualifier;

/**
* Collected constants of bean qualifiers.
*
* @author Kaito
* @see Qualifier
*/
public final class BeanQualifiers {

/**
*
*/
public static final String DAO_JGIT = "jgit";

private BeanQualifiers() {
throw new AssertionError("Don't instantiate me.");
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Goslings - Git Objects Browser
* https://github.com/kaitoy/goslings
* MIT licensed
*
* Copyright (C) 2016 Kaito Yamada
*/

package com.github.kaitoy.goslings.server.controller;

/**
* This is thrown if the server receives a request with illegal parameters.
* The message in this instance is supposed to be for users and is sent to client using
* {@link ErrorInfo}.
*
* @author Kaito Yamada
*/
public final class BadRequestException extends RuntimeException {

/**
*
*/
private static final long serialVersionUID = 721031396637761940L;

/**
*
*/
public BadRequestException() {
super();
}

/**
* @param message an error message for users.
*/
public BadRequestException(String message){
super(message);
}

/**
* @param message an error message for users.
* @param cause cause
*/
public BadRequestException(String message, Throwable cause){
super(message, cause);
}

/**
* @param cause cause
*/
public BadRequestException(Throwable cause){
super(cause);
}

}
Loading

0 comments on commit 00f72e6

Please sign in to comment.