Add logging
This commit is contained in:
parent
1520e2353a
commit
b7f3fa081c
3 changed files with 149 additions and 12 deletions
142
Cargo.lock
generated
142
Cargo.lock
generated
|
|
@ -1,6 +1,6 @@
|
|||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
version = 4
|
||||
|
||||
[[package]]
|
||||
name = "addr2line"
|
||||
|
|
@ -17,6 +17,15 @@ version = "1.0.2"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
|
||||
|
||||
[[package]]
|
||||
name = "aho-corasick"
|
||||
version = "1.1.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anstream"
|
||||
version = "0.6.11"
|
||||
|
|
@ -317,6 +326,29 @@ dependencies = [
|
|||
"shared_child",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "env_filter"
|
||||
version = "0.1.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1bf3c259d255ca70051b30e2e95b5446cdb8949ac4cd22c0d7fd634d89f568e2"
|
||||
dependencies = [
|
||||
"log",
|
||||
"regex",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "env_logger"
|
||||
version = "0.11.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "13c863f0904021b108aa8b2f55046443e6b1ebde8fd4a15c399893aae4fa069f"
|
||||
dependencies = [
|
||||
"anstream",
|
||||
"anstyle",
|
||||
"env_filter",
|
||||
"jiff",
|
||||
"log",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "equivalent"
|
||||
version = "1.0.1"
|
||||
|
|
@ -368,6 +400,8 @@ dependencies = [
|
|||
"config",
|
||||
"directories",
|
||||
"duct",
|
||||
"env_logger",
|
||||
"log",
|
||||
"miette",
|
||||
"serde",
|
||||
"temp-dir",
|
||||
|
|
@ -413,6 +447,30 @@ version = "1.0.10"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c"
|
||||
|
||||
[[package]]
|
||||
name = "jiff"
|
||||
version = "0.2.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "49cce2b81f2098e7e3efc35bc2e0a6b7abec9d34128283d7a26fa8f32a6dbb35"
|
||||
dependencies = [
|
||||
"jiff-static",
|
||||
"log",
|
||||
"portable-atomic",
|
||||
"portable-atomic-util",
|
||||
"serde_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "jiff-static"
|
||||
version = "0.2.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "980af8b43c3ad5d8d349ace167ec8170839f753a42d233ba19e08afe1850fa69"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "json5"
|
||||
version = "0.4.1"
|
||||
|
|
@ -459,6 +517,12 @@ version = "0.4.13"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c"
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.29"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897"
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.7.1"
|
||||
|
|
@ -619,19 +683,34 @@ dependencies = [
|
|||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.78"
|
||||
name = "portable-atomic"
|
||||
version = "1.11.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae"
|
||||
checksum = "f84267b20a16ea918e43c6a88433c2d54fa145c92a811b5b047ccbe153674483"
|
||||
|
||||
[[package]]
|
||||
name = "portable-atomic-util"
|
||||
version = "0.2.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d8a2f0d8d040d7848a709caf78912debcc3f33ee4b3cac47d73d1e1069e83507"
|
||||
dependencies = [
|
||||
"portable-atomic",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.103"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5ee95bc4ef87b8d5ba32e8b7714ccc834865276eab0aed5c9958d00ec45f49e8"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.35"
|
||||
version = "1.0.42"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef"
|
||||
checksum = "a338cc41d27e6cc6dce6cefc13a0729dfbb81c262b1f519331575dd80ef3067f"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
|
@ -656,6 +735,35 @@ dependencies = [
|
|||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex"
|
||||
version = "1.12.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "843bc0191f75f3e22651ae5f1e72939ab2f72a4bc30fa80a066bd66edefc24d4"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
"regex-automata",
|
||||
"regex-syntax",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex-automata"
|
||||
version = "0.4.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5276caf25ac86c8d810222b3dbb938e512c55c6831a10f3e6ed1c93b84041f1c"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
"regex-syntax",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex-syntax"
|
||||
version = "0.8.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7a2d987857b319362043e95f5353c0535c1f58eec5336fdfcf626430af7def58"
|
||||
|
||||
[[package]]
|
||||
name = "ron"
|
||||
version = "0.8.1"
|
||||
|
|
@ -705,18 +813,28 @@ checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c"
|
|||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.196"
|
||||
version = "1.0.228"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "870026e60fa08c69f064aa766c10f10b1d62db9ccd4d0abb206472bee0ce3b32"
|
||||
checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e"
|
||||
dependencies = [
|
||||
"serde_core",
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_core"
|
||||
version = "1.0.228"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad"
|
||||
dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.196"
|
||||
version = "1.0.228"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "33c85360c95e7d137454dc81d9a4ed2b8efd8fbe19cee57357b32b9771fccb67"
|
||||
checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
|
@ -799,9 +917,9 @@ checksum = "b7401a30af6cb5818bb64852270bb722533397edcfc7344954a38f420819ece2"
|
|||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.48"
|
||||
version = "2.0.111"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f"
|
||||
checksum = "390cc9a294ab71bdb1aa2e99d13be9c753cd2d7bd6560c77118597410c4d2e87"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ clap = { version = "4.4.18", features = ["derive"] }
|
|||
config = "0.14.0"
|
||||
directories = "5.0.1"
|
||||
duct = "0.13.7"
|
||||
env_logger = "0.11.8"
|
||||
log = "0.4.29"
|
||||
miette = { version = "7.0.0", features = ["fancy"] }
|
||||
serde = { version = "1.0.196", features = ["derive"] }
|
||||
temp-dir = "0.1.12"
|
||||
|
|
|
|||
17
src/main.rs
17
src/main.rs
|
|
@ -70,6 +70,8 @@ impl Delete {
|
|||
.as_ref()
|
||||
.try_m_unwrap_or_else(|| Ok(¤t_branch))?;
|
||||
|
||||
log::debug!("Using branch {branch}");
|
||||
|
||||
if !self.local_only
|
||||
&& let Ok(remote) = git_cd(&[
|
||||
"rev-parse",
|
||||
|
|
@ -206,6 +208,8 @@ impl Send {
|
|||
.as_ref()
|
||||
.try_m_unwrap_or_else(|| Ok(¤t_branch))?;
|
||||
|
||||
log::debug!("Sending branch {branch}");
|
||||
|
||||
let branch_dir = patch_dir.join(&branch);
|
||||
let version = match self.version {
|
||||
Some(v) => v,
|
||||
|
|
@ -215,6 +219,8 @@ impl Send {
|
|||
},
|
||||
};
|
||||
|
||||
log::debug!("Using version {version}");
|
||||
|
||||
let version_dir = &branch_dir.join(&version.to_string());
|
||||
|
||||
let mut cmd = std::process::Command::new("git");
|
||||
|
|
@ -296,6 +302,8 @@ impl FormatPatch {
|
|||
.branch
|
||||
.try_m_unwrap_or_else(|| Ok(git_cd(&["branch", "--show-current"])?))?;
|
||||
|
||||
log::debug!("Using branch {branch}");
|
||||
|
||||
let component = config.component.try_m_unwrap_or_else(|| {
|
||||
let url = git_cd(&["remote", "get-url", "origin"])?;
|
||||
Ok(url
|
||||
|
|
@ -411,6 +419,8 @@ impl FormatPatch {
|
|||
.or(config.interdiff_base)
|
||||
.unwrap_or_else(|| String::from("origin/master"));
|
||||
|
||||
log::debug!("Applying interdiff with {base}");
|
||||
|
||||
struct TempBranch<'a> {
|
||||
name: &'a str,
|
||||
git: &'a dyn Fn(&[&str]) -> Result<String>,
|
||||
|
|
@ -634,6 +644,8 @@ fn latest_version(branch_dir: &Path) -> Result<Option<u64>> {
|
|||
}
|
||||
|
||||
fn git_bare(args: Vec<&str>) -> Result<String> {
|
||||
log::trace!("Running git {args:?}",);
|
||||
|
||||
let out = duct::cmd("git", args)
|
||||
.stderr_to_stdout()
|
||||
.unchecked()
|
||||
|
|
@ -653,6 +665,8 @@ fn git_bare(args: Vec<&str>) -> Result<String> {
|
|||
}
|
||||
|
||||
fn main() -> Result<()> {
|
||||
env_logger::init();
|
||||
|
||||
let args = Arg::parse();
|
||||
|
||||
let project_dir = ProjectDirs::from("net", "traxys", "git-series-manager")
|
||||
|
|
@ -664,6 +678,7 @@ fn main() -> Result<()> {
|
|||
"--show-toplevel",
|
||||
])?))
|
||||
})?;
|
||||
log::debug!("Repo root is: {repo_root:?}");
|
||||
let patch_dir = repo_root.join(".patches");
|
||||
|
||||
let git_cd = |args: &[&str]| {
|
||||
|
|
@ -690,6 +705,8 @@ fn main() -> Result<()> {
|
|||
.into_diagnostic()
|
||||
.wrap_err("Failed to deserialize the configuration")?;
|
||||
|
||||
log::debug!("Configuration: {config:#?}");
|
||||
|
||||
std::fs::create_dir_all(&patch_dir)
|
||||
.into_diagnostic()
|
||||
.wrap_err("could not create patch directory")?;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue