forked from kemitix/git-next
chore: convert project into a cargo workspace
This commit is contained in:
parent
1cd56d953e
commit
834dff4370
41 changed files with 96 additions and 32 deletions
|
@ -1,4 +1,4 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# cc-cli as a commit hook
|
# cc-cli as a commit hook
|
||||||
exec < /dev/tty
|
exec </dev/tty
|
||||||
cargo bin cc-cli "$@"
|
cc-cli "$@"
|
||||||
|
|
31
Cargo.toml
31
Cargo.toml
|
@ -1,16 +1,14 @@
|
||||||
[package]
|
[workspace]
|
||||||
name = "git-next"
|
resolver = "2"
|
||||||
version = "0.3.0"
|
members = ["crates/cli"]
|
||||||
edition = "2021"
|
|
||||||
|
|
||||||
[features]
|
[workspace.lints.clippy]
|
||||||
default = ["forgejo"]
|
nursery = { level = "warn", priority = -1 }
|
||||||
forgejo = []
|
# pedantic = "warn"
|
||||||
github = []
|
unwrap_used = "warn"
|
||||||
|
expect_used = "warn"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
[workspace.dependencies]
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
# CLI parsing
|
# CLI parsing
|
||||||
clap = { version = "4.5", features = ["cargo", "derive"] }
|
clap = { version = "4.5", features = ["cargo", "derive"] }
|
||||||
|
|
||||||
|
@ -66,19 +64,8 @@ actix = "0.13"
|
||||||
actix-rt = "2.9"
|
actix-rt = "2.9"
|
||||||
tokio = { version = "1.37", features = ["full"] }
|
tokio = { version = "1.37", features = ["full"] }
|
||||||
|
|
||||||
[dev-dependencies]
|
|
||||||
# Testing
|
# Testing
|
||||||
assert2 = "0.3"
|
assert2 = "0.3"
|
||||||
pretty_assertions = "1.4"
|
pretty_assertions = "1.4"
|
||||||
test-log = { version = "0.2", features = ["env_logger", "trace"] }
|
test-log = { version = "0.2", features = ["env_logger", "trace"] }
|
||||||
anyhow = "1.0"
|
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
73
crates/cli/Cargo.toml
Normal 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"
|
|
@ -15,7 +15,7 @@ pub fn run(fs: FileSystem) {
|
||||||
file_name
|
file_name
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
match fs.file_write(&pathbuf, include_str!("../default.toml")) {
|
match fs.file_write(&pathbuf, include_str!("../../../default.toml")) {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
println!("Created a default configuration file at {}", file_name);
|
println!("Created a default configuration file at {}", file_name);
|
||||||
}
|
}
|
|
@ -163,13 +163,14 @@ fn gitdir_should_display_as_pathbuf() {
|
||||||
// git.kemitix.net:kemitix/git-next
|
// git.kemitix.net:kemitix/git-next
|
||||||
// If the default push remote is something else, then this test will fail
|
// If the default push remote is something else, then this test will fail
|
||||||
fn repo_details_find_default_push_remote_finds_correct_remote() -> Result<()> {
|
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(
|
let mut repo_details = common::repo_details(
|
||||||
1,
|
1,
|
||||||
ServerGeneration::new(),
|
ServerGeneration::new(),
|
||||||
common::forge_details(1, ForgeType::MockForge),
|
common::forge_details(1, ForgeType::MockForge),
|
||||||
None,
|
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.forge.hostname = Hostname("git.kemitix.net".to_string());
|
||||||
repo_details.repo_path = RepoPath("kemitix/git-next".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]
|
#[test]
|
||||||
fn gitdir_validate_should_pass_a_valid_git_repo() -> Result<()> {
|
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(
|
let mut repo_details = common::repo_details(
|
||||||
1,
|
1,
|
||||||
ServerGeneration::new(),
|
ServerGeneration::new(),
|
||||||
common::forge_details(1, ForgeType::MockForge),
|
common::forge_details(1, ForgeType::MockForge),
|
||||||
None,
|
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.forge.hostname = Hostname("git.kemitix.net".to_string());
|
||||||
repo_details.repo_path = RepoPath("kemitix/git-next".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]
|
#[test]
|
||||||
fn gitdir_validate_should_fail_a_git_repo_with_wrong_remote() -> Result<()> {
|
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(
|
let mut repo_details = common::repo_details(
|
||||||
1,
|
1,
|
||||||
ServerGeneration::new(),
|
ServerGeneration::new(),
|
||||||
common::forge_details(1, ForgeType::MockForge),
|
common::forge_details(1, ForgeType::MockForge),
|
||||||
None,
|
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.forge.hostname = Hostname("localhost".to_string());
|
||||||
repo_details.repo_path = RepoPath("hello/world".to_string());
|
repo_details.repo_path = RepoPath("hello/world".to_string());
|
|
@ -33,7 +33,7 @@ pub fn init(fs: FileSystem) {
|
||||||
file_name
|
file_name
|
||||||
);
|
);
|
||||||
} else {
|
} 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),
|
Ok(_) => println!("Created a default configuration file at {}", file_name),
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
eprintln!("Failed to write to the configuration file: {}", e)
|
eprintln!("Failed to write to the configuration file: {}", e)
|
1
justfile
1
justfile
|
@ -1,5 +1,6 @@
|
||||||
install-hooks:
|
install-hooks:
|
||||||
@echo "Installing git hooks"
|
@echo "Installing git hooks"
|
||||||
|
cargo install cc-cli
|
||||||
git config core.hooksPath .git-hooks
|
git config core.hooksPath .git-hooks
|
||||||
|
|
||||||
validate-dev-branch:
|
validate-dev-branch:
|
||||||
|
|
Loading…
Reference in a new issue