Compare commits
10 Commits
e94b2e1d4b
...
d049197d7c
Author | SHA1 | Date | |
---|---|---|---|
d049197d7c | |||
da9a4e9602 | |||
36a3183fd3 | |||
e897278323 | |||
a6f0c57c16 | |||
ce969aa25c | |||
8dd083aae5 | |||
1159b87a53 | |||
b85099fbbd | |||
6569ec619a |
30
build.gradle
30
build.gradle
@ -1,30 +0,0 @@
|
||||
plugins {
|
||||
id 'org.jetbrains.kotlin.jvm' version "$kotlinVersion"
|
||||
id 'org.jetbrains.kotlin.plugin.serialization' version "$kotlinVersion"
|
||||
id 'application'
|
||||
}
|
||||
|
||||
version = '0.1.1'
|
||||
|
||||
mainClassName = 'me.msoucy.gbat.MainKt'
|
||||
description = 'Git By A Truck'
|
||||
|
||||
sourceCompatibility = 1.8
|
||||
targetCompatibility = 1.8
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
jcenter()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'org.jetbrains.kotlin:kotlin-stdlib'
|
||||
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.7'
|
||||
implementation "com.xenomachina:kotlin-argparser:$kotlin_argparser_version"
|
||||
implementation "org.jetbrains.exposed:exposed-core:$kotlin_exposed_version"
|
||||
implementation "org.jetbrains.exposed:exposed-dao:$kotlin_exposed_version"
|
||||
implementation "org.jetbrains.exposed:exposed-jdbc:$kotlin_exposed_version"
|
||||
implementation "org.xerial:sqlite-jdbc:3.30.1"
|
||||
implementation 'com.google.code.gson:gson:2.8.6'
|
||||
testImplementation 'junit:junit:4.12'
|
||||
}
|
39
build.gradle.kts
Normal file
39
build.gradle.kts
Normal file
@ -0,0 +1,39 @@
|
||||
plugins {
|
||||
kotlin("jvm") version "1.9.22"
|
||||
kotlin("plugin.serialization") version "1.9.22"
|
||||
application
|
||||
}
|
||||
|
||||
version = "0.1.1"
|
||||
|
||||
group = "me.msoucy.gbat"
|
||||
description = "Git By A Truck"
|
||||
|
||||
kotlin {
|
||||
jvmToolchain(21)
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
val argparserVersion: String by project
|
||||
val exposedVersion: String by project
|
||||
dependencies {
|
||||
implementation(kotlin("reflect"))
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.3")
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.0")
|
||||
implementation("com.xenomachina:kotlin-argparser:$argparserVersion")
|
||||
implementation("org.jetbrains.exposed:exposed-core:$exposedVersion")
|
||||
implementation("org.jetbrains.exposed:exposed-dao:$exposedVersion")
|
||||
implementation("org.jetbrains.exposed:exposed-jdbc:$exposedVersion")
|
||||
implementation("org.xerial:sqlite-jdbc:3.45.1.0")
|
||||
implementation("com.google.code.gson:gson:2.10.1")
|
||||
implementation("org.python:jython-standalone:2.7.2")
|
||||
implementation("org.pygments:pygments:2.5.2")
|
||||
testImplementation("junit:junit:4.12")
|
||||
}
|
||||
|
||||
application {
|
||||
mainClass.set("MainKt") // The main class of the application
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
kotlinVersion=1.3.71
|
||||
kotlin_argparser_version=2.0.7
|
||||
kotlin_exposed_version=0.25.1
|
||||
kotlinVersion=1.4.0
|
||||
argparserVersion=2.0.7
|
||||
exposedVersion=0.47.0
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
3
gradle/wrapper/gradle-wrapper.properties
vendored
3
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,5 +1,6 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
|
||||
networkTimeout=10000
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
288
gradlew
vendored
288
gradlew
vendored
@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env sh
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright 2015 the original author or authors.
|
||||
# Copyright © 2015-2021 the original authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@ -17,67 +17,98 @@
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
##
|
||||
#
|
||||
# Gradle start up script for POSIX generated by Gradle.
|
||||
#
|
||||
# Important for running:
|
||||
#
|
||||
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||
# noncompliant, but you have some other compliant shell such as ksh or
|
||||
# bash, then to run this script, type that shell name before the whole
|
||||
# command line, like:
|
||||
#
|
||||
# ksh Gradle
|
||||
#
|
||||
# Busybox and similar reduced shells will NOT work, because this script
|
||||
# requires all of these POSIX shell features:
|
||||
# * functions;
|
||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||
# * compound commands having a testable exit status, especially «case»;
|
||||
# * various built-in commands including «command», «set», and «ulimit».
|
||||
#
|
||||
# Important for patching:
|
||||
#
|
||||
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||
#
|
||||
# The "traditional" practice of packing multiple parameters into a
|
||||
# space-separated string is a well documented source of bugs and security
|
||||
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||
# options in "$@", and eventually passing that to Java.
|
||||
#
|
||||
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||
# see the in-line comments for details.
|
||||
#
|
||||
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
# Need this for relative symlinks.
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG=`dirname "$PRG"`"/$link"
|
||||
fi
|
||||
app_path=$0
|
||||
|
||||
# Need this for daisy-chained symlinks.
|
||||
while
|
||||
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||
[ -h "$app_path" ]
|
||||
do
|
||||
ls=$( ls -ld "$app_path" )
|
||||
link=${ls#*' -> '}
|
||||
case $link in #(
|
||||
/*) app_path=$link ;; #(
|
||||
*) app_path=$APP_HOME$link ;;
|
||||
esac
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >/dev/null
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=`basename "$0"`
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
# This is normally unused
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
MAX_FD=maximum
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
}
|
||||
} >&2
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
} >&2
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "`uname`" in
|
||||
CYGWIN* )
|
||||
cygwin=true
|
||||
;;
|
||||
Darwin* )
|
||||
darwin=true
|
||||
;;
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
NONSTOP* )
|
||||
nonstop=true
|
||||
;;
|
||||
case "$( uname )" in #(
|
||||
CYGWIN* ) cygwin=true ;; #(
|
||||
Darwin* ) darwin=true ;; #(
|
||||
MSYS* | MINGW* ) msys=true ;; #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
@ -87,9 +118,9 @@ CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
JAVACMD=$JAVA_HOME/bin/java
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
@ -98,7 +129,7 @@ Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD="java"
|
||||
JAVACMD=java
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
@ -106,80 +137,109 @@ location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||
MAX_FD_LIMIT=`ulimit -H -n`
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||
MAX_FD="$MAX_FD_LIMIT"
|
||||
fi
|
||||
ulimit -n $MAX_FD
|
||||
if [ $? -ne 0 ] ; then
|
||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||
fi
|
||||
else
|
||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||
fi
|
||||
fi
|
||||
|
||||
# For Darwin, add options to specify how the application appears in the dock
|
||||
if $darwin; then
|
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
|
||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||
SEP=""
|
||||
for dir in $ROOTDIRSRAW ; do
|
||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||
SEP="|"
|
||||
done
|
||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||
# Add a user-defined pattern to the cygpath arguments
|
||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||
fi
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
i=0
|
||||
for arg in "$@" ; do
|
||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||
|
||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||
else
|
||||
eval `echo args$i`="\"$arg\""
|
||||
fi
|
||||
i=`expr $i + 1`
|
||||
done
|
||||
case $i in
|
||||
0) set -- ;;
|
||||
1) set -- "$args0" ;;
|
||||
2) set -- "$args0" "$args1" ;;
|
||||
3) set -- "$args0" "$args1" "$args2" ;;
|
||||
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC3045
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
case $MAX_FD in #(
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC3045
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
fi
|
||||
|
||||
# Escape application args
|
||||
save () {
|
||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||
echo " "
|
||||
}
|
||||
APP_ARGS=`save "$@"`
|
||||
# Collect all arguments for the java command, stacking in reverse order:
|
||||
# * args from the command line
|
||||
# * the main class name
|
||||
# * -classpath
|
||||
# * -D...appname settings
|
||||
# * --module-path (only if needed)
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||
|
||||
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if "$cygwin" || "$msys" ; then
|
||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||
|
||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
for arg do
|
||||
if
|
||||
case $arg in #(
|
||||
-*) false ;; # don't mess with options #(
|
||||
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||
[ -e "$t" ] ;; #(
|
||||
*) false ;;
|
||||
esac
|
||||
then
|
||||
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||
fi
|
||||
# Roll the args list around exactly as many times as the number of
|
||||
# args, so each arg winds up back in the position where it started, but
|
||||
# possibly modified.
|
||||
#
|
||||
# NB: a `for` loop captures its iteration list before it begins, so
|
||||
# changing the positional parameters here affects neither the number of
|
||||
# iterations, nor the values presented in `arg`.
|
||||
shift # remove old arg
|
||||
set -- "$@" "$arg" # push replacement arg
|
||||
done
|
||||
fi
|
||||
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Collect all arguments for the java command;
|
||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||
# shell script including quotes and variable substitutions, so put them in
|
||||
# double quotes to make sure that they get re-expanded; and
|
||||
# * put everything else in single quotes, so that it's not re-expanded.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-classpath "$CLASSPATH" \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
if ! command -v xargs >/dev/null 2>&1
|
||||
then
|
||||
die "xargs is not available"
|
||||
fi
|
||||
|
||||
# Use "xargs" to parse quoted args.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
#
|
||||
# In Bash we could simply go:
|
||||
#
|
||||
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||
# set -- "${ARGS[@]}" "$@"
|
||||
#
|
||||
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||
# character that might be a shell metacharacter, then use eval to reverse
|
||||
# that process (while maintaining the separation between arguments), and wrap
|
||||
# the whole thing up as a single "set" statement.
|
||||
#
|
||||
# This will of course break if any of these variables contains a newline or
|
||||
# an unmatched quote.
|
||||
#
|
||||
|
||||
eval "set -- $(
|
||||
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||
xargs -n1 |
|
||||
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||
tr '\n' ' '
|
||||
)" '"$@"'
|
||||
|
||||
exec "$JAVACMD" "$@"
|
||||
|
30
gradlew.bat
vendored
30
gradlew.bat
vendored
@ -26,6 +26,7 @@ if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%"=="" set DIRNAME=.
|
||||
@rem This is normally unused
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@ -40,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto init
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
@ -54,7 +55,7 @@ goto fail
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto init
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
@ -64,21 +65,6 @@ echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:init
|
||||
@rem Get command-line arguments, handling Windows variants
|
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||
|
||||
:win9xME_args
|
||||
@rem Slurp the command line arguments.
|
||||
set CMD_LINE_ARGS=
|
||||
set _SKIP=2
|
||||
|
||||
:win9xME_args_slurp
|
||||
if "x%~1" == "x" goto execute
|
||||
|
||||
set CMD_LINE_ARGS=%*
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
@ -86,17 +72,19 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
set EXIT_CODE=%ERRORLEVEL%
|
||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||
exit /b %EXIT_CODE%
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
@ -1,14 +1,13 @@
|
||||
package me.msoucy.gbat
|
||||
|
||||
import java.io.File
|
||||
import org.jetbrains.exposed.sql.*
|
||||
import org.jetbrains.exposed.sql.transactions.transaction
|
||||
|
||||
import me.msoucy.gbat.models.CondensedAnalysis
|
||||
import me.msoucy.gbat.models.Condensation
|
||||
import me.msoucy.gbat.models.CondensedAnalysis
|
||||
import me.msoucy.gbat.models.KnowledgeModel
|
||||
import me.msoucy.gbat.models.LineModel
|
||||
import me.msoucy.gbat.models.RiskModel
|
||||
import org.jetbrains.exposed.sql.*
|
||||
import org.jetbrains.exposed.sql.transactions.transaction
|
||||
|
||||
fun analyze(
|
||||
riskModel: RiskModel,
|
||||
@ -26,7 +25,7 @@ fun analyze(
|
||||
changes.forEach { change ->
|
||||
changesProcessed++
|
||||
if (changesProcessed % 1000 == 0 && verbose) {
|
||||
System.err.println("Analyzer applied change #${changesProcessed}")
|
||||
System.err.println("Analyzer applied change #$changesProcessed")
|
||||
}
|
||||
lineModel.apply(change.eventType, change.lineNum, change.lineVal ?: "")
|
||||
knowledgeModel.apply(change.eventType, author, change.lineNum)
|
||||
|
@ -1,8 +1,9 @@
|
||||
package me.msoucy.gbat
|
||||
|
||||
import me.msoucy.gbat.models.RiskModel
|
||||
import me.msoucy.gbat.models.SummaryModel
|
||||
|
||||
import com.xenomachina.argparser.ArgParser
|
||||
import com.xenomachina.argparser.InvalidArgumentException
|
||||
import com.xenomachina.argparser.default
|
||||
import com.xenomachina.argparser.mainBody
|
||||
import java.io.File
|
||||
import java.util.concurrent.Executors
|
||||
import kotlin.math.pow
|
||||
@ -12,14 +13,9 @@ import kotlin.text.RegexOption
|
||||
import kotlin.text.startsWith
|
||||
import kotlinx.coroutines.*
|
||||
import kotlinx.coroutines.flow.*
|
||||
|
||||
import com.xenomachina.argparser.ArgParser
|
||||
import com.xenomachina.argparser.InvalidArgumentException
|
||||
import com.xenomachina.argparser.default
|
||||
import com.xenomachina.argparser.mainBody
|
||||
|
||||
import me.msoucy.gbat.models.RiskModel
|
||||
import me.msoucy.gbat.models.SummaryModel
|
||||
import org.jetbrains.exposed.sql.*
|
||||
import org.jetbrains.exposed.sql.transactions.transaction
|
||||
|
||||
val REALLY_LONG_TIME = 864000
|
||||
val DEFAULT_INTERESTING_RES = mutableListOf(
|
||||
@ -58,17 +54,14 @@ fun validateGit(exe : String) : String {
|
||||
|
||||
class GbatArgs(parser: ArgParser) {
|
||||
// Input options
|
||||
val interesting by parser.adding("--interesting", "-I",
|
||||
help="Regular expression to determine which files should be included in calculations.")
|
||||
val not_interesting by parser.adding("--not-interesting", "-N",
|
||||
help="Regular expression to determine which files should not be included in calculations.")
|
||||
val interesting by parser.adding("--interesting", "-I", help = "Regular expression to determine which files should be included in calculations.")
|
||||
val not_interesting by parser.adding("--not-interesting", "-N", help = "Regular expression to determine which files should not be included in calculations.")
|
||||
val case_sensitive by parser.flagging("Use case sensitive regexps when determining interesting files (default is case-insensitive)")
|
||||
val departed by parser.storing("--departed-file", "-D", help = "File listing departed devs, one per line", transform = ::File).default<File?>(null)
|
||||
val risk_file by parser.storing("--bus-risk-file", help = "File of dev=float lines (e.g. ejorgensen=0.4) with custom bus risks for devs", transform = ::File).default<File?>(null)
|
||||
val default_bus_risk by parser.storing("--default-bus-risk", help = "Default risk that a dev will be hit by a bus in your analysis timeframe (defaults to 0.1).") { toDouble() }.default(0.1)
|
||||
|
||||
// Multiprocessing options
|
||||
val num_git_procs by parser.storing("--num-git-procs", help="The number of git processes to run simultaneously (defaults to 3)") { toInt() }.default(3)
|
||||
val num_analyzer_procs by parser.storing("--num-analyzer-procs", help = "The number of analyzer processes to run (defaults to 3)") { toInt() }.default(3)
|
||||
|
||||
// Tuning options
|
||||
@ -87,11 +80,10 @@ class GbatArgs(parser: ArgParser) {
|
||||
fun main(args: Array<String>) = mainBody {
|
||||
ArgParser(args).parseInto(::GbatArgs).run {
|
||||
val outDir = File(output)
|
||||
if(outDir.isDirectory) {
|
||||
//throw InvalidArgumentException("Output directory already exists")
|
||||
}
|
||||
|
||||
outDir.delete()
|
||||
outDir.mkdirs()
|
||||
File(outDir, ".gitignore").writeText("*")
|
||||
|
||||
fun parse_interesting(theList: List<String>) =
|
||||
theList.map {
|
||||
@ -120,9 +112,7 @@ fun main(args: Array<String>) = mainBody {
|
||||
}
|
||||
return hasInterest
|
||||
}
|
||||
|
||||
fun GitRepo.interestingNames() = ls().split("\n").filter{ it.isInteresting() }
|
||||
val fnames = repo.interestingNames()
|
||||
val fnames = repo.ls().split("\n").filter { it.isInteresting() }
|
||||
|
||||
if (fnames.isEmpty()) {
|
||||
System.err.println("No interesting files found, exiting.")
|
||||
@ -136,30 +126,34 @@ fun main(args: Array<String>) = mainBody {
|
||||
val riskModel = RiskModel(riskThresh, default_bus_risk, risk_file, departed)
|
||||
|
||||
val dbFname = File(outDir, "summary.db")
|
||||
dbFname.delete();
|
||||
dbFname.delete()
|
||||
val summaryDb = Database.connect("jdbc:sqlite:${dbFname.absolutePath}", driver = "org.sqlite.JDBC")
|
||||
transaction(summaryDb) {
|
||||
addLogger(StdOutSqlLogger)
|
||||
// exec("PRAGMA journal_mode = OFF")
|
||||
// exec("PRAGMA synchronous = OFF")
|
||||
}
|
||||
val summaryModel = SummaryModel(summaryDb)
|
||||
val analysisExecutor = Executors.newFixedThreadPool(num_analyzer_procs).asCoroutineDispatcher()
|
||||
|
||||
runBlocking {
|
||||
flow {
|
||||
fnames.forEach { fname ->
|
||||
emit(parseHistory(repo, projectRootFile, File(fname)))
|
||||
fnames.map { fname ->
|
||||
async(analysisExecutor) {
|
||||
if (verbose) {
|
||||
println("Analyzing $fname")
|
||||
}
|
||||
}.map { history ->
|
||||
val history = parseHistory(repo, projectRootFile, File(projectRootFile, fname))
|
||||
analyze(riskModel, creation_constant, history, verbose)
|
||||
}.collect { analysis ->
|
||||
}
|
||||
}.awaitAll().forEach { analysis ->
|
||||
if (verbose) {
|
||||
println("Summarizing ${analysis.fileName}")
|
||||
}
|
||||
summaryModel.summarize(analysis)
|
||||
}
|
||||
}
|
||||
|
||||
if (verbose) {
|
||||
println("Rendering output")
|
||||
}
|
||||
renderSummary(projectRootFile, summaryModel, outDir)
|
||||
|
||||
// Render summary
|
||||
System.err.println("Done, summary is in ${outDir}/index.html")
|
||||
System.err.println("Done, summary is in $outDir/index.html")
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ package me.msoucy.gbat
|
||||
import java.io.File
|
||||
import kotlin.math.abs
|
||||
import kotlin.math.max
|
||||
|
||||
import me.msoucy.gbat.models.ChangeType
|
||||
import me.msoucy.gbat.models.Event
|
||||
|
||||
@ -14,14 +13,16 @@ data class HistoryItem(
|
||||
val authorDiffs: List<Pair<String, List<Event>>>
|
||||
)
|
||||
|
||||
fun parseHistory(repo : GitRepo,
|
||||
fun parseHistory(
|
||||
repo: GitRepo,
|
||||
projectRoot: File,
|
||||
fname: File,
|
||||
verbose : Boolean = false) : HistoryItem {
|
||||
verbose: Boolean = false
|
||||
): HistoryItem {
|
||||
val entries = repo.log(fname)
|
||||
val repoRoot = repo.root()
|
||||
if (verbose) {
|
||||
System.err.println("Parsing history for ${fname}")
|
||||
System.err.println("Parsing history for $fname")
|
||||
}
|
||||
return HistoryItem(repoRoot, projectRoot, fname,
|
||||
entries.map { (author, diff) ->
|
||||
|
@ -1,15 +1,11 @@
|
||||
package me.msoucy.gbat
|
||||
|
||||
import java.io.File
|
||||
|
||||
import me.msoucy.gbat.models.ProjectTreeNode
|
||||
import me.msoucy.gbat.models.ProjectTreeResult
|
||||
import me.msoucy.gbat.models.Statistics
|
||||
import me.msoucy.gbat.models.SummaryModel
|
||||
|
||||
import com.google.gson.GsonBuilder
|
||||
import java.io.File
|
||||
import me.msoucy.gbat.models.SummaryModel
|
||||
import org.jetbrains.exposed.sql.*
|
||||
import org.jetbrains.exposed.sql.transactions.transaction
|
||||
import org.python.util.PythonInterpreter
|
||||
|
||||
val NUM_RISKIEST_AUTHORS = 10
|
||||
val NUM_RISKIEST_FILES = 10
|
||||
@ -25,7 +21,7 @@ class SummaryRenderer(
|
||||
createFilesDir()
|
||||
renderSummaryJson(projectRoot)
|
||||
renderFileJson(projectRoot)
|
||||
// renderSrc(projectRoot)
|
||||
renderSrc(projectRoot)
|
||||
}
|
||||
|
||||
private fun renderSummaryJson(projectRoot: File) {
|
||||
@ -42,6 +38,32 @@ class SummaryRenderer(
|
||||
}
|
||||
|
||||
private fun createFilesDir() = filesDir.mkdirs()
|
||||
|
||||
private fun renderSrc(projectRoot: File) {
|
||||
val interpreter = PythonInterpreter()
|
||||
val cssFile = File(filesDir, "pygments.css")
|
||||
interpreter.exec("""
|
||||
from pygments.formatters import HtmlFormatter
|
||||
formatter = HtmlFormatter(linenos=True, lineanchors='gbab')
|
||||
formatCss = formatter.get_style_defs()
|
||||
""")
|
||||
cssFile.writeText(interpreter.get("formatCss", String::class.java))
|
||||
|
||||
summaryModel.projectFiles(projectRoot.absolutePath).forEach {
|
||||
val resultFile = File(filesDir, "${it.fileId}.html")
|
||||
val lines = summaryModel.fileLines(it.fileId)
|
||||
val body = lines.joinToString("\n")
|
||||
interpreter["fname"] = it.fname.toString()
|
||||
interpreter["body"] = body
|
||||
interpreter.exec("""
|
||||
from pygments import highlight
|
||||
from pygments.lexers import guess_lexer_for_filename
|
||||
lexer = guess_lexer_for_filename(fname, body)
|
||||
html = highlight(body, lexer, formatter)
|
||||
""")
|
||||
resultFile.writeText("""<link rel=stylesheet type="text/css" href="pygments.css">""" + interpreter.get("html", String::class.java))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun renderSummary(
|
||||
|
@ -14,6 +14,7 @@ class GitRepo(val projectRoot : File, val git_exe : String) {
|
||||
"--name-only",
|
||||
"-r",
|
||||
"HEAD",
|
||||
"--",
|
||||
projectRoot.absolutePath
|
||||
)
|
||||
val (out, _) = cmd.runCommand(projectRoot)
|
||||
@ -40,6 +41,7 @@ class GitRepo(val projectRoot : File, val git_exe : String) {
|
||||
"--follow", // Follow history through renames
|
||||
"--patience", // Use the patience diff algorithm
|
||||
"-p", // Show patches
|
||||
"--",
|
||||
fname.absolutePath
|
||||
)
|
||||
val (out, err) = cmd.runCommand(projectRoot)
|
||||
|
@ -1,30 +1,25 @@
|
||||
package me.msoucy.gbat.models
|
||||
|
||||
import java.io.File
|
||||
import java.nio.file.Path
|
||||
import java.nio.file.Paths
|
||||
import org.jetbrains.exposed.dao.id.IntIdTable
|
||||
import org.jetbrains.exposed.sql.*
|
||||
import org.jetbrains.exposed.sql.transactions.transaction
|
||||
|
||||
import me.msoucy.gbat.copyOf
|
||||
import me.msoucy.gbat.mutableCopyOf
|
||||
import org.jetbrains.exposed.dao.id.IntIdTable
|
||||
import org.jetbrains.exposed.sql.*
|
||||
import org.jetbrains.exposed.sql.transactions.transaction
|
||||
import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq
|
||||
|
||||
class KnowledgeModel(val db: Database, val constant: Double, val riskModel: RiskModel) {
|
||||
|
||||
class KnowledgeAcct(var knowledgeAcctId : Int,
|
||||
class KnowledgeAcct(
|
||||
var knowledgeAcctId: Int,
|
||||
var authors: List<String>,
|
||||
var authorsStr : String)
|
||||
var authorsStr: String
|
||||
)
|
||||
|
||||
object AuthorsTable : Table("authors") {
|
||||
val id = integer("authorid")
|
||||
object AuthorsTable : IntIdTable("authors", "authorid") {
|
||||
val author = text("author").uniqueIndex("authors_idx")
|
||||
override val primaryKey = PrimaryKey(id)
|
||||
}
|
||||
object KnowledgeAcctsTable : Table("knowledgeaccts") {
|
||||
val id = integer("knowledgeacctid")
|
||||
object KnowledgeAcctsTable : IntIdTable("knowledgeaccts", "knowledgeacctid") {
|
||||
val authors = text("authors").uniqueIndex("knowledgeacctsauthors_idx")
|
||||
override val primaryKey = PrimaryKey(id)
|
||||
}
|
||||
object KnowledgeAuthorsTable : Table("knowedgeaccts_authors") {
|
||||
val knowledgeacctid = integer("knowledgeacctid")
|
||||
@ -33,7 +28,7 @@ class KnowledgeModel(val db : Database, val constant : Double, val riskModel : R
|
||||
}
|
||||
object LineKnowledge : Table("lineknowledge") {
|
||||
val linenum = integer("linenum")
|
||||
val knowledgeacctid = integer("knowledgeacctid")
|
||||
val knowledgeacctid = integer("knowledgeacctid").references(KnowledgeAuthorsTable.knowledgeacctid)
|
||||
val knowledge = double("knowledge")
|
||||
}
|
||||
|
||||
@ -77,7 +72,7 @@ class KnowledgeModel(val db : Database, val constant : Double, val riskModel : R
|
||||
}
|
||||
|
||||
fun knowledgeSummary(lineNum: Int) = transaction(db) {
|
||||
LineKnowledge.select {
|
||||
LineKnowledge.selectAll().where {
|
||||
LineKnowledge.linenum eq lineNum
|
||||
}.map {
|
||||
val acct = getKnowledgeAcct(it[LineKnowledge.knowledgeacctid])
|
||||
@ -96,11 +91,11 @@ class KnowledgeModel(val db : Database, val constant : Double, val riskModel : R
|
||||
}
|
||||
|
||||
private fun getKnowledgeAcct(knowledgeAcctId: Int): KnowledgeAcct = transaction(db) {
|
||||
KnowledgeAcctsTable.select {
|
||||
KnowledgeAcctsTable.selectAll().where {
|
||||
KnowledgeAcctsTable.id eq knowledgeAcctId
|
||||
}.map {
|
||||
KnowledgeAcct(
|
||||
it[KnowledgeAcctsTable.id],
|
||||
it[KnowledgeAcctsTable.id].value,
|
||||
it[KnowledgeAcctsTable.authors].split("\n"),
|
||||
it[KnowledgeAcctsTable.authors]
|
||||
)
|
||||
@ -109,8 +104,8 @@ class KnowledgeModel(val db : Database, val constant : Double, val riskModel : R
|
||||
|
||||
private fun destroyLineKnowledge(knowledgeId: Int, lineNum: Int) = transaction(db) {
|
||||
LineKnowledge.deleteWhere {
|
||||
(LineKnowledge.knowledgeacctid eq knowledgeId) and
|
||||
(LineKnowledge.linenum eq lineNum)
|
||||
(knowledgeacctid eq knowledgeId) and
|
||||
(linenum eq lineNum)
|
||||
}
|
||||
}
|
||||
|
||||
@ -143,7 +138,7 @@ class KnowledgeModel(val db : Database, val constant : Double, val riskModel : R
|
||||
}
|
||||
|
||||
private fun knowledgeInAcct(knowledgeAcctId: Int, lineNum: Int) = transaction(db) {
|
||||
LineKnowledge.select {
|
||||
LineKnowledge.selectAll().where {
|
||||
(LineKnowledge.knowledgeacctid eq knowledgeAcctId) and
|
||||
(LineKnowledge.linenum eq lineNum)
|
||||
}.map {
|
||||
@ -152,7 +147,7 @@ class KnowledgeModel(val db : Database, val constant : Double, val riskModel : R
|
||||
}
|
||||
|
||||
private fun nonSafeAcctsWithKnowledgeOf(lineNum: Int) = transaction(db) {
|
||||
LineKnowledge.select {
|
||||
LineKnowledge.selectAll().where {
|
||||
(LineKnowledge.linenum eq lineNum) and
|
||||
(LineKnowledge.knowledgeacctid neq SAFE_KNOWLEDGE_ACCT_ID)
|
||||
}.map {
|
||||
@ -161,7 +156,7 @@ class KnowledgeModel(val db : Database, val constant : Double, val riskModel : R
|
||||
}
|
||||
|
||||
private fun allAcctsWithKnowledgeOf(lineNum: Int) = transaction(db) {
|
||||
LineKnowledge.select {
|
||||
LineKnowledge.selectAll().where {
|
||||
LineKnowledge.linenum eq lineNum
|
||||
}.map {
|
||||
it[LineKnowledge.knowledgeacctid]
|
||||
@ -169,7 +164,7 @@ class KnowledgeModel(val db : Database, val constant : Double, val riskModel : R
|
||||
}
|
||||
|
||||
private fun adjustKnowledge(knowledgeAcctId: Int, lineNum: Int, adjustment: Double) = transaction(db) {
|
||||
val lineExists = LineKnowledge.select {
|
||||
val lineExists = LineKnowledge.selectAll().where {
|
||||
(LineKnowledge.knowledgeacctid eq knowledgeAcctId) and
|
||||
(LineKnowledge.linenum eq lineNum)
|
||||
}.count() > 0
|
||||
@ -192,36 +187,35 @@ class KnowledgeModel(val db : Database, val constant : Double, val riskModel : R
|
||||
|
||||
private fun lookupOrCreateKnowledgeAcct(authors: List<String>) = transaction(db) {
|
||||
val authorStr = authors.sorted().joinToString("\n")
|
||||
var newId = KnowledgeAcctsTable.select {
|
||||
KnowledgeAcctsTable.selectAll().where {
|
||||
KnowledgeAcctsTable.authors eq authorStr
|
||||
}.map {
|
||||
it[KnowledgeAcctsTable.id]
|
||||
}.firstOrNull() ?: -1
|
||||
if (newId != -1) {
|
||||
it[KnowledgeAcctsTable.id].value
|
||||
}.firstOrNull() ?: run {
|
||||
KnowledgeAcctsTable.insert {
|
||||
it[KnowledgeAcctsTable.authors] = authorStr
|
||||
}
|
||||
newId = KnowledgeAcctsTable.select {
|
||||
val theNewId = KnowledgeAcctsTable.selectAll().where {
|
||||
KnowledgeAcctsTable.authors eq authorStr
|
||||
}.map {
|
||||
it[KnowledgeAcctsTable.id]
|
||||
it[KnowledgeAcctsTable.id].value
|
||||
}.first()
|
||||
|
||||
authors.map(::lookupOrCreateAuthor).forEach { authorId ->
|
||||
KnowledgeAuthorsTable.insert {
|
||||
it[KnowledgeAuthorsTable.knowledgeacctid] = newId
|
||||
it[KnowledgeAuthorsTable.authorid] = authorId
|
||||
it[KnowledgeAuthorsTable.knowledgeacctid] = theNewId
|
||||
it[KnowledgeAuthorsTable.authorid] = authorId.value
|
||||
}
|
||||
}
|
||||
theNewId
|
||||
}
|
||||
newId
|
||||
}
|
||||
|
||||
private fun lookupOrCreateAuthor(authorName: String) = transaction(db) {
|
||||
AuthorsTable.insertIgnore {
|
||||
it[author] = authorName
|
||||
}
|
||||
AuthorsTable.select {
|
||||
AuthorsTable.selectAll().where {
|
||||
AuthorsTable.author eq authorName
|
||||
}.first().let {
|
||||
it[AuthorsTable.id]
|
||||
@ -229,7 +223,7 @@ class KnowledgeModel(val db : Database, val constant : Double, val riskModel : R
|
||||
}
|
||||
|
||||
private fun totalLineKnowledge(linenum: Int) = transaction(db) {
|
||||
LineKnowledge.select {
|
||||
LineKnowledge.selectAll().where {
|
||||
LineKnowledge.linenum eq linenum
|
||||
}.map {
|
||||
it[LineKnowledge.knowledge]
|
||||
@ -240,11 +234,9 @@ class KnowledgeModel(val db : Database, val constant : Double, val riskModel : R
|
||||
SchemaUtils.dropDatabase()
|
||||
SchemaUtils.createMissingTablesAndColumns(AuthorsTable, KnowledgeAcctsTable, KnowledgeAuthorsTable, LineKnowledge)
|
||||
AuthorsTable.insertIgnore {
|
||||
it[id] = 1
|
||||
it[author] = ""
|
||||
}
|
||||
KnowledgeAcctsTable.insertIgnore {
|
||||
it[id] = 1
|
||||
it[authors] = ""
|
||||
}
|
||||
KnowledgeAuthorsTable.insertIgnore {
|
||||
|
@ -1,13 +1,5 @@
|
||||
package me.msoucy.gbat.models
|
||||
|
||||
import java.io.File
|
||||
import java.nio.file.Path
|
||||
import java.nio.file.Paths
|
||||
import kotlin.io.forEachLine
|
||||
import org.jetbrains.exposed.dao.id.IntIdTable
|
||||
import org.jetbrains.exposed.sql.*
|
||||
import org.jetbrains.exposed.sql.transactions.transaction
|
||||
|
||||
class LineModel() {
|
||||
inner class Line(var num: Int, var text: String)
|
||||
val model = mutableSetOf<Line>()
|
||||
|
@ -3,10 +3,12 @@ package me.msoucy.gbat.models
|
||||
import java.io.File
|
||||
import kotlin.io.forEachLine
|
||||
|
||||
class RiskModel(val threshold : Double,
|
||||
class RiskModel(
|
||||
val threshold: Double,
|
||||
val default: Double,
|
||||
val busRiskFile: File?,
|
||||
val departedFile : File?) {
|
||||
val departedFile: File?
|
||||
) {
|
||||
val departed = mutableSetOf<String>()
|
||||
val risks = mutableMapOf<String, Double>().withDefault { default }
|
||||
|
||||
|
@ -166,7 +166,7 @@ class SummaryModel(val db : Database) {
|
||||
}
|
||||
|
||||
fun fpath(fileId: Int): Path = transaction(db) {
|
||||
FilesTable.select {
|
||||
FilesTable.selectAll().where {
|
||||
FilesTable.id eq fileId
|
||||
}.first().let { row ->
|
||||
val dirs = reconsDirs(row[FilesTable.dirid])
|
||||
@ -176,7 +176,7 @@ class SummaryModel(val db : Database) {
|
||||
|
||||
fun projectFiles(project: String): List<ProjectFilesResult> = transaction(db) {
|
||||
val projectId = findOrCreateProject(project)
|
||||
(FilesTable innerJoin DirsTable).select {
|
||||
(FilesTable innerJoin DirsTable).selectAll().where {
|
||||
(FilesTable.dirid eq DirsTable.id) and
|
||||
(DirsTable.projectid eq projectId)
|
||||
}.map { row ->
|
||||
@ -192,7 +192,7 @@ class SummaryModel(val db : Database) {
|
||||
val parentDirIds = mutableListOf(0)
|
||||
while (parentDirIds.isNotEmpty()) {
|
||||
val parentId = parentDirIds.removeAt(0)
|
||||
DirsTable.select { DirsTable.parentdirid eq parentId }
|
||||
DirsTable.selectAll().where { DirsTable.parentdirid eq parentId }
|
||||
.forEach { row ->
|
||||
val dirId = row[DirsTable.id].value
|
||||
theTree.getOrPut(parentId) { ProjectTree() }.dirs.add(dirId)
|
||||
@ -203,13 +203,13 @@ class SummaryModel(val db : Database) {
|
||||
|
||||
// Then add the files
|
||||
theTree.entries.forEach { entry ->
|
||||
FilesTable.select { FilesTable.dirid eq entry.key }.forEach { row ->
|
||||
FilesTable.selectAll().where { FilesTable.dirid eq entry.key }.forEach { row ->
|
||||
entry.value.files[row[FilesTable.id].value] = FileEntry(row[FilesTable.fname])
|
||||
}
|
||||
entry.value.files.entries.forEach { (fileId, fileEntry) ->
|
||||
lineAllocations
|
||||
.slice(AllocationsTable.knowledge.sum(), AllocationsTable.risk.sum(), AllocationsTable.orphaned.sum())
|
||||
.select { LinesTable.fileid eq fileId }
|
||||
.select(AllocationsTable.knowledge.sum(), AllocationsTable.risk.sum(), AllocationsTable.orphaned.sum())
|
||||
.where { LinesTable.fileid eq fileId }
|
||||
.groupBy(LinesTable.fileid)
|
||||
.forEach { row ->
|
||||
fileEntry.stats.totKnowledge = row[AllocationsTable.knowledge.sum()] ?: 0.0
|
||||
@ -219,12 +219,12 @@ class SummaryModel(val db : Database) {
|
||||
}
|
||||
entry.value.files.entries.forEach { (fileId, fileEntry) ->
|
||||
lineAllocationGroups
|
||||
.slice(
|
||||
.select(
|
||||
AllocationsTable.knowledge.sum(),
|
||||
AllocationsTable.risk.sum(),
|
||||
AllocationsTable.orphaned.sum(),
|
||||
AuthorsGroupsTable.authors
|
||||
).select { LinesTable.fileid eq fileId }
|
||||
).where { LinesTable.fileid eq fileId }
|
||||
.groupBy(AllocationsTable.authorgroupid)
|
||||
.orderBy(AuthorsGroupsTable.authors)
|
||||
.forEach { row ->
|
||||
@ -239,24 +239,24 @@ class SummaryModel(val db : Database) {
|
||||
val projectTree = ProjectTreeResult(project, root)
|
||||
|
||||
allJoined
|
||||
.slice(
|
||||
.select(
|
||||
AllocationsTable.knowledge.sum(),
|
||||
AllocationsTable.risk.sum(),
|
||||
AllocationsTable.orphaned.sum(),
|
||||
AuthorsGroupsTable.authors
|
||||
)
|
||||
.select { DirsTable.projectid eq projectId }
|
||||
.where { DirsTable.projectid eq projectId }
|
||||
.groupBy(AuthorsGroupsTable.id)
|
||||
.forEach { row ->
|
||||
projectTree.authorRisks[row[AuthorsGroupsTable.authors]] = Statistics(row)
|
||||
}
|
||||
|
||||
manyJoined
|
||||
.slice(
|
||||
.select(
|
||||
AllocationsTable.knowledge.sum(),
|
||||
AllocationsTable.risk.sum(),
|
||||
AllocationsTable.orphaned.sum()
|
||||
).select {
|
||||
).where {
|
||||
DirsTable.projectid eq projectId
|
||||
}.first().let { row ->
|
||||
projectTree.stats = Statistics(row)
|
||||
@ -268,8 +268,8 @@ class SummaryModel(val db : Database) {
|
||||
fun fileSummary(fileId: Int) = transaction(db) {
|
||||
var fileTree = FileTree()
|
||||
lineAllocationGroups
|
||||
.slice(AllocationsTable.knowledge.sum(), AllocationsTable.risk.sum(), AllocationsTable.orphaned.sum(), AuthorsGroupsTable.authors)
|
||||
.select {
|
||||
.select(AllocationsTable.knowledge.sum(), AllocationsTable.risk.sum(), AllocationsTable.orphaned.sum(), AuthorsGroupsTable.authors)
|
||||
.where {
|
||||
LinesTable.fileid eq fileId
|
||||
}.groupBy(AuthorsGroupsTable.id).forEach { row ->
|
||||
val authors = row[AuthorsGroupsTable.authors]
|
||||
@ -279,29 +279,29 @@ class SummaryModel(val db : Database) {
|
||||
JoinType.LEFT,
|
||||
LinesTable.fileid, FilesTable.id
|
||||
)
|
||||
.slice(AllocationsTable.knowledge.sum(), AllocationsTable.risk.sum(), AllocationsTable.orphaned.sum())
|
||||
.select { LinesTable.fileid eq fileId }
|
||||
.select(AllocationsTable.knowledge.sum(), AllocationsTable.risk.sum(), AllocationsTable.orphaned.sum())
|
||||
.where { LinesTable.fileid eq fileId }
|
||||
.first().let { row ->
|
||||
fileTree.stats = Statistics(row)
|
||||
}
|
||||
|
||||
fileTree.name = FilesTable.select { FilesTable.id eq fileId }.map { it[FilesTable.fname] }.first()
|
||||
fileTree.name = FilesTable.selectAll().where { FilesTable.id eq fileId }.map { it[FilesTable.fname] }.first()
|
||||
|
||||
LinesTable.select { LinesTable.fileid eq fileId }
|
||||
LinesTable.selectAll().where { LinesTable.fileid eq fileId }
|
||||
.map { it[LinesTable.id].value }
|
||||
.forEach { lineId ->
|
||||
val lineDict = LineDict()
|
||||
lineAllocationGroups
|
||||
.slice(AllocationsTable.knowledge.sum(), AllocationsTable.risk.sum(), AllocationsTable.orphaned.sum(), AuthorsGroupsTable.authors)
|
||||
.select {
|
||||
.select(AllocationsTable.knowledge.sum(), AllocationsTable.risk.sum(), AllocationsTable.orphaned.sum(), AuthorsGroupsTable.authors)
|
||||
.where {
|
||||
LinesTable.id eq lineId
|
||||
}.groupBy(AuthorsGroupsTable.id).forEach { lineRow ->
|
||||
lineDict.authorRisks[lineRow[AuthorsGroupsTable.authors]] = Statistics(lineRow)
|
||||
}
|
||||
|
||||
lineAllocations
|
||||
.slice(AllocationsTable.knowledge.sum(), AllocationsTable.risk.sum(), AllocationsTable.orphaned.sum())
|
||||
.select {
|
||||
.select(AllocationsTable.knowledge.sum(), AllocationsTable.risk.sum(), AllocationsTable.orphaned.sum())
|
||||
.where {
|
||||
LinesTable.id eq lineId
|
||||
}.first().let {
|
||||
lineDict.stats = Statistics(it)
|
||||
@ -312,7 +312,7 @@ class SummaryModel(val db : Database) {
|
||||
}
|
||||
|
||||
fun fileLines(fileId: Int): List<String> = transaction(db) {
|
||||
LinesTable.select {
|
||||
LinesTable.selectAll().where {
|
||||
LinesTable.fileid eq fileId
|
||||
}.orderBy(LinesTable.linenum).map {
|
||||
it[LinesTable.line]
|
||||
@ -322,6 +322,7 @@ class SummaryModel(val db : Database) {
|
||||
private fun transformNode(tree: MutableMap<Int, ProjectTree>, dirId: Int): ProjectTreeNode {
|
||||
val result = ProjectTreeNode()
|
||||
tree[dirId]?.let { dirdict ->
|
||||
result.name = dirdict.name
|
||||
result.dirs = mutableListOf<ProjectTreeNode>().apply {
|
||||
dirdict.dirs.forEach {
|
||||
add(transformNode(tree, it))
|
||||
@ -337,7 +338,7 @@ class SummaryModel(val db : Database) {
|
||||
val segs = mutableListOf<String>()
|
||||
var newDirId = dirId
|
||||
while (newDirId != 0) {
|
||||
DirsTable.select {
|
||||
DirsTable.selectAll().where {
|
||||
DirsTable.id eq newDirId
|
||||
}.forEach {
|
||||
segs.add(it[DirsTable.dir])
|
||||
@ -361,7 +362,7 @@ class SummaryModel(val db : Database) {
|
||||
|
||||
private fun findOrCreateAuthorGroup(authors: List<String>): Int = transaction(db) {
|
||||
val authorsstr = authors.joinToString("\n")
|
||||
var authorGroupId = AuthorsGroupsTable.select {
|
||||
var authorGroupId = AuthorsGroupsTable.selectAll().where {
|
||||
AuthorsGroupsTable.authors eq authorsstr
|
||||
}.map {
|
||||
it[AuthorsGroupsTable.id].value
|
||||
@ -386,7 +387,7 @@ class SummaryModel(val db : Database) {
|
||||
AuthorsTable.insertIgnore {
|
||||
it[AuthorsTable.author] = author
|
||||
}
|
||||
ProjectTable.select {
|
||||
AuthorsTable.selectAll().where {
|
||||
AuthorsTable.author eq author
|
||||
}.map {
|
||||
it[AuthorsTable.id].value
|
||||
@ -412,7 +413,7 @@ class SummaryModel(val db : Database) {
|
||||
ProjectTable.insertIgnore {
|
||||
it[ProjectTable.project] = project
|
||||
}
|
||||
ProjectTable.select {
|
||||
ProjectTable.selectAll().where {
|
||||
ProjectTable.project eq project
|
||||
}.map {
|
||||
it[ProjectTable.id].value
|
||||
@ -425,7 +426,7 @@ class SummaryModel(val db : Database) {
|
||||
it[parentdirid] = parentDirId
|
||||
it[projectid] = projectId
|
||||
}
|
||||
DirsTable.select {
|
||||
DirsTable.selectAll().where {
|
||||
DirsTable.dir eq dirname
|
||||
DirsTable.parentdirid eq parentDirId
|
||||
DirsTable.projectid eq projectId
|
||||
@ -453,7 +454,7 @@ class SummaryModel(val db : Database) {
|
||||
val dirs = mutableListOf<String>()
|
||||
var parentDirId = dirId
|
||||
while (parentDirId != 0) {
|
||||
DirsTable.select {
|
||||
DirsTable.selectAll().where {
|
||||
DirsTable.id eq parentDirId
|
||||
}
|
||||
.first()
|
||||
|
Loading…
Reference in New Issue
Block a user