index : gitrs
A lightweight web interface for browsing Git repositories, implemented in Rust
about summary refs log tree commit diff

Diffstat

-rw-r--r-- build.rs 6
-rw-r--r-- git-rs.service 16
-rw-r--r-- justfile 57
 3 files changed, 57 insertions(+), 22 deletions(-)

diff --git a/build.rs b/build.rs
index 0a7c23a..fe7e164 100644
--- a/build.rs
+++ b/build.rs
@@ -1,5 +1,7 @@
fn main() {
    // Cargo watches this directory recursively; any file added/changed/removed
    // under it triggers a rebuild on the next `cargo build`/`cargo run`.
    // Cargo watches these directories recursively; any file added/changed/removed
    // under them triggers a rebuild on the next `cargo build`/`cargo run`.
    println!("cargo:rerun-if-changed=src");
    println!("cargo:rerun-if-changed=templates");
    println!("cargo:rerun-if-changed=static");
}
diff --git a/git-rs.service b/git-rs.service
new file mode 100644
index 0000000..1814be5 100644
--- /dev/null
+++ b/git-rs.service
@@ -1,0 +1,16 @@
[Unit]
Description=git-rs — Lightweight Git web frontend
After=network-online.target
Wants=network-online.target

[Service]
Type=simple
User=root
WorkingDirectory=/srv/git
ExecStart=/usr/bin/git-rs --url 0.0.0.0 --port 80 --repos-dir /srv/git
Restart=on-failure
RestartSec=5
AmbientCapabilities=CAP_NET_BIND_SERVICE

[Install]
WantedBy=multi-user.target
diff --git a/justfile b/justfile
index 1ab7c49..b94382e 100644
--- a/justfile
+++ b/justfile
@@ -1,29 +1,46 @@
build mode="":
  cargo build --{{mode}}

run:
  cargo run

debug argument="":
  @GIT_LOG=trace cargo run -- {{argument}}
  @bat ~/.cache/nmrs-tui/nmrs-tui.log

arm_target := "aarch64-unknown-linux-gnu"

default:
    @just --list

# Build debug binary
build *args:
    cargo build {{args}}

# Build optimized release binary (x86_64)
build-release:
    cargo build --release

# Cross-compile static ARM64 binary for Orange Pi
build-arm:
    cargo build --release --target {{arm_target}}

# Build and deploy ARM64 binary + systemd service to Orange Pi
deploy host="pi": build-arm
    ssh {{host}} "systemctl stop git-rs || true"
    scp target/{{arm_target}}/release/git-rs {{host}}:/usr/bin/git-rs
    # scp git-rs.service {{host}}:/etc/systemd/system/git-rs.service
    ssh {{host}} "systemctl daemon-reload && systemctl start git-rs"

# Run locally (e.g. `just run -p 8080 -r ./repos`)
run *args:
    cargo run -- {{args}}

# Fast type and borrow check
check:
  cargo check

package:
  cargo package
    cargo check --all-targets

publish:
  cargo publish

release level="patch":
  cargo release {{level}} --execute

# Format all Rust code
fmt:
    cargo fmt --all

# Run clippy with warnings denied
lint:
    cargo clippy --all-targets --all-features -- -D warnings

# Run format and lint checks
ci: fmt lint

# Remove build artifacts
clean:
    cargo clean