Compare commits
3 commits
7aa0ce2e6a
...
de9f1ecd37
Author | SHA1 | Date | |
---|---|---|---|
de9f1ecd37 | |||
7c0da5dc3f | |||
f0daac76b4 |
10 changed files with 276 additions and 22 deletions
187
Cargo.lock
generated
187
Cargo.lock
generated
|
@ -342,6 +342,21 @@ version = "1.3.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a3e368af43e418a04d52505cf3dbc23dda4e3407ae2fa99fd0e4f308ce546acc"
|
||||
|
||||
[[package]]
|
||||
name = "cassowary"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "df8670b8c7b9dae1793364eafadf7239c40d669904660c5960d74cfd80b46a53"
|
||||
|
||||
[[package]]
|
||||
name = "castaway"
|
||||
version = "0.2.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0abae9be0aaf9ea96a3b1b8b1b55c602ca751eba1b1500220cea4ecbafe7c0d5"
|
||||
dependencies = [
|
||||
"rustversion",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.0.95"
|
||||
|
@ -457,6 +472,20 @@ version = "1.0.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7"
|
||||
|
||||
[[package]]
|
||||
name = "compact_str"
|
||||
version = "0.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6050c3a16ddab2e412160b31f2c871015704239bca62f72f6e5f0be631d3f644"
|
||||
dependencies = [
|
||||
"castaway",
|
||||
"cfg-if",
|
||||
"itoa",
|
||||
"rustversion",
|
||||
"ryu",
|
||||
"static_assertions",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "constant_time_eq"
|
||||
version = "0.1.5"
|
||||
|
@ -553,6 +582,31 @@ version = "0.8.19"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345"
|
||||
|
||||
[[package]]
|
||||
name = "crossterm"
|
||||
version = "0.28.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "829d955a0bb380ef178a640b91779e3987da38c9aea133b20614cfed8cdea9c6"
|
||||
dependencies = [
|
||||
"bitflags 2.5.0",
|
||||
"crossterm_winapi",
|
||||
"mio 1.0.1",
|
||||
"parking_lot",
|
||||
"rustix",
|
||||
"signal-hook",
|
||||
"signal-hook-mio",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossterm_winapi"
|
||||
version = "0.9.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "acdd7c62a3665c7f6830a51635d9ac9b23ed385797f70a83bb8bafe9c572ab2b"
|
||||
dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crypto-common"
|
||||
version = "0.1.6"
|
||||
|
@ -960,6 +1014,7 @@ dependencies = [
|
|||
"notify",
|
||||
"pretty_assertions",
|
||||
"rand",
|
||||
"ratatui",
|
||||
"secrecy",
|
||||
"sendmail",
|
||||
"serde_json",
|
||||
|
@ -1047,8 +1102,8 @@ checksum = "b037f7449dd4a8b711e660301ff1ff28aa00eea09698421fb2d78db51a7b7a72"
|
|||
dependencies = [
|
||||
"color-eyre",
|
||||
"regex",
|
||||
"strum",
|
||||
"strum_macros",
|
||||
"strum 0.24.1",
|
||||
"strum_macros 0.24.3",
|
||||
"tracing",
|
||||
"url",
|
||||
]
|
||||
|
@ -2308,6 +2363,16 @@ dependencies = [
|
|||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "instability"
|
||||
version = "0.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b23a0c8dfe501baac4adf6ebbfa6eddf8f0c07f56b058cc1288017e32397846c"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"syn 2.0.60",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "io-close"
|
||||
version = "0.3.7"
|
||||
|
@ -2335,6 +2400,15 @@ dependencies = [
|
|||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itertools"
|
||||
version = "0.13.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186"
|
||||
dependencies = [
|
||||
"either",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itoa"
|
||||
version = "1.0.11"
|
||||
|
@ -2477,6 +2551,15 @@ version = "0.4.21"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c"
|
||||
|
||||
[[package]]
|
||||
name = "lru"
|
||||
version = "0.12.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "37ee39891760e7d94734f6f63fedc29a2e4a152f836120753a72503f09fcf904"
|
||||
dependencies = [
|
||||
"hashbrown 0.14.5",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "mac-notification-sys"
|
||||
version = "0.3.0"
|
||||
|
@ -2576,6 +2659,19 @@ dependencies = [
|
|||
"windows-sys 0.48.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "mio"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4569e456d394deccd22ce1c1913e6ea0e54519f577285001215d33557431afe4"
|
||||
dependencies = [
|
||||
"hermit-abi",
|
||||
"libc",
|
||||
"log",
|
||||
"wasi 0.11.0+wasi-snapshot-preview1",
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "mockall"
|
||||
version = "0.13.0"
|
||||
|
@ -2673,7 +2769,7 @@ dependencies = [
|
|||
"kqueue",
|
||||
"libc",
|
||||
"log",
|
||||
"mio",
|
||||
"mio 0.8.11",
|
||||
"walkdir",
|
||||
"windows-sys 0.48.0",
|
||||
]
|
||||
|
@ -2855,6 +2951,12 @@ dependencies = [
|
|||
"windows-targets 0.52.5",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "paste"
|
||||
version = "1.0.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a"
|
||||
|
||||
[[package]]
|
||||
name = "path-clean"
|
||||
version = "1.0.1"
|
||||
|
@ -3038,6 +3140,27 @@ dependencies = [
|
|||
"getrandom 0.2.14",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ratatui"
|
||||
version = "0.28.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5ba6a365afbe5615999275bea2446b970b10a41102500e27ce7678d50d978303"
|
||||
dependencies = [
|
||||
"bitflags 2.5.0",
|
||||
"cassowary",
|
||||
"compact_str",
|
||||
"crossterm",
|
||||
"instability",
|
||||
"itertools",
|
||||
"lru",
|
||||
"paste",
|
||||
"strum 0.26.3",
|
||||
"strum_macros 0.26.4",
|
||||
"unicode-segmentation",
|
||||
"unicode-truncate",
|
||||
"unicode-width",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rayon"
|
||||
version = "1.10.0"
|
||||
|
@ -3484,6 +3607,17 @@ dependencies = [
|
|||
"signal-hook-registry",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "signal-hook-mio"
|
||||
version = "0.2.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "34db1a06d485c9142248b7a054f034b349b212551f3dfd19c94d45a754a217cd"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"mio 1.0.1",
|
||||
"signal-hook",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "signal-hook-registry"
|
||||
version = "1.4.2"
|
||||
|
@ -3568,6 +3702,15 @@ version = "0.24.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "063e6045c0e62079840579a7e47a355ae92f60eb74daaf156fb1e84ba164e63f"
|
||||
|
||||
[[package]]
|
||||
name = "strum"
|
||||
version = "0.26.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8fec0f0aef304996cf250b31b5a10dee7980c85da9d759361292b8bca5a18f06"
|
||||
dependencies = [
|
||||
"strum_macros 0.26.4",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "strum_macros"
|
||||
version = "0.24.3"
|
||||
|
@ -3581,6 +3724,19 @@ dependencies = [
|
|||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "strum_macros"
|
||||
version = "0.26.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4c6bee85a5a24955dc440386795aa378cd9cf82acd5f764469152d2270e581be"
|
||||
dependencies = [
|
||||
"heck 0.5.0",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"rustversion",
|
||||
"syn 2.0.60",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "subtle"
|
||||
version = "2.5.0"
|
||||
|
@ -3769,7 +3925,7 @@ dependencies = [
|
|||
"backtrace",
|
||||
"bytes",
|
||||
"libc",
|
||||
"mio",
|
||||
"mio 0.8.11",
|
||||
"num_cpus",
|
||||
"parking_lot",
|
||||
"pin-project-lite",
|
||||
|
@ -4058,6 +4214,29 @@ dependencies = [
|
|||
"tinyvec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-segmentation"
|
||||
version = "1.11.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-truncate"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b3644627a5af5fa321c95b9b235a72fd24cd29c648c2c379431e6628655627bf"
|
||||
dependencies = [
|
||||
"itertools",
|
||||
"unicode-segmentation",
|
||||
"unicode-width",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-width"
|
||||
version = "0.1.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-xid"
|
||||
version = "0.2.4"
|
||||
|
|
|
@ -26,6 +26,9 @@ git-next-core = { path = "crates/core", version = "0.13" }
|
|||
git-next-forge-forgejo = { path = "crates/forge-forgejo", version = "0.13" }
|
||||
git-next-forge-github = { path = "crates/forge-github", version = "0.13" }
|
||||
|
||||
# TUI
|
||||
ratatui = "0.28"
|
||||
|
||||
# CLI parsing
|
||||
clap = { version = "4.5", features = ["cargo", "derive"] }
|
||||
|
||||
|
|
|
@ -12,15 +12,19 @@ keywords = { workspace = true }
|
|||
categories = { workspace = true }
|
||||
|
||||
[features]
|
||||
default = ["forgejo", "github"]
|
||||
default = ["forgejo", "github", "tui"]
|
||||
forgejo = ["git-next-forge-forgejo"]
|
||||
github = ["git-next-forge-github"]
|
||||
tui = ["ratatui"]
|
||||
|
||||
[dependencies]
|
||||
git-next-core = { workspace = true }
|
||||
git-next-forge-forgejo = { workspace = true, optional = true }
|
||||
git-next-forge-github = { workspace = true, optional = true }
|
||||
|
||||
# TUI
|
||||
ratatui = { workspace = true, optional = true }
|
||||
|
||||
# CLI parsing
|
||||
clap = { workspace = true }
|
||||
|
||||
|
|
|
@ -36,17 +36,17 @@ fn short_message(user_notification: &UserNotification) -> String {
|
|||
repo_alias,
|
||||
commit,
|
||||
log: _,
|
||||
} => format!("CI Check Failed: {forge_alias}/{repo_alias}: {commit}"),
|
||||
} => format!("{forge_alias}/{repo_alias}: CI Check Failed: {commit}"),
|
||||
UserNotification::RepoConfigLoadFailure {
|
||||
forge_alias,
|
||||
repo_alias,
|
||||
reason: _,
|
||||
} => format!("Invalid Repo Config: {forge_alias}/{repo_alias}"),
|
||||
} => format!("{forge_alias}/{repo_alias}: Invalid Repo Config"),
|
||||
UserNotification::WebhookRegistration {
|
||||
forge_alias,
|
||||
repo_alias,
|
||||
reason: _,
|
||||
} => format!("Failed Webhook Registration: {forge_alias}/{repo_alias}"),
|
||||
} => format!("{forge_alias}/{repo_alias}: Failed Webhook Registration"),
|
||||
UserNotification::DevNotBasedOnMain {
|
||||
forge_alias,
|
||||
repo_alias,
|
||||
|
@ -55,7 +55,7 @@ fn short_message(user_notification: &UserNotification) -> String {
|
|||
dev_commit: _,
|
||||
main_commit: _,
|
||||
log: _,
|
||||
} => format!("Dev not based on Main: {forge_alias}/{repo_alias}"),
|
||||
} => format!("{forge_alias}/{repo_alias}: Dev not based on Main"),
|
||||
};
|
||||
format!("[git-next] {tail}")
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ fn when_history_has_expired_then_message_is_passed() {
|
|||
|
||||
#[test]
|
||||
fn when_history_has_unexpired_then_message_is_blocked() {
|
||||
let dur = Duration::from_millis(1);
|
||||
let dur = Duration::from_secs(1);
|
||||
let mut history = History::new(dur);
|
||||
|
||||
let user_notification = UserNotification::RepoConfigLoadFailure {
|
||||
|
|
1
crates/cli/src/tui/actor/handlers/mod.rs
Normal file
1
crates/cli/src/tui/actor/handlers/mod.rs
Normal file
|
@ -0,0 +1 @@
|
|||
//
|
4
crates/cli/src/tui/actor/messages.rs
Normal file
4
crates/cli/src/tui/actor/messages.rs
Normal file
|
@ -0,0 +1,4 @@
|
|||
//
|
||||
use git_next_core::message;
|
||||
|
||||
message!(Start, "Start the TUI");
|
61
crates/cli/src/tui/actor/mod.rs
Normal file
61
crates/cli/src/tui/actor/mod.rs
Normal file
|
@ -0,0 +1,61 @@
|
|||
//
|
||||
mod handlers;
|
||||
pub mod messages;
|
||||
|
||||
use std::io::{stderr, Stderr};
|
||||
|
||||
use actix::{Actor, Context};
|
||||
|
||||
use ratatui::{
|
||||
crossterm::{
|
||||
execute,
|
||||
terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen},
|
||||
},
|
||||
prelude::CrosstermBackend,
|
||||
Terminal,
|
||||
};
|
||||
|
||||
pub struct Tui {
|
||||
terminal: Option<Terminal<CrosstermBackend<Stderr>>>,
|
||||
}
|
||||
|
||||
impl Actor for Tui {
|
||||
type Context = Context<Self>;
|
||||
|
||||
fn started(&mut self, _ctx: &mut Self::Context) {
|
||||
match init() {
|
||||
Ok(terminal) => {
|
||||
self.terminal.replace(terminal);
|
||||
}
|
||||
Err(err) => tracing::error!(?err, "Failed to start terminal UI"),
|
||||
}
|
||||
}
|
||||
|
||||
fn stopped(&mut self, _ctx: &mut Self::Context) {
|
||||
if let Err(err) = restore() {
|
||||
match std::env::consts::OS {
|
||||
"linux" | "macos" => {
|
||||
tracing::error!(
|
||||
?err,
|
||||
"Failed to restore terminal: Type `reset` to restore terminal"
|
||||
);
|
||||
}
|
||||
"windows" => {
|
||||
tracing::error!(?err, "Failed to restore terminal: Reopen a new terminal");
|
||||
}
|
||||
_ => tracing::error!(?err, "Failed to restore terminal"),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn init() -> std::io::Result<Terminal<CrosstermBackend<Stderr>>> {
|
||||
execute!(stderr(), EnterAlternateScreen)?;
|
||||
enable_raw_mode()?;
|
||||
Terminal::new(CrosstermBackend::new(stderr()))
|
||||
}
|
||||
|
||||
fn restore() -> std::io::Result<()> {
|
||||
execute!(stderr(), LeaveAlternateScreen)?;
|
||||
disable_raw_mode()
|
||||
}
|
2
crates/cli/src/tui/mod.rs
Normal file
2
crates/cli/src/tui/mod.rs
Normal file
|
@ -0,0 +1,2 @@
|
|||
//
|
||||
mod actor;
|
|
@ -1,23 +1,23 @@
|
|||
[workspace]
|
||||
# Disable git releases for all packages by default
|
||||
git_release_enable = false
|
||||
git_release_enable = true
|
||||
|
||||
# Disable git tags for all packages by default
|
||||
git_tag_enable = false
|
||||
git_tag_enable = true
|
||||
|
||||
# set the path of all the crates to the changelog to the root of the repository
|
||||
changelog_path = "./CHANGELOG.md"
|
||||
|
||||
[[package]]
|
||||
name = "git-next"
|
||||
# (Optional) Customize the git tag name to remove the `my_main_package` prefix.
|
||||
git_tag_name = "v{{ version }}"
|
||||
|
||||
# Enable git tags for this package
|
||||
git_tag_enable = true
|
||||
|
||||
# Enable git releases for this package
|
||||
git_release_enable = true
|
||||
# [[package]]
|
||||
# name = "git-next"
|
||||
# # (Optional) Customize the git tag name to remove the `my_main_package` prefix.
|
||||
# git_tag_name = "v{{ version }}"
|
||||
#
|
||||
# # Enable git tags for this package
|
||||
# git_tag_enable = true
|
||||
#
|
||||
# # Enable git releases for this package
|
||||
# git_release_enable = true
|
||||
|
||||
[changelog]
|
||||
body = """
|
||||
|
|
Loading…
Reference in a new issue