mirror of
https://github.com/casey/just.git
synced 2025-08-04 15:08:39 +00:00
Remove ref-type crate (#2364)
This commit is contained in:
parent
5fb514c1c6
commit
2052b1bcfd
5 changed files with 22 additions and 227 deletions
|
@ -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"
|
|
@ -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}");
|
||||
}
|
|
@ -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"
|
||||
);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue