Remove ref-type crate (#2364)

This commit is contained in:
Casey Rodarmor 2024-09-13 16:34:30 +07:00 committed by GitHub
parent 5fb514c1c6
commit 2052b1bcfd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 22 additions and 227 deletions

View file

@ -1,13 +0,0 @@
[package]
name = "ref-type"
version = "0.0.0"
authors = ["Casey Rodarmor <casey@rodarmor.com>"]
edition = "2018"
publish = false
[dependencies]
regex = "1.5.4"
structopt = "0.3.21"
[dev-dependencies]
executable-path = "1.0.0"

View file

@ -1,25 +0,0 @@
use {regex::Regex, structopt::StructOpt};
#[derive(StructOpt)]
struct Arguments {
#[structopt(long)]
reference: String,
}
fn main() {
let arguments = Arguments::from_args();
let regex = Regex::new("^refs/tags/[[:digit:]]+[.][[:digit:]]+[.][[:digit:]]+$")
.expect("Failed to compile release regex");
let value = if regex.is_match(&arguments.reference) {
"release"
} else {
"other"
};
eprintln!("ref: {}", arguments.reference);
eprintln!("value: {value}");
println!("value={value}");
}

View file

@ -1,38 +0,0 @@
use {
executable_path::executable_path,
std::{process::Command, str},
};
fn stdout(reference: &str) -> String {
let output = Command::new(executable_path("ref-type"))
.args(["--reference", reference])
.output()
.unwrap();
assert!(output.status.success());
String::from_utf8(output.stdout).unwrap()
}
#[test]
fn junk_is_other() {
assert_eq!(stdout("refs/tags/asdf"), "value=other\n");
}
#[test]
fn valid_version_is_release() {
assert_eq!(stdout("refs/tags/0.0.0"), "value=release\n");
}
#[test]
fn valid_version_with_trailing_characters_is_other() {
assert_eq!(stdout("refs/tags/0.0.0-rc1"), "value=other\n");
}
#[test]
fn valid_version_with_lots_of_digits_is_release() {
assert_eq!(
stdout("refs/tags/01232132.098327498374.43268473849734"),
"value=release\n"
);
}