v2 #1
@ -52,3 +52,36 @@ jobs:
|
|||||||
|
|
||||||
- name: Test
|
- name: Test
|
||||||
run: cargo test --release
|
run: cargo test --release
|
||||||
|
|
||||||
|
check-version:
|
||||||
|
name: Check version
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: check version
|
||||||
|
run: |
|
||||||
|
# Get base branch (usually main)
|
||||||
|
BASE_REF="${{ github.base_ref }}"
|
||||||
|
if [ -z "$BASE_REF" ]; then
|
||||||
|
BASE_REF="main"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Get current version
|
||||||
|
CURRENT_VERSION=$(grep -m 1 '^version = ' Cargo.toml | sed 's/version = "\(.*\)"/\1/')
|
||||||
|
echo "Current version: $CURRENT_VERSION"
|
||||||
|
|
||||||
|
# Get version from base branch
|
||||||
|
git fetch origin $BASE_REF
|
||||||
|
BASE_VERSION=$(git show origin/$BASE_REF:Cargo.toml | grep -m 1 '^version = ' | sed 's/version = "\(.*\)"/\1/')
|
||||||
|
echo "Base version: $BASE_VERSION"
|
||||||
|
|
||||||
|
# Check if version changed
|
||||||
|
if [ "$CURRENT_VERSION" = "$BASE_VERSION" ]; then
|
||||||
|
echo "::error::Version in Cargo.toml has not been changed."
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo "Version has been updated from $BASE_VERSION to $CURRENT_VERSION"
|
||||||
|
fi
|
||||||
|
19
.gitea/workflows/release.yml
Normal file
19
.gitea/workflows/release.yml
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
name: Release
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
release:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
id: use-go-action
|
||||||
|
uses: https://gitea.com/actions/release-action@main
|
||||||
|
with:
|
||||||
|
api_key: '${{secrets.RELEASE_TOKEN}}'
|
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -306,7 +306,7 @@ checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pick"
|
name = "pick"
|
||||||
version = "0.0.1"
|
version = "0.0.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anstyle",
|
"anstyle",
|
||||||
"anyhow",
|
"anyhow",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "pick"
|
name = "pick"
|
||||||
version = "0.0.1"
|
version = "0.0.2"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{ lib, fetchgit, rustPlatform }:
|
{ lib, fetchgit, rustPlatform }:
|
||||||
rustPlatform.buildRustPackage rec {
|
rustPlatform.buildRustPackage rec {
|
||||||
pname = "pick";
|
pname = "pick";
|
||||||
version = "0.0.1";
|
version = "0.0.2";
|
||||||
cargoLock.lockFile = src + /Cargo.lock;
|
cargoLock.lockFile = src + /Cargo.lock;
|
||||||
|
|
||||||
src = builtins.fetchGit {
|
src = builtins.fetchGit {
|
||||||
|
@ -25,34 +25,26 @@ impl RegexSegment {
|
|||||||
// Neighboring doublestar is always responsible for slashes
|
// Neighboring doublestar is always responsible for slashes
|
||||||
(_, Self::Single(x), Some(Self::DoubleStar)) => x.to_owned(),
|
(_, Self::Single(x), Some(Self::DoubleStar)) => x.to_owned(),
|
||||||
|
|
||||||
// [^/]+ is a "segment" (a block of non-slash chars)
|
|
||||||
// The "base" doublestar pattern is a segment
|
|
||||||
// followed by zero or more segments prefixed by a slash.
|
|
||||||
//
|
|
||||||
// No additional slashes
|
// No additional slashes
|
||||||
(None, Self::DoubleStar, None) => "((?:[^/]+(?:[/][^/]+)*)?)".into(),
|
(None, Self::DoubleStar, None) => "((?:.*)?)".into(),
|
||||||
|
|
||||||
|
// Leading slash
|
||||||
|
(Some(Self::Single(_)), Self::DoubleStar, None) => "((?:[/].*)?)".into(),
|
||||||
|
|
||||||
|
// Trailing slash
|
||||||
|
(None, Self::DoubleStar, Some(Self::Single(_))) => "((?:.*[/])?)".into(),
|
||||||
|
|
||||||
|
// Leading and trailing slash.
|
||||||
|
// Also, replace self with a [/] when empty.
|
||||||
|
(Some(Self::Single(_)), Self::DoubleStar, Some(Self::Single(_))) => {
|
||||||
|
"((?:[/].*[/])|[/])".into()
|
||||||
|
}
|
||||||
|
|
||||||
// Doublestars cannot be neighbors
|
// Doublestars cannot be neighbors
|
||||||
(_, Self::DoubleStar, Some(Self::DoubleStar))
|
(_, Self::DoubleStar, Some(Self::DoubleStar))
|
||||||
| (Some(Self::DoubleStar), Self::DoubleStar, _) => {
|
| (Some(Self::DoubleStar), Self::DoubleStar, _) => {
|
||||||
unreachable!("consecutive doublestars must be reduced")
|
unreachable!("consecutive doublestars must be reduced")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Leading slash
|
|
||||||
(Some(Self::Single(_)), Self::DoubleStar, None) => {
|
|
||||||
"((?:[/][^/]+(?:[/][^/]+)*)?)".into()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Trailing slash
|
|
||||||
(None, Self::DoubleStar, Some(Self::Single(_))) => {
|
|
||||||
"((?:[^/]+(?:[/][^/]+)*[/])?)".into()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Leading and trailing slash.
|
|
||||||
// Also, replace self with a [/] when empty.
|
|
||||||
(Some(Self::Single(_)), Self::DoubleStar, Some(Self::Single(_))) => {
|
|
||||||
"((?:[/][^/]+(?:[/][^/]+)*[/])|[/])".into()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -301,6 +293,34 @@ mod tests {
|
|||||||
assert!(!regex.is_match("root/testfile"));
|
assert!(!regex.is_match("root/testfile"));
|
||||||
assert!(!regex.is_match("root/testxxfile"));
|
assert!(!regex.is_match("root/testxxfile"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn doublestar_nullable() {
|
||||||
|
let regex = rule_regex(&["root/**/file"]);
|
||||||
|
|
||||||
|
assert!(regex.is_match("root/test/file"));
|
||||||
|
assert!(regex.is_match("root/file"));
|
||||||
|
assert!(!regex.is_match("rootfile"));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn doublestar_nullable_post() {
|
||||||
|
let regex = rule_regex(&["root/**"]);
|
||||||
|
|
||||||
|
assert!(regex.is_match("root"));
|
||||||
|
assert!(regex.is_match("root/file"));
|
||||||
|
assert!(!regex.is_match("rootfile"));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn doublestar_nullable_pre() {
|
||||||
|
let regex = rule_regex(&["**/file"]);
|
||||||
|
|
||||||
|
assert!(regex.is_match("file"));
|
||||||
|
assert!(regex.is_match("root/file"));
|
||||||
|
assert!(!regex.is_match("rootfile"));
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn doublestar_bad_extension() {
|
fn doublestar_bad_extension() {
|
||||||
let regex = rule_regex(&["**.flac"]);
|
let regex = rule_regex(&["**.flac"]);
|
||||||
|
Reference in New Issue
Block a user