Compare commits

..

23 commits
v0.2.0 ... main

Author SHA1 Message Date
Renovate Bot
590f692094 chore(deps): update kemitix/rust action to v2.1.0
All checks were successful
ci/woodpecker/pr/woodpecker Pipeline was successful
Rust / build (map[name:nightly]) (pull_request) Successful in 1m20s
Rust / build (map[name:stable]) (pull_request) Successful in 1m7s
ci/woodpecker/pull_request_closed/woodpecker Pipeline was successful
ci/woodpecker/push/woodpecker Pipeline was successful
Rust / build (map[name:nightly]) (push) Successful in 2m34s
Rust / build (map[name:stable]) (push) Successful in 1m10s
2024-09-17 14:32:56 +00:00
26db7106a1 build: run test against Rust nightly
All checks were successful
Rust / build (map[name:stable]) (push) Successful in 1m10s
Rust / build (map[name:nightly]) (push) Successful in 1m22s
ci/woodpecker/push/woodpecker Pipeline was successful
2024-09-17 14:44:40 +01:00
7f5af60757 build: run integration test with same os as it was built
All checks were successful
Rust / build (push) Successful in 1m13s
ci/woodpecker/push/woodpecker Pipeline was successful
2024-09-17 14:30:05 +01:00
Renovate Bot
fc7fbca090 chore(deps): update docker.io/rust docker tag to v1.81.0
All checks were successful
Rust / build (pull_request) Successful in 38s
ci/woodpecker/pull_request_closed/woodpecker Pipeline was successful
ci/woodpecker/pr/woodpecker Pipeline was successful
Rust / build (push) Successful in 28s
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/cron/woodpecker Pipeline was successful
2024-09-05 23:47:07 +00:00
f645c4d15e build: update forgejo action to rust 1.80.1
All checks were successful
Rust / build (push) Successful in 21s
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/cron/woodpecker Pipeline was successful
2024-08-11 09:04:47 +01:00
Renovate Bot
bf7486235f chore(deps): update docker.io/rust docker tag to v1.80.1
Some checks failed
ci/woodpecker/pr/woodpecker Pipeline failed
Rust / build (pull_request) Failing after 28s
ci/woodpecker/pull_request_closed/woodpecker Pipeline was successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/cron/woodpecker Pipeline was successful
Rust / build (push) Failing after 11s
2024-08-08 20:47:04 +00:00
Renovate Bot
b2f02297e9 chore(deps): update kemitix/rust action to v1
All checks were successful
ci/woodpecker/cron/woodpecker Pipeline was successful
ci/woodpecker/pr/woodpecker Pipeline was successful
Rust / build (pull_request) Successful in 17s
ci/woodpecker/pull_request_closed/woodpecker Pipeline was successful
Rust / build (push) Successful in 16s
ci/woodpecker/push/woodpecker Pipeline was successful
2024-08-02 18:46:33 +00:00
Renovate Bot
6954185ef1 chore(deps): update docker.io/tamasfe/taplo docker tag to v0.9.3
Some checks failed
ci/woodpecker/pr/woodpecker Pipeline was successful
Rust / build (pull_request) Failing after 11s
ci/woodpecker/pull_request_closed/woodpecker Pipeline was successful
Rust / build (push) Failing after 10s
ci/woodpecker/push/woodpecker Pipeline was successful
2024-07-31 12:16:17 +00:00
Renovate Bot
29df35b196 chore(deps): woodpecker update docker.io/rust docker tag to v1.80.0
All checks were successful
Rust / build (push) Successful in 14s
ci/woodpecker/push/woodpecker Pipeline was successful
2024-07-30 07:38:04 +01:00
21c8f0883a build: woodpecker: remove steps migrated to forge actions
All checks were successful
Rust / build (push) Successful in 15s
ci/woodpecker/push/woodpecker Pipeline was successful
2024-07-30 07:38:04 +01:00
bef0389ce6 build: add forgejo workflow push-next
All checks were successful
Rust / build (push) Successful in 20s
ci/woodpecker/push/woodpecker Pipeline was successful
2024-07-30 07:28:10 +01:00
Renovate Bot
c6072d8ed3 chore(deps): update docker.io/tamasfe/taplo docker tag to v0.9.2
All checks were successful
ci/woodpecker/pr/woodpecker Pipeline was successful
ci/woodpecker/pull_request_closed/woodpecker Pipeline was successful
ci/woodpecker/cron/woodpecker Pipeline was successful
ci/woodpecker/push/woodpecker Pipeline was successful
2024-07-12 11:45:48 +00:00
Renovate Bot
52bdc5c615 chore(deps): update docker.io/rust docker tag to v1.79.0
All checks were successful
ci/woodpecker/pr/woodpecker Pipeline was successful
ci/woodpecker/pull_request_closed/woodpecker Pipeline was successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/cron/woodpecker Pipeline was successful
2024-06-13 18:01:01 +00:00
4d7dcb2665 chore(renovate): update update major and minor version
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/cron/woodpecker Pipeline was successful
2024-05-14 14:02:38 +01:00
021b7ea8dd Update docker.io/rust Docker tag to v1.78 (#13)
All checks were successful
ci/woodpecker/cron/woodpecker Pipeline was successful
ci/woodpecker/push/woodpecker Pipeline was successful
This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| docker.io/rust | minor | `1.77` -> `1.78` |

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4zMzQuNCIsInVwZGF0ZWRJblZlciI6IjM3LjMzNC40IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->

Co-authored-by: Renovate Bot <renovate@kemitix.net>
Co-authored-by: kemitix <kemitix@noreply.kemitix.net>
Reviewed-on: #13
Co-authored-by: renovate <renovate@noreply.kemitix.net>
Co-committed-by: renovate <renovate@noreply.kemitix.net>
2024-05-03 19:24:11 +01:00
69b643309d Update docker.io/rust Docker tag to v1.77 (#11)
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/cron/woodpecker Pipeline was successful
This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| docker.io/rust | minor | `1.76` -> `1.77` |

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4yNjQuMCIsInVwZGF0ZWRJblZlciI6IjM3LjI2NC4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9-->

Co-authored-by: Renovate Bot <renovate@kemitix.net>
Reviewed-on: #11
Co-authored-by: renovate <renovate@noreply.kemitix.net>
Co-committed-by: renovate <renovate@noreply.kemitix.net>
2024-03-21 20:54:15 +00:00
cb9ae3ca5e release/0.2.1 (#10)
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/cron/woodpecker Pipeline was successful
Reviewed-on: #10
Co-authored-by: Paul Campbell <pcampbell@kemitix.net>
Co-committed-by: Paul Campbell <pcampbell@kemitix.net>
2024-02-28 17:48:25 +00:00
430819cd81 Version set to 0.2.1 (#9)
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
Reviewed-on: #9
Co-authored-by: Paul Campbell <pcampbell@kemitix.net>
Co-committed-by: Paul Campbell <pcampbell@kemitix.net>
2024-02-26 13:59:29 +00:00
ba6e2b0ab9 rewrite woodpecker-ci to publish to crates.io (#8)
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
Reviewed-on: #8
Co-authored-by: Paul Campbell <pcampbell@kemitix.net>
Co-committed-by: Paul Campbell <pcampbell@kemitix.net>
2024-02-26 10:36:03 +00:00
cf5833a5d6 Update Rust crate clap to 4.5 (#7)
All checks were successful
ci/woodpecker/cron/woodpecker Pipeline was successful
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [clap](https://github.com/clap-rs/clap) | dependencies | minor | `4.4` -> `4.5` |

>  **Important**
>
> Release Notes retrieval for this PR were skipped because no github.com credentials were available.
> If you are self-hosted, please see [this instruction](https://github.com/renovatebot/renovate/blob/master/docs/usage/examples/self-hosting.md#githubcom-token-for-release-notes).

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4xNTIuMSIsInVwZGF0ZWRJblZlciI6IjM3LjE1Mi4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9-->

Co-authored-by: Renovate Bot <renovate@kemitix.net>
Reviewed-on: #7
Co-authored-by: renovate <renovate@noreply.kemitix.net>
Co-committed-by: renovate <renovate@noreply.kemitix.net>
2024-02-09 08:49:19 +00:00
fcb70534d5 Update Rust crate clap to 4.4 (#5)
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/cron/woodpecker Pipeline was successful
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [clap](https://github.com/clap-rs/clap) | dependencies | minor | `4.0` -> `4.4` |

>  **Important**
>
> Release Notes retrieval for this PR were skipped because no github.com credentials were available.
> If you are self-hosted, please see [this instruction](https://github.com/renovatebot/renovate/blob/master/docs/usage/examples/self-hosting.md#githubcom-token-for-release-notes).

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4xNDYuMCIsInVwZGF0ZWRJblZlciI6IjM3LjE0Ni4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9-->

Co-authored-by: Renovate Bot <renovate@kemitix.net>
Co-authored-by: Paul Campbell <kemitix@noreply.kemitix.net>
Reviewed-on: #5
Co-authored-by: renovate <renovate@noreply.kemitix.net>
Co-committed-by: renovate <renovate@noreply.kemitix.net>
2024-01-23 19:17:11 +00:00
26e4f2a503 Configure Renovate (#4)
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
Welcome to [Renovate](https://github.com/renovatebot/renovate)! This is an onboarding PR to help you understand and configure settings before regular Pull Requests begin.

🚦 To activate Renovate, merge this Pull Request. To disable Renovate, simply close this Pull Request unmerged.

---
### Detected Package Files

 * `Cargo.toml` (cargo)
 * `.woodpecker.yml` (woodpecker)

### Configuration Summary

Based on the default config's presets, Renovate will:

  - Start dependency updates only once this onboarding PR is merged
  - Enable Renovate Dependency Dashboard creation.
  - Use semantic commit type `fix` for dependencies and `chore` for all others if semantic commits are in use.
  - Ignore `node_modules`, `bower_components`, `vendor` and various test/tests directories.
  - Group known monorepo packages together.
  - Use curated list of recommended non-monorepo package groupings.
  - Apply crowd-sourced package replacement rules.
  - Apply crowd-sourced workarounds for known problems with packages.

🔡 Do you want to change how Renovate upgrades your dependencies? Add your custom config to `renovate.json` in this branch. Renovate will update the Pull Request description the next time it runs.

---

### What to Expect

With your current configuration, Renovate will create 1 Pull Request:

<details>
<summary>Update Rust crate clap to 4.4</summary>

  - Schedule: ["at any time"]
  - Branch name: `renovate/clap-4.x`
  - Merge into: `main`
  - Upgrade [clap](https://github.com/clap-rs/clap) to `4.4`

</details>

---

 Got questions? Check out Renovate's [Docs](https://docs.renovatebot.com/), particularly the Getting Started section.
If you need any further assistance then you can also [request help here](https://github.com/renovatebot/renovate/discussions).

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).

<!--renovate-config-hash:e80b4e42a3043bc12fa0640db4bac392d2bf770acf841360d7c8ceeeac2ec1a9-->

Co-authored-by: Renovate Bot <renovate@kemitix.net>
Reviewed-on: #4
Co-authored-by: renovate <renovate@noreply.kemitix.net>
Co-committed-by: renovate <renovate@noreply.kemitix.net>
2024-01-23 18:55:46 +00:00
Paul Campbell
ac5dedb7f9 Add woodpecker ci config (#3)
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/cron/woodpecker Pipeline was successful
Co-authored-by: Paul Campbell <pcampbell@kemitix.net>
Reviewed-on: #3
2023-03-24 09:41:50 +00:00
9 changed files with 271 additions and 271 deletions

View file

@ -0,0 +1,52 @@
name: Rust
on:
push:
branches: ["next"]
pull_request:
branches: ["main"]
env:
CARGO_TERM_COLOR: always
jobs:
build:
runs-on: docker
strategy:
matrix:
toolchain:
- name: stable
- name: nightly
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Format
uses: https://git.kemitix.net/kemitix/rust@v2.1.0
with:
args: ${{ matrix.toolchain.name }} cargo fmt --all -- --check
# - name: Machete
# uses: https://github.com/bnjbvr/cargo-machete@v0.6.2
- name: Clippy
uses: https://git.kemitix.net/kemitix/rust@v2.1.0
with:
args: ${{ matrix.toolchain.name }} cargo clippy
- name: Build
uses: https://git.kemitix.net/kemitix/rust@v2.1.0
with:
args: ${{ matrix.toolchain.name }} cargo build
- name: Test
uses: https://git.kemitix.net/kemitix/rust@v2.1.0
with:
args: ${{ matrix.toolchain.name }} cargo test --no-fail-fast
- name: Integration
uses: https://git.kemitix.net/kemitix/rust@v2.1.0
with:
args: ./test.sh

46
.woodpecker.yml Normal file
View file

@ -0,0 +1,46 @@
variables:
- &rust_image "docker.io/rust:1.81.0"
- &slow_check_paths
- path:
# rust source code
- "crates/**"
- "src/**"
- "tests/**"
- "**/Cargo.toml"
- "Cargo.lock"
# database migrations
- "migrations/**"
# config files and scripts used by ci
- ".woodpecker.yml"
steps:
toml_fmt:
image: docker.io/tamasfe/taplo:0.9.3
commands:
- taplo format --check
cargo_machete:
image: *rust_image
commands:
- wget https://github.com/cargo-bins/cargo-binstall/releases/latest/download/cargo-binstall-x86_64-unknown-linux-musl.tgz
- tar -xvf cargo-binstall-x86_64-unknown-linux-musl.tgz
- rm cargo-binstall-x86_64-unknown-linux-musl.tgz
- mv cargo-binstall /usr/local/cargo/bin
- cargo binstall -y cargo-machete
- cargo machete
ignored_files:
image: docker.io/alpine:latest
commands:
- apk add git
- IGNORED=$(git ls-files --cached -i --exclude-standard)
- if [[ "$IGNORED" ]]; then echo "Ignored files present:\n$IGNORED\n"; exit 1; fi
publish_to_crates_io:
image: *rust_image
commands:
- cargo login "$CARGO_REGISTRY_TOKEN"
- cargo publish --registry crates-io --no-verify
secrets: [cargo_registry_token]
when:
event: tag

287
Cargo.lock generated
View file

@ -3,46 +3,82 @@
version = 3 version = 3
[[package]] [[package]]
name = "bitflags" name = "anstream"
version = "1.3.2" version = "0.6.11"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" checksum = "6e2e1ebcb11de5c03c67de28a7df593d32191b44939c482e97702baaaa6ab6a5"
dependencies = [
"anstyle",
"anstyle-parse",
"anstyle-query",
"anstyle-wincon",
"colorchoice",
"utf8parse",
]
[[package]] [[package]]
name = "bitflags" name = "anstyle"
version = "2.0.2" version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "487f1e0fcbe47deb8b0574e646def1c903389d95241dd1bbcc6ce4a715dfc0c1" checksum = "7079075b41f533b8c61d2a4d073c4676e1f8b249ff94a393b0595db304e0dd87"
[[package]] [[package]]
name = "cc" name = "anstyle-parse"
version = "1.0.79" version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" checksum = "c75ac65da39e5fe5ab759307499ddad880d724eed2f6ce5b5e8a26f4f387928c"
dependencies = [
"utf8parse",
]
[[package]]
name = "anstyle-query"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e28923312444cdd728e4738b3f9c9cac739500909bb3d3c94b43551b16517648"
dependencies = [
"windows-sys",
]
[[package]]
name = "anstyle-wincon"
version = "3.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7"
dependencies = [
"anstyle",
"windows-sys",
]
[[package]] [[package]]
name = "clap" name = "clap"
version = "4.1.11" version = "4.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "42dfd32784433290c51d92c438bb72ea5063797fc3cc9a21a8c4346bebbb2098" checksum = "80c21025abd42669a92efc996ef13cfb2c5c627858421ea58d5c3b331a6c134f"
dependencies = [ dependencies = [
"bitflags 2.0.2", "clap_builder",
"clap_derive", "clap_derive",
]
[[package]]
name = "clap_builder"
version = "4.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "458bf1f341769dfcf849846f65dffdf9146daa56bcd2a47cb4e1de9915567c99"
dependencies = [
"anstream",
"anstyle",
"clap_lex", "clap_lex",
"is-terminal",
"once_cell",
"strsim", "strsim",
"termcolor",
] ]
[[package]] [[package]]
name = "clap_derive" name = "clap_derive"
version = "4.1.9" version = "4.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fddf67631444a3a3e3e5ac51c36a5e01335302de677bd78759eaa90ab1f46644" checksum = "307bc0538d5f0f83b8248db3087aa92fe504e4691294d0c96c0eabc33f47ba47"
dependencies = [ dependencies = [
"heck", "heck",
"proc-macro-error",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn", "syn",
@ -50,33 +86,15 @@ dependencies = [
[[package]] [[package]]
name = "clap_lex" name = "clap_lex"
version = "0.3.3" version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "033f6b7a4acb1f358c742aaca805c939ee73b4c6209ae4318ec7aca81c42e646" checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce"
dependencies = [
"os_str_bytes",
]
[[package]] [[package]]
name = "errno" name = "colorchoice"
version = "0.2.8" version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1" checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7"
dependencies = [
"errno-dragonfly",
"libc",
"winapi",
]
[[package]]
name = "errno-dragonfly"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf"
dependencies = [
"cc",
"libc",
]
[[package]] [[package]]
name = "heck" name = "heck"
@ -84,88 +102,11 @@ version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
[[package]]
name = "hermit-abi"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286"
[[package]]
name = "io-lifetimes"
version = "1.0.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0dd6da19f25979c7270e70fa95ab371ec3b701cd0eefc47667a09785b3c59155"
dependencies = [
"hermit-abi",
"libc",
"windows-sys",
]
[[package]]
name = "is-terminal"
version = "0.4.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8687c819457e979cc940d09cb16e42a1bf70aa6b60a549de6d3a62a0ee90c69e"
dependencies = [
"hermit-abi",
"io-lifetimes",
"rustix",
"windows-sys",
]
[[package]]
name = "libc"
version = "0.2.140"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "99227334921fae1a979cf0bfdfcc6b3e5ce376ef57e16fb6fb3ea2ed6095f80c"
[[package]]
name = "linux-raw-sys"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4"
[[package]]
name = "once_cell"
version = "1.17.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3"
[[package]]
name = "os_str_bytes"
version = "6.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ceedf44fb00f2d1984b0bc98102627ce622e083e49a5bacdb3e514fa4238e267"
[[package]]
name = "proc-macro-error"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c"
dependencies = [
"proc-macro-error-attr",
"proc-macro2",
"quote",
"syn",
"version_check",
]
[[package]]
name = "proc-macro-error-attr"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869"
dependencies = [
"proc-macro2",
"quote",
"version_check",
]
[[package]] [[package]]
name = "proc-macro2" name = "proc-macro2"
version = "1.0.52" version = "1.0.78"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1d0e1ae9e836cc3beddd63db0df682593d7e2d3d891ae8c9083d2113e1744224" checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae"
dependencies = [ dependencies = [
"unicode-ident", "unicode-ident",
] ]
@ -179,53 +120,30 @@ dependencies = [
"proc-macro2", "proc-macro2",
] ]
[[package]]
name = "rustix"
version = "0.36.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2fe885c3a125aa45213b68cc1472a49880cb5923dc23f522ad2791b882228778"
dependencies = [
"bitflags 1.3.2",
"errno",
"io-lifetimes",
"libc",
"linux-raw-sys",
"windows-sys",
]
[[package]] [[package]]
name = "skip" name = "skip"
version = "0.2.0" version = "0.2.1"
dependencies = [ dependencies = [
"clap", "clap",
] ]
[[package]] [[package]]
name = "strsim" name = "strsim"
version = "0.10.0" version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" checksum = "5ee073c9e4cd00e28217186dbe12796d692868f432bf2e97ee73bed0c56dfa01"
[[package]] [[package]]
name = "syn" name = "syn"
version = "1.0.109" version = "2.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" checksum = "79d9531f94112cfc3e4c8f5f02cb2b58f72c97b7efd85f70203cc6d8efda5927"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"unicode-ident", "unicode-ident",
] ]
[[package]]
name = "termcolor"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6"
dependencies = [
"winapi-util",
]
[[package]] [[package]]
name = "unicode-ident" name = "unicode-ident"
version = "1.0.8" version = "1.0.8"
@ -233,56 +151,25 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4"
[[package]] [[package]]
name = "version_check" name = "utf8parse"
version = "0.9.4" version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a"
[[package]]
name = "winapi"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
dependencies = [
"winapi-i686-pc-windows-gnu",
"winapi-x86_64-pc-windows-gnu",
]
[[package]]
name = "winapi-i686-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
[[package]]
name = "winapi-util"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
dependencies = [
"winapi",
]
[[package]]
name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]] [[package]]
name = "windows-sys" name = "windows-sys"
version = "0.45.0" version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
dependencies = [ dependencies = [
"windows-targets", "windows-targets",
] ]
[[package]] [[package]]
name = "windows-targets" name = "windows-targets"
version = "0.42.2" version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd"
dependencies = [ dependencies = [
"windows_aarch64_gnullvm", "windows_aarch64_gnullvm",
"windows_aarch64_msvc", "windows_aarch64_msvc",
@ -295,42 +182,42 @@ dependencies = [
[[package]] [[package]]
name = "windows_aarch64_gnullvm" name = "windows_aarch64_gnullvm"
version = "0.42.2" version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea"
[[package]] [[package]]
name = "windows_aarch64_msvc" name = "windows_aarch64_msvc"
version = "0.42.2" version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef"
[[package]] [[package]]
name = "windows_i686_gnu" name = "windows_i686_gnu"
version = "0.42.2" version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313"
[[package]] [[package]]
name = "windows_i686_msvc" name = "windows_i686_msvc"
version = "0.42.2" version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a"
[[package]] [[package]]
name = "windows_x86_64_gnu" name = "windows_x86_64_gnu"
version = "0.42.2" version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd"
[[package]] [[package]]
name = "windows_x86_64_gnullvm" name = "windows_x86_64_gnullvm"
version = "0.42.2" version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e"
[[package]] [[package]]
name = "windows_x86_64_msvc" name = "windows_x86_64_msvc"
version = "0.42.2" version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04"

View file

@ -1,9 +1,17 @@
[package] [package]
name = "skip" name = "skip"
version = "0.2.0" version = "0.2.1"
edition = "2021" edition = "2021"
authors = ["Paul Campbell <pcampbell@kemitix.net>"]
categories = ["command-line-utilities"]
description = "Skip lines in a file"
license = "MIT"
repository = "https://git.kemitix.net/kemitix/skip"
keywords = ["skip", "lines", "file", "text", "utility"]
rust-version = "1.74.1"
exclude = [".cargo_home"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
clap = { version = "4.0", features = ["derive"] } clap = { version = "4.5", features = ["derive"] }

View file

@ -2,13 +2,17 @@
Skip part of a file. Skip part of a file.
As `head` will show the top of a file after a number of line, As `head` will show the top of a file up-to a number of line,
so `skip` will do the opposite, and not show the top of the file, so `skip` will do the opposite, and not show the top of the file,
but will show the rest. but will show the rest.
Additionally, it can check for whole lines matching, Additionally, it can check for whole lines matching,
or for a token being present on the line. or for a token being present on the line.
N.B.: The `skip` crate used to be an implementation of [Skip list](https://en.wikipedia.org/wiki/Skip_list),
by [Luo Jia / Zhouqi Jiang](https://github.com/luojia65) ([source](https://github.com/luojia65/skip)).
That crate will be republished as [skip-list](https://crates.io/crates/skip-list) (soon).
## Usage ## Usage
### Skip a fixed number of lines ### Skip a fixed number of lines

View file

@ -1,15 +1,15 @@
dist: target-release-skip dist: target-release
if test ! -d dist ; then mkdir dist ; fi if test ! -d dist ; then mkdir dist ; fi
cp target/release/skip dist/ cp target/release/skip dist/
inttest: target-debug-skip target-release: unittest inttest
./test.sh
target-release-skip: unittest inttest
cargo build --release cargo build --release
target-debug-skip: inttest: target-debug
cargo build ./test.sh
unittest: target-debug-skip unittest: target-debug
cargo test cargo test
target-debug:
cargo build

10
renovate.json Normal file
View file

@ -0,0 +1,10 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": ["config:recommended"],
"packageRules": [
{
"matchManagers": ["cargo"],
"rangeStrategy": "replace"
}
]
}

View file

@ -39,7 +39,7 @@ pub fn skip(cli: &Cli, writer: &mut impl Write) -> Result<()> {
None => Box::new(BufReader::new(std::io::stdin())), None => Box::new(BufReader::new(std::io::stdin())),
}; };
if let Some(line) = &cli.line { if let Some(line) = &cli.line {
skip_lines_matching(&cli, reader, writer, line) skip_lines_matching(cli, reader, writer, line)
} else if let Some(ref token) = cli.token { } else if let Some(ref token) = cli.token {
skip_tokens(cli, reader, writer, token) skip_tokens(cli, reader, writer, token)
} else { } else {
@ -49,13 +49,9 @@ pub fn skip(cli: &Cli, writer: &mut impl Write) -> Result<()> {
// skip a number of lines // skip a number of lines
fn skip_lines(cli: &Cli, reader: Box<dyn BufRead>, writer: &mut impl Write) -> Result<()> { fn skip_lines(cli: &Cli, reader: Box<dyn BufRead>, writer: &mut impl Write) -> Result<()> {
let mut counter = 0usize; for (counter, current_line) in reader.lines().map_while(Option::Some).flatten().enumerate() {
for current_line in reader.lines() { if counter >= cli.lines {
if let Ok(current_line) = current_line { writeln!(writer, "{}", current_line)?;
if counter >= cli.lines {
writeln!(writer, "{}", current_line)?;
}
counter += 1;
} }
} }
Ok(()) Ok(())
@ -69,14 +65,12 @@ fn skip_lines_matching(
line: &str, line: &str,
) -> Result<()> { ) -> Result<()> {
let mut counter = 0usize; let mut counter = 0usize;
for current_line in reader.lines() { for current_line in reader.lines().map_while(Option::Some).flatten() {
if let Ok(current_line) = current_line { if counter >= cli.lines {
if counter >= cli.lines { writeln!(writer, "{}", current_line)?;
writeln!(writer, "{}", current_line)?; }
} if line == current_line {
if line == current_line { counter += 1;
counter += 1;
}
} }
} }
Ok(()) Ok(())
@ -92,18 +86,16 @@ fn skip_tokens(
) -> Result<()> { ) -> Result<()> {
let mut counter = 0usize; let mut counter = 0usize;
for current_line in reader.lines() { for current_line in reader.lines().map_while(Option::Some).flatten() {
if let Ok(current_line) = current_line { if counter >= cli.lines {
if counter >= cli.lines { writeln!(writer, "{}", current_line)?;
writeln!(writer, "{}", current_line)?; }
} if current_line.contains(token) {
if current_line.contains(&token) { if cli.ignore_extras {
if cli.ignore_extras { counter += 1;
counter += 1; } else {
} else { let occurances = current_line.matches(&token).count();
let occurances = current_line.matches(&token).count(); counter += occurances;
counter += occurances;
}
} }
} }
} }
@ -151,10 +143,7 @@ mod tests {
skip(&cli, &mut lines)?; skip(&cli, &mut lines)?;
//then //then
assert_eq!( assert_eq!(String::from_utf8(lines)?, ["alpha", "gamma\n"].join("\n"));
String::from_utf8(lines)?,
vec!["alpha", "gamma\n"].join("\n")
);
Ok(()) Ok(())
} }
@ -196,7 +185,7 @@ mod tests {
//then //then
assert_eq!( assert_eq!(
String::from_utf8(lines)?, String::from_utf8(lines)?,
vec![ [
"Or help one fainting robin", "Or help one fainting robin",
"Unto his nest again,", "Unto his nest again,",
"I shall not live in vain.\n" "I shall not live in vain.\n"
@ -224,7 +213,7 @@ mod tests {
//then //then
assert_eq!( assert_eq!(
String::from_utf8(lines)?, String::from_utf8(lines)?,
vec![ [
//Lorem ipsum dolor sit amet, -- +2 = 2 //Lorem ipsum dolor sit amet, -- +2 = 2
//consectetur adipiscing elit, //consectetur adipiscing elit,
//sed do eiusmod tempor incididunt -- +1 = 3 //sed do eiusmod tempor incididunt -- +1 = 3
@ -257,7 +246,7 @@ mod tests {
//then //then
assert_eq!( assert_eq!(
String::from_utf8(lines)?, String::from_utf8(lines)?,
vec![ [
//Lorem ipsum dolor sit amet, -- 1 //Lorem ipsum dolor sit amet, -- 1
//consectetur adipiscing elit, //consectetur adipiscing elit,
//sed do eiusmod tempor incididunt -- 2 //sed do eiusmod tempor incididunt -- 2

54
test.sh
View file

@ -2,37 +2,41 @@
set -e set -e
echo "PWD: $PWD"
ls -l
ls -l target
SKIP="./target/debug/skip" SKIP="./target/debug/skip"
DIFF="diff -u --color" DIFF="diff -u --color"
if test ! -x $SKIP ; then if test ! -x $SKIP; then
echo "File missing: $SKIP - try 'zig build'" echo "File missing: $SKIP - try 'cargo build'"
exit 1 exit 1
fi fi
echo "> skip a line when reading from stdin" echo "> skip a line when reading from stdin"
INPUT=$(cat<<EOF INPUT=$(
cat <<EOF
line 1 line 1
line 2 line 2
EOF EOF
) )
echo "line 2" > test.expect echo "line 2" >test.expect
echo "$INPUT" | $SKIP 1 > test.out echo "$INPUT" | $SKIP 1 >test.out
$DIFF test.expect test.out $DIFF test.expect test.out
rm test.expect test.out rm test.expect test.out
echo "> skip a line when reading from a file" echo "> skip a line when reading from a file"
cat<<EOF > test.in cat <<EOF >test.in
line 1 line 1
line 2 line 2
EOF EOF
echo "line 2" > test.expect echo "line 2" >test.expect
$SKIP 1 test.in > test.out $SKIP 1 test.in >test.out
$DIFF test.expect test.out $DIFF test.expect test.out
rm test.expect test.out rm test.expect test.out
echo "> skip until 2 matching lines seen" echo "> skip until 2 matching lines seen"
cat<<EOF > test.in cat <<EOF >test.in
alpha alpha
beta beta
alpha alpha
@ -40,17 +44,17 @@ alpha
gamma gamma
alpha alpha
EOF EOF
cat<<EOF > test.expect cat <<EOF >test.expect
alpha alpha
gamma gamma
alpha alpha
EOF EOF
$SKIP 2 test.in --line alpha > test.out $SKIP 2 test.in --line alpha >test.out
$DIFF test.expect test.out $DIFF test.expect test.out
rm test.in test.expect test.out rm test.in test.expect test.out
echo "> skip lines until 2 tokens seen" echo "> skip lines until 2 tokens seen"
cat<<EOF > test.in cat <<EOF >test.in
Lorem ipsum dolor sit amet, Lorem ipsum dolor sit amet,
consectetur adipiscing elit, consectetur adipiscing elit,
sed do eiusmod tempor incididunt sed do eiusmod tempor incididunt
@ -60,37 +64,37 @@ quis nostrud exercitation ullamco
laboris nisi ut aliquip ex ea laboris nisi ut aliquip ex ea
commodo consequat. commodo consequat.
EOF EOF
cat<<EOF > test.expect cat <<EOF >test.expect
Ut enim ad minim veniam, Ut enim ad minim veniam,
quis nostrud exercitation ullamco quis nostrud exercitation ullamco
laboris nisi ut aliquip ex ea laboris nisi ut aliquip ex ea
commodo consequat. commodo consequat.
EOF EOF
$SKIP 2 test.in --token dolor > test.out $SKIP 2 test.in --token dolor >test.out
$DIFF test.expect test.out $DIFF test.expect test.out
rm test.in test.expect test.out rm test.in test.expect test.out
echo "> handle unknown parameter with simple error message" echo "> handle unknown parameter with simple error message"
cat<<EOF > test.expect.err cat <<EOF >test.expect.err
error: unexpected argument '--foo' found error: unexpected argument '--foo' found
note: to pass '--foo' as a value, use '-- --foo' tip: to pass '--foo' as a value, use '-- --foo'
Usage: skip [OPTIONS] <LINES> [FILE] Usage: skip [OPTIONS] <LINES> [FILE]
For more information, try '--help'. For more information, try '--help'.
EOF EOF
cat<<EOF > test.expect cat <<EOF >test.expect
EOF EOF
touch test.out test.err touch test.out test.err
$SKIP --foo > test.out 2> test.err || true $SKIP --foo >test.out 2>test.err || true
$DIFF test.expect test.out $DIFF test.expect test.out
$DIFF test.expect.err test.err $DIFF test.expect.err test.err
rm test.expect test.out rm test.expect test.out
rm test.expect.err test.err rm test.expect.err test.err
echo "> handle ignore-extra when token is missing" echo "> handle ignore-extra when token is missing"
cat<<EOF > test.expect.err cat <<EOF >test.expect.err
error: the following required arguments were not provided: error: the following required arguments were not provided:
--token <TOKEN> --token <TOKEN>
<LINES> <LINES>
@ -99,17 +103,17 @@ Usage: skip --ignore-extras --token <TOKEN> <LINES> [FILE]
For more information, try '--help'. For more information, try '--help'.
EOF EOF
cat<<EOF > test.expect cat <<EOF >test.expect
EOF EOF
touch test.out test.err touch test.out test.err
$SKIP --ignore-extras > test.out 2> test.err || true $SKIP --ignore-extras >test.out 2>test.err || true
$DIFF test.expect test.out $DIFF test.expect test.out
$DIFF test.expect.err test.err $DIFF test.expect.err test.err
rm test.expect test.out rm test.expect test.out
rm test.expect.err test.err rm test.expect.err test.err
echo "> skip lines until 4 tokens seen - ignored extra tokens on same line" echo "> skip lines until 4 tokens seen - ignored extra tokens on same line"
cat<<EOF > test.in cat <<EOF >test.in
Lorem ipsum dolor sit amet, Lorem ipsum dolor sit amet,
consectetur adipiscing elit, consectetur adipiscing elit,
sed do eiusmod tempor incididunt sed do eiusmod tempor incididunt
@ -119,12 +123,12 @@ quis nostrud exercitation ullamco
laboris nisi ut aliquip ex ea laboris nisi ut aliquip ex ea
commodo consequat. commodo consequat.
EOF EOF
cat<<EOF > test.expect cat <<EOF >test.expect
quis nostrud exercitation ullamco quis nostrud exercitation ullamco
laboris nisi ut aliquip ex ea laboris nisi ut aliquip ex ea
commodo consequat. commodo consequat.
EOF EOF
$SKIP 4 test.in --token m --ignore-extras > test.out $SKIP 4 test.in --token m --ignore-extras >test.out
$DIFF test.expect test.out $DIFF test.expect test.out
rm test.in test.expect test.out rm test.in test.expect test.out