nqminhuit / gis

Java Command Line Application which extends Git for supporting git-modules
1 stars 0 forks source link
cli git git-submodules graalvm-native-image java mandrel vertx

Java CI with Maven

Introduction

Build from source

Native image

(require docker/podman to build)

There are 2 GraalVM distributions: GraalVM CE and Mandrel. Since this app is written in Java completely, Mandrel is prefered.

cd gis
podman build -t gis . || return 1; podman create --name dkgis_ gis:latest; podman cp dkgis_:/app/gis/gis .; podman rm -f dkgis_

After the steps above, an executable file named gis will be created under project directory.

JVM

cd gis
mvn clean verify package

The executable jar file will be created at target/gis-<version>.jar

Usage

For more details, just run:

./gis --help

Generate completion for zsh:

./gis completion --directory ${fpath[1]}

Reload your zsh session, we can now press <TAB> for autocomplete.

Currently gis only support zsh for completion.

Config

Gis will read config from file at ~/.config/gis.config

Supported configs:

| key                     | description                                             | default value       |
|-------------------------+---------------------------------------------------------+---------------------|
| default_branches        | comma separated values indicate default branch values   | master,main,develop |
| feature_branch_prefixes | comma separated values indicate feature branch prefixes | feature/            |

Note: do NOT insert space into value part. don't:

master, main, develop

do:

master,main,develop

example:

default_branches=master,main,develop
feature_branch_prefixes=feature/

The reason that value parsing is not that smart is because that we use default Java core package java.util.Properties to parse values. We prefer Java's core over extra dependencies.

Comparison

notes:

status

status: git vs gis

command for generating the above numbers:

for i in {1..1000}; do { time git submodule foreach git status -sb --ignore-submodules; } 2>> git_st_report done
# took 28s638ms in total

for i in {1..1000}; do { time gis st; } 2>> gis_st_report done
# took 13s654ms in total

fetch

fetch: git vs gis

command for generating the above numbers:

for i in {1..100}; do { time git submodule foreach git fetch; } 2>> git_fe_report done
# took 29m43s442ms

for i in {1..100}; do { time gis fe; } 2>> gis_fe_report done
# took 5m11s832ms

Code quality

Use Sonarqube to analyze code:

podman run -d --name sonarqube -e SONAR_ES_BOOTSTRAP_CHECKS_DISABLE=true -p 9876:9000 docker.io/sonarqube:9.9.5-community

Then go to http://localhost:9876

Performance

Measure by hyperfine

| Command          | Mean [ms]       | Min [ms] | Max [ms] | Relative |
|------------------+-----------------+----------+----------+----------|
| gis              | 161.1 ± 28.2    |    129.2 |    216.0 |     1.00 |
| gis branches -nn | 146.0 ± 29.7    |     81.8 |    230.3 |     1.00 |
| gis branches     | 145.5 ± 27.1    |     68.0 |    183.4 |     1.00 |
| gis co br_tst_1  | 1047.8 ± 69.1   |    981.4 |   1204.2 |     1.00 |
| gis fetch        | 7043.6 ± 1983.0 |   3848.4 |  10246.1 |     1.00 |
| gis files        | 3472.5 ± 70.4   |   3402.4 |   3663.2 |     1.00 |
| gis status       | 152.5 ± 23.9    |    113.6 |    196.9 |     1.00 |

Performance is run with:

CPU info:

CPU NODE SOCKET CORE L1d:L1i:L2:L3 ONLINE    MAXMHZ   MINMHZ      MHZ
  0    0      0    0 0:0:0:0          yes 4600.0000 800.0000 870.5860
  1    0      0    0 0:0:0:0          yes 4600.0000 800.0000 869.3230
  2    0      0    1 4:4:1:0          yes 4600.0000 800.0000 800.2880
  3    0      0    1 4:4:1:0          yes 4600.0000 800.0000 800.4020
  4    0      0    2 8:8:2:0          yes 4600.0000 800.0000 800.1200
  5    0      0    2 8:8:2:0          yes 4600.0000 800.0000 800.0000
  6    0      0    3 12:12:3:0        yes 4600.0000 800.0000 800.0340
  7    0      0    3 12:12:3:0        yes 4600.0000 800.0000 800.0000
  8    0      0    4 16:16:4:0        yes 4600.0000 800.0000 805.9600
  9    0      0    4 16:16:4:0        yes 4600.0000 800.0000 800.7110
 10    0      0    5 20:20:5:0        yes 4600.0000 800.0000 800.0000
 11    0      0    5 20:20:5:0        yes 4600.0000 800.0000 802.9520
 12    0      0    6 28:28:7:0        yes 3300.0000 800.0000 864.4740
 13    0      0    7 29:29:7:0        yes 3300.0000 800.0000 800.0000
 14    0      0    8 30:30:7:0        yes 3300.0000 800.0000 799.8320
 15    0      0    9 31:31:7:0        yes 3300.0000 800.0000 800.0000

RAM info:

RANGE                                 SIZE  STATE REMOVABLE  BLOCK
0x0000000000000000-0x000000007fffffff   2G online       yes   0-15
0x0000000100000000-0x000000087fffffff  30G online       yes 32-271

Memory block size:       128M
Total online memory:      32G
Total offline memory:      0B

gis version: 2.0.0-dev