-
Notifications
You must be signed in to change notification settings - Fork 4
/
justfile
71 lines (54 loc) · 2.11 KB
/
justfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
set positional-arguments
badge-crates := "[![crate](https://img.shields.io/crates/v/repgrep)](https://crates.io/crates/repgrep)"
badge-docs := "[![documentation](https://docs.rs/repgrep/badge.svg)](https://docs.rs/repgrep)"
bench-json := "benches/rg.json"
_default:
just -l
# run this once after you pull down the repository
setup:
cargo install cargo-bump
cargo install cargo-readme
if command -v pacman >/dev/null 2>&1 /dev/null; then sudo pacman -S --needed ripgrep; fi
if command -v apt-get >/dev/null 2>&1 /dev/null; then sudo apt-get install ripgrep; fi
if ! command -v rg >/dev/null 2>&1 /dev/null; then echo "please install rg!"; exit 1; fi
# runs rustfmt
fmt:
rustup run nightly cargo fmt
# tests rgr
test *args:
RUST_LOG=trace cargo test --all --all-features "$@"
# run rgr locally with logging enabled - use `just devlogs` to view output
dev *args:
RUST_LOG=trace cargo run -- "$@"
# follows logs from `just dev`
dev-logs:
tail -f ./rgr.log
# ensures that data is available for the benchmarks
setup-bench:
if [ ! -f "{{bench-json}}" ]; then rg --json --no-config . ./ > "{{bench-json}}"; fi
# run the benchmarks
bench: setup-bench
cargo bench
# update the readme
readme:
printf "%s\n%s\n%s" "{{ badge-crates }}" "{{ badge-docs }}" "$(cargo readme)" > README.md
sed -i 's/# repgrep/# repgrep (rgr)/' README.md
check-dirty:
if [ ! -z "$(git status --porcelain)" ]; then \
echo "It seems there are uncommitted changes, please run this command in a clean git state"; \
exit 1; \
fi \
# Bumps the crate,a creates a tag and commits the changed files
bump +TYPE: check-dirty
#!/usr/bin/env bash
set -euxo pipefail
last_tag=$(git describe --tags | grep -oEm 1 '([0-9]+\.[0-9]+\.[0-9]+)')
commits=$(git log --no-decorate --oneline "$last_tag"..HEAD | sed 's/^/- /')
just fmt
cargo bump {{ TYPE }}
cargo check
just readme
version=$(grep -oEm 1 '([0-9]+\.[0-9]+\.[0-9]+)' Cargo.toml)
printf '# %s\n\n%s\n\n%s' "$version" "$commits" "$(cat CHANGELOG.md)" > CHANGELOG.md
git add .
git commit -v -m "$version"