chore: convert project into a cargo workspace
All checks were successful
ci/woodpecker/push/cron-docker-builder Pipeline was successful
ci/woodpecker/push/push-next Pipeline was successful
ci/woodpecker/push/tag-created Pipeline was successful

This commit is contained in:
Paul Campbell 2024-05-11 11:11:13 +01:00
parent 1cd56d953e
commit 834dff4370
41 changed files with 96 additions and 32 deletions

View file

@ -1,4 +1,4 @@
#!/bin/sh
# cc-cli as a commit hook
exec < /dev/tty
cargo bin cc-cli "$@"
exec </dev/tty
cc-cli "$@"

View file

@ -1,16 +1,14 @@
[package]
name = "git-next"
version = "0.3.0"
edition = "2021"
[workspace]
resolver = "2"
members = ["crates/cli"]
[features]
default = ["forgejo"]
forgejo = []
github = []
[workspace.lints.clippy]
nursery = { level = "warn", priority = -1 }
# pedantic = "warn"
unwrap_used = "warn"
expect_used = "warn"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
[workspace.dependencies]
# CLI parsing
clap = { version = "4.5", features = ["cargo", "derive"] }
@ -66,19 +64,8 @@ actix = "0.13"
actix-rt = "2.9"
tokio = { version = "1.37", features = ["full"] }
[dev-dependencies]
# Testing
assert2 = "0.3"
pretty_assertions = "1.4"
test-log = { version = "0.2", features = ["env_logger", "trace"] }
anyhow = "1.0"
[package.metadata.bin]
# Conventional commits githook
cc-cli = { version = "0.1" }
[lints.clippy]
nursery = { level = "warn", priority = -1 }
# pedantic = "warn"
unwrap_used = "warn"
expect_used = "warn"

73
crates/cli/Cargo.toml Normal file
View file

@ -0,0 +1,73 @@
[package]
name = "git-next"
version = "0.3.0"
edition = "2021"
[features]
default = ["forgejo"]
forgejo = []
github = []
[dependencies]
# CLI parsing
clap = { workspace = true }
# logging
console-subscriber = { workspace = true }
tracing = { workspace = true }
tracing-subscriber = { workspace = true }
# base64 decoding
base64 = { workspace = true }
# git
# gix = { workspace = true }
gix = { workspace = true }
async-trait = { workspace = true }
# fs/network
kxio = { workspace = true }
# fs
tempfile = { workspace = true }
# TOML parsing
serde = { workspace = true }
serde_json = { workspace = true }
toml = { workspace = true }
# Secrets and Password
secrecy = { workspace = true }
# Conventional Commit check
git-conventional = { workspace = true }
# Webhooks
bytes = { workspace = true }
ulid = { workspace = true }
warp = { workspace = true }
# error handling
derive_more = { workspace = true }
terrors = { workspace = true }
# file watcher
inotify = { workspace = true }
# Actors
actix = { workspace = true }
actix-rt = { workspace = true }
tokio = { workspace = true }
[dev-dependencies]
# Testing
assert2 = { workspace = true }
pretty_assertions = { workspace = true }
test-log = { workspace = true }
anyhow = { workspace = true }
[lints.clippy]
nursery = { level = "warn", priority = -1 }
# pedantic = "warn"
unwrap_used = "warn"
expect_used = "warn"

View file

@ -15,7 +15,7 @@ pub fn run(fs: FileSystem) {
file_name
);
} else {
match fs.file_write(&pathbuf, include_str!("../default.toml")) {
match fs.file_write(&pathbuf, include_str!("../../../default.toml")) {
Ok(_) => {
println!("Created a default configuration file at {}", file_name);
}

View file

@ -163,13 +163,14 @@ fn gitdir_should_display_as_pathbuf() {
// git.kemitix.net:kemitix/git-next
// If the default push remote is something else, then this test will fail
fn repo_details_find_default_push_remote_finds_correct_remote() -> Result<()> {
let cwd = std::env::current_dir().map_err(RepoValidationError::Io)?;
let cli_crate_dir = std::env::current_dir().map_err(RepoValidationError::Io)?;
let_assert!(Some(Some(root)) = cli_crate_dir.parent().map(|p| p.parent()));
let mut repo_details = common::repo_details(
1,
ServerGeneration::new(),
common::forge_details(1, ForgeType::MockForge),
None,
GitDir::new(&cwd), // Server GitDir - should be ignored
GitDir::new(&root), // Server GitDir - should be ignored
);
repo_details.forge.hostname = Hostname("git.kemitix.net".to_string());
repo_details.repo_path = RepoPath("kemitix/git-next".to_string());
@ -188,13 +189,14 @@ fn repo_details_find_default_push_remote_finds_correct_remote() -> Result<()> {
#[test]
fn gitdir_validate_should_pass_a_valid_git_repo() -> Result<()> {
let cwd = std::env::current_dir().map_err(RepoValidationError::Io)?;
let cli_crate_dir = std::env::current_dir().map_err(RepoValidationError::Io)?;
let_assert!(Some(Some(root)) = cli_crate_dir.parent().map(|p| p.parent()));
let mut repo_details = common::repo_details(
1,
ServerGeneration::new(),
common::forge_details(1, ForgeType::MockForge),
None,
GitDir::new(&cwd), // Server GitDir - should be ignored
GitDir::new(&root), // Server GitDir - should be ignored
);
repo_details.forge.hostname = Hostname("git.kemitix.net".to_string());
repo_details.repo_path = RepoPath("kemitix/git-next".to_string());
@ -207,13 +209,14 @@ fn gitdir_validate_should_pass_a_valid_git_repo() -> Result<()> {
#[test]
fn gitdir_validate_should_fail_a_git_repo_with_wrong_remote() -> Result<()> {
let_assert!(Ok(cwd) = std::env::current_dir().map_err(RepoValidationError::Io));
let_assert!(Ok(cli_crate_dir) = std::env::current_dir().map_err(RepoValidationError::Io));
let_assert!(Some(Some(root)) = cli_crate_dir.parent().map(|p| p.parent()));
let mut repo_details = common::repo_details(
1,
ServerGeneration::new(),
common::forge_details(1, ForgeType::MockForge),
None,
GitDir::new(&cwd), // Server GitDir - should be ignored
GitDir::new(&root), // Server GitDir - should be ignored
);
repo_details.forge.hostname = Hostname("localhost".to_string());
repo_details.repo_path = RepoPath("hello/world".to_string());

View file

@ -33,7 +33,7 @@ pub fn init(fs: FileSystem) {
file_name
);
} else {
match fs.file_write(&pathbuf, include_str!("../../server-default.toml")) {
match fs.file_write(&pathbuf, include_str!("../../../../server-default.toml")) {
Ok(_) => println!("Created a default configuration file at {}", file_name),
Err(e) => {
eprintln!("Failed to write to the configuration file: {}", e)

View file

@ -1,5 +1,6 @@
install-hooks:
@echo "Installing git hooks"
cargo install cc-cli
git config core.hooksPath .git-hooks
validate-dev-branch: