git-next 2025.7.1

trunk-based development manager
build:
  #!/usr/bin/env bash
  set -e
  cargo fmt
  cargo fmt --check
  forgejo-todo-checker --workspace $PWD --site https://git.kemitix.net --repo kemitix/git-next
  cargo machete
  cargo clippy --all-targets -- -Dwarnings
  cargo check
  cargo test
  cargo doc
  # cargo test --example get
  # cargo mutants --jobs 4

ci:
  #!/usr/bin/env bash
  set -e
  cargo fmt
  cargo fmt --check
  forgejo-todo-checker --workspace $PWD --site https://git.kemitix.net --repo kemitix/git-next
  cargo machete
  cargo hack --feature-powerset clippy --all-targets -- -Dwarnings
  cargo hack --feature-powerset check
  cargo hack --feature-powerset test
  cargo doc
  # cargo test --example get
  # cargo mutants --jobs 4

clippy:
  cargo clippy --all-targets -- -Dwarnings

test-in-docker:
  docker run --rm -u $(id -u):$(id -g) -v ${PWD}:/app/ git.kemitix.net/kemitix/rust:latest cargo test

shell-in-docker:
  docker run --rm -u $(id -u):$(id -g) -it -v ${PWD}:/app/ git.kemitix.net/kemitix/rust:latest bash

docker-test-image := "git.kemitix.net/kemitix/git-next:test"

build-docker:
  docker build . -t {{ docker-test-image }}

run-in-docker: build-docker
  docker run --rm -u $(id -u):$(id -g) -v ${PWD}:/app/ {{ docker-test-image }} server start

run-ui-in-docker: build-docker
  docker run --rm -u $(id -u):$(id -g) -it -v ${PWD}:/app/ {{ docker-test-image }} server start --ui

install-hooks:
  @echo "Installing git hooks"
  cargo install cc-cli
  git config core.hooksPath .git-hooks

validate-dev-branch:
  git rebase -i origin/main -x 'just mock-ci'

mock-ci:
  cargo fmt --check
  cargo hack --feature-powerset check
  cargo hack --feature-powerset test
  cargo hack --feature-powerset clippy

start-ngrok:
  #!/usr/bin/env bash
  # Uses NGROK_DOMAIN env var if available
  if test -z ${NGROK_DOMAIN} ; then
    ngrok http 8080
  else
    ngrok http --domain=${NGROK_DOMAIN} 8080
  fi

start-mac-tunnel:
  ssh dagon -R7777:localhost:8888
  @echo "Mac Tunnel has closed"

coverage-update:
  cargo tarpaulin --lib --out html
  echo "Now:\n\topen tarpaulin-report.html"

coverage crate test:
  cargo tarpaulin -p {{crate}} --lib --out html -- {{test}}
  # cargo tarpaulin --skip-clean -p {{crate}} --lib --out html -- {{test}}
  
grcov-coverage:
  #!/usr/bin/env bash
  set -e
  # an alternate coverage report
  rustup component add llvm-tools-preview
  export RUSTFLAGS="-Cinstrument-coverage"
  cargo check
  export LLVM_PROFILE_FILE="git-next-%p-%m.profraw"
  cargo test
  echo "Building report..."
  grcov . -s . --binary-path ./target/debug/ -t html --branch --ignore-not-existing -o ./target/debug/coverage/
  find . -name '*.profraw' -exec rm "{}" \;
  echo "Now:\n\topen target/debug/coverage/index.html"

docker-build:
  docker build -t git.kemitix.net/kemitix/git-next:latest . 

docker-run: docker-build
  docker run -it -p "7777:8888" -v .:/app/ git.kemitix.net/kemitix/git-next:latest server start --ui

run *args:
  cargo run -- {{ args }}

run-ui:
  just run server start --ui

publish-docker-image tag:
  docker pull git.kemitix.net/kemitix/git-next:{{ tag }}
  docker tag git.kemitix.net/kemitix/git-next:{{ tag }} codeberg.org/kemitix/git-next:{{ tag }}
  docker push codeberg.org/kemitix/git-next:{{ tag }}