Compare commits

...

3 commits

Author SHA1 Message Date
7aa0ce2e6a WIP: TUI actor
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
2024-08-10 16:50:48 +01:00
7243447efa fix: release-plx generated PR changelog 2024-08-10 16:50:48 +01:00
907db9f122 feat: make forge and repo alias more prominent in email
Some checks failed
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
Rust / build (push) Failing after 5s
Closes kemitix/git-next#141
2024-08-10 08:20:49 +01:00
10 changed files with 278 additions and 21 deletions

187
Cargo.lock generated
View file

@ -342,6 +342,21 @@ version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a3e368af43e418a04d52505cf3dbc23dda4e3407ae2fa99fd0e4f308ce546acc" 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]] [[package]]
name = "cc" name = "cc"
version = "1.0.95" version = "1.0.95"
@ -457,6 +472,20 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" 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]] [[package]]
name = "constant_time_eq" name = "constant_time_eq"
version = "0.1.5" version = "0.1.5"
@ -553,6 +582,31 @@ version = "0.8.19"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345" 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]] [[package]]
name = "crypto-common" name = "crypto-common"
version = "0.1.6" version = "0.1.6"
@ -960,6 +1014,7 @@ dependencies = [
"notify", "notify",
"pretty_assertions", "pretty_assertions",
"rand", "rand",
"ratatui",
"secrecy", "secrecy",
"sendmail", "sendmail",
"serde_json", "serde_json",
@ -1047,8 +1102,8 @@ checksum = "b037f7449dd4a8b711e660301ff1ff28aa00eea09698421fb2d78db51a7b7a72"
dependencies = [ dependencies = [
"color-eyre", "color-eyre",
"regex", "regex",
"strum", "strum 0.24.1",
"strum_macros", "strum_macros 0.24.3",
"tracing", "tracing",
"url", "url",
] ]
@ -2308,6 +2363,16 @@ dependencies = [
"libc", "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]] [[package]]
name = "io-close" name = "io-close"
version = "0.3.7" version = "0.3.7"
@ -2335,6 +2400,15 @@ dependencies = [
"windows-sys 0.52.0", "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]] [[package]]
name = "itoa" name = "itoa"
version = "1.0.11" version = "1.0.11"
@ -2477,6 +2551,15 @@ version = "0.4.21"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" 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]] [[package]]
name = "mac-notification-sys" name = "mac-notification-sys"
version = "0.3.0" version = "0.3.0"
@ -2576,6 +2659,19 @@ dependencies = [
"windows-sys 0.48.0", "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]] [[package]]
name = "mockall" name = "mockall"
version = "0.13.0" version = "0.13.0"
@ -2673,7 +2769,7 @@ dependencies = [
"kqueue", "kqueue",
"libc", "libc",
"log", "log",
"mio", "mio 0.8.11",
"walkdir", "walkdir",
"windows-sys 0.48.0", "windows-sys 0.48.0",
] ]
@ -2855,6 +2951,12 @@ dependencies = [
"windows-targets 0.52.5", "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]] [[package]]
name = "path-clean" name = "path-clean"
version = "1.0.1" version = "1.0.1"
@ -3038,6 +3140,27 @@ dependencies = [
"getrandom 0.2.14", "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]] [[package]]
name = "rayon" name = "rayon"
version = "1.10.0" version = "1.10.0"
@ -3484,6 +3607,17 @@ dependencies = [
"signal-hook-registry", "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]] [[package]]
name = "signal-hook-registry" name = "signal-hook-registry"
version = "1.4.2" version = "1.4.2"
@ -3568,6 +3702,15 @@ version = "0.24.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "063e6045c0e62079840579a7e47a355ae92f60eb74daaf156fb1e84ba164e63f" 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]] [[package]]
name = "strum_macros" name = "strum_macros"
version = "0.24.3" version = "0.24.3"
@ -3581,6 +3724,19 @@ dependencies = [
"syn 1.0.109", "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]] [[package]]
name = "subtle" name = "subtle"
version = "2.5.0" version = "2.5.0"
@ -3769,7 +3925,7 @@ dependencies = [
"backtrace", "backtrace",
"bytes", "bytes",
"libc", "libc",
"mio", "mio 0.8.11",
"num_cpus", "num_cpus",
"parking_lot", "parking_lot",
"pin-project-lite", "pin-project-lite",
@ -4058,6 +4214,29 @@ dependencies = [
"tinyvec", "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]] [[package]]
name = "unicode-xid" name = "unicode-xid"
version = "0.2.4" version = "0.2.4"

View file

@ -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-forgejo = { path = "crates/forge-forgejo", version = "0.13" }
git-next-forge-github = { path = "crates/forge-github", version = "0.13" } git-next-forge-github = { path = "crates/forge-github", version = "0.13" }
# TUI
ratatui = "0.28"
# CLI parsing # CLI parsing
clap = { version = "4.5", features = ["cargo", "derive"] } clap = { version = "4.5", features = ["cargo", "derive"] }

View file

@ -12,15 +12,19 @@ keywords = { workspace = true }
categories = { workspace = true } categories = { workspace = true }
[features] [features]
default = ["forgejo", "github"] default = ["forgejo", "github", "tui"]
forgejo = ["git-next-forge-forgejo"] forgejo = ["git-next-forge-forgejo"]
github = ["git-next-forge-github"] github = ["git-next-forge-github"]
tui = ["ratatui"]
[dependencies] [dependencies]
git-next-core = { workspace = true } git-next-core = { workspace = true }
git-next-forge-forgejo = { workspace = true, optional = true } git-next-forge-forgejo = { workspace = true, optional = true }
git-next-forge-github = { workspace = true, optional = true } git-next-forge-github = { workspace = true, optional = true }
# TUI
ratatui = { workspace = true, optional = true }
# CLI parsing # CLI parsing
clap = { workspace = true } clap = { workspace = true }

View file

@ -36,17 +36,17 @@ fn short_message(user_notification: &UserNotification) -> String {
repo_alias, repo_alias,
commit, commit,
log: _, log: _,
} => format!("CI Check Failed: {forge_alias}/{repo_alias}: {commit}"), } => format!("{forge_alias}/{repo_alias}: CI Check Failed: {commit}"),
UserNotification::RepoConfigLoadFailure { UserNotification::RepoConfigLoadFailure {
forge_alias, forge_alias,
repo_alias, repo_alias,
reason: _, reason: _,
} => format!("Invalid Repo Config: {forge_alias}/{repo_alias}"), } => format!("{forge_alias}/{repo_alias}: Invalid Repo Config"),
UserNotification::WebhookRegistration { UserNotification::WebhookRegistration {
forge_alias, forge_alias,
repo_alias, repo_alias,
reason: _, reason: _,
} => format!("Failed Webhook Registration: {forge_alias}/{repo_alias}"), } => format!("{forge_alias}/{repo_alias}: Failed Webhook Registration"),
UserNotification::DevNotBasedOnMain { UserNotification::DevNotBasedOnMain {
forge_alias, forge_alias,
repo_alias, repo_alias,
@ -55,7 +55,7 @@ fn short_message(user_notification: &UserNotification) -> String {
dev_commit: _, dev_commit: _,
main_commit: _, main_commit: _,
log: _, 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}") format!("[git-next] {tail}")
} }

View file

@ -1,4 +1,7 @@
// //
#[cfg(feature = "tui")]
mod tui;
mod alerts; mod alerts;
mod file_watcher; mod file_watcher;
mod forge; mod forge;

View file

@ -0,0 +1 @@
//

View file

@ -0,0 +1,4 @@
//
use git_next_core::message;
message!(Start, "Start the TUI");

View 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()
}

View file

@ -0,0 +1,2 @@
//
mod actor;

View file

@ -1,23 +1,23 @@
[workspace] [workspace]
# Disable git releases for all packages by default # Disable git releases for all packages by default
git_release_enable = false git_release_enable = true
# Disable git tags for all packages by default # 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 # set the path of all the crates to the changelog to the root of the repository
changelog_path = "./CHANGELOG.md" changelog_path = "./CHANGELOG.md"
[[package]] # [[package]]
name = "git-next" # name = "git-next"
# (Optional) Customize the git tag name to remove the `my_main_package` prefix. # # (Optional) Customize the git tag name to remove the `my_main_package` prefix.
git_tag_name = "v{{ version }}" # git_tag_name = "v{{ version }}"
#
# Enable git tags for this package # # Enable git tags for this package
git_tag_enable = true # git_tag_enable = true
#
# Enable git releases for this package # # Enable git releases for this package
git_release_enable = true # git_release_enable = true
[changelog] [changelog]
body = """ body = """