Byron / cargo-smart-release

Release complex cargo-workspaces automatically with changelog generation, used by `gitoxide`
Apache License 2.0
78 stars 7 forks source link

run on detached head hits unreachable code #14

Closed MingweiSamuel closed 9 months ago

MingweiSamuel commented 9 months ago
Mingw@MarbleTea MINGW64 /d/Projects/hydroflow ((c50ca121b6d...))
$ RUST_BACKTRACE=full cargo run --manifest-path ../cargo-smart-release/Cargo.toml --bin cargo-smart-release -- smart-release --no-changelog-preview --allow-fully-generated-changelogs --bump patch --bump-dependencies auto --no-publish hydro_deploy/hydro_cli
...
warning: `cargo-smart-release` (lib) generated 29 warnings (run `cargo fix --lib -p cargo-smart-release` to apply 29 suggestions)
    Finished dev [unoptimized + debuginfo] target(s) in 0.24s
     Running `D:\Projects\cargo-smart-release\target\debug\cargo-smart-release.exe smart-release --no-changelog-preview --allow-fully-generated-changelogs --bump patch --bump-dependencies auto --no-publish hydro_deploy/hydro_cli`
[WARN ] Consider running with --update-crates-index to assure bumping on demand uses the latest information
thread 'main' panicked at src\git\history.rs:40:40:
internal error: entered unreachable code: handled above
stack backtrace:
   0:     0x7ff68f6711ad - std::sys_common::backtrace::_print::impl$0::fmt
                               at /rustc/cd674d61790607dfb6faa9d754bd3adfa13aea7c/library\std\src\sys_common\backtrace.rs:44
   1:     0x7ff68f697c1d - core::fmt::rt::Argument::fmt
                               at /rustc/cd674d61790607dfb6faa9d754bd3adfa13aea7c/library\core\src\fmt\rt.rs:142
   2:     0x7ff68f697c1d - core::fmt::write
                               at /rustc/cd674d61790607dfb6faa9d754bd3adfa13aea7c/library\core\src\fmt\mod.rs:1117
   3:     0x7ff68f66af61 - std::io::Write::write_fmt<std::sys::windows::stdio::Stderr>
                               at /rustc/cd674d61790607dfb6faa9d754bd3adfa13aea7c/library\std\src\io\mod.rs:1762
   4:     0x7ff68f670f9a - std::sys_common::backtrace::_print
                               at /rustc/cd674d61790607dfb6faa9d754bd3adfa13aea7c/library\std\src\sys_common\backtrace.rs:47
   5:     0x7ff68f670f9a - std::sys_common::backtrace::print
                               at /rustc/cd674d61790607dfb6faa9d754bd3adfa13aea7c/library\std\src\sys_common\backtrace.rs:34
   6:     0x7ff68f674419 - std::panicking::default_hook::closure$1
                               at /rustc/cd674d61790607dfb6faa9d754bd3adfa13aea7c/library\std\src\panicking.rs:272
   7:     0x7ff68f6740db - std::panicking::default_hook
                               at /rustc/cd674d61790607dfb6faa9d754bd3adfa13aea7c/library\std\src\panicking.rs:292
   8:     0x7ff68f674904 - std::panicking::rust_panic_with_hook
                               at /rustc/cd674d61790607dfb6faa9d754bd3adfa13aea7c/library\std\src\panicking.rs:731
   9:     0x7ff68f67479b - std::panicking::begin_panic_handler::closure$0
                               at /rustc/cd674d61790607dfb6faa9d754bd3adfa13aea7c/library\std\src\panicking.rs:601
  10:     0x7ff68f671f49 - std::sys_common::backtrace::__rust_end_short_backtrace<std::panicking::begin_panic_handler::closure_env$0,never$>
                               at /rustc/cd674d61790607dfb6faa9d754bd3adfa13aea7c/library\std\src\sys_common\backtrace.rs:170
  11:     0x7ff68f6744e4 - std::panicking::begin_panic_handler
                               at /rustc/cd674d61790607dfb6faa9d754bd3adfa13aea7c/library\std\src\panicking.rs:597
  12:     0x7ff68f73a557 - core::panicking::panic_fmt
                               at /rustc/cd674d61790607dfb6faa9d754bd3adfa13aea7c/library\core\src\panicking.rs:72
  13:     0x7ff68e94e582 - cargo_smart_release::git::history::collect
                               at D:\Projects\cargo-smart-release\src\git\history.rs:40
  14:     0x7ff68e89132b - cargo_smart_release::context::impl$0::new::closure$0
                               at D:\Projects\cargo-smart-release\src\context.rs:33
  15:     0x7ff68e8e8967 - core::bool::impl$0::then<enum2$<core::result::Result<enum2$<core::option::Option<cargo_smart_release::commit::History> >,anyhow::Error> >,cargo_smart_release::context::impl$0::new::closure_env$0>                               at /rustc/cd674d61790607dfb6faa9d754bd3adfa13aea7c\library\core\src\bool.rs:60
  16:     0x7ff68e8a407d - cargo_smart_release::context::Context::new
                               at D:\Projects\cargo-smart-release\src\context.rs:30
  17:     0x7ff68e87442f - cargo_smart_release::command::release_impl::Context::new
                               at D:\Projects\cargo-smart-release\src\command\release\mod.rs:37
  18:     0x7ff68e8748d4 - cargo_smart_release::command::release_impl::release
                               at D:\Projects\cargo-smart-release\src\command\release\mod.rs:72
  19:     0x7ff68e824fcf - cargo_smart_release::main
                               at D:\Projects\cargo-smart-release\src\cli\main.rs:71
  20:     0x7ff68e828d3b - core::ops::function::FnOnce::call_once<enum2$<core::result::Result<tuple$<>,anyhow::Error> > (*)(),tuple$<> >
                               at /rustc/cd674d61790607dfb6faa9d754bd3adfa13aea7c\library\core\src\ops\function.rs:250
  21:     0x7ff68e82a16e - std::sys_common::backtrace::__rust_begin_short_backtrace<enum2$<core::result::Result<tuple$<>,anyhow::Error> > (*)(),enum2$<core::result::Result<tuple$<>,anyhow::Error> > >
                               at /rustc/cd674d61790607dfb6faa9d754bd3adfa13aea7c\library\std\src\sys_common\backtrace.rs:154
  22:     0x7ff68e8238e1 - std::rt::lang_start::closure$0<enum2$<core::result::Result<tuple$<>,anyhow::Error> > >
                               at /rustc/cd674d61790607dfb6faa9d754bd3adfa13aea7c\library\std\src\rt.rs:167
  23:     0x7ff68f662e18 - std::rt::lang_start_internal::closure$2
                               at /rustc/cd674d61790607dfb6faa9d754bd3adfa13aea7c/library\std\src\rt.rs:148
  24:     0x7ff68f662e18 - std::panicking::try::do_call
                               at /rustc/cd674d61790607dfb6faa9d754bd3adfa13aea7c/library\std\src\panicking.rs:504
  25:     0x7ff68f662e18 - std::panicking::try
                               at /rustc/cd674d61790607dfb6faa9d754bd3adfa13aea7c/library\std\src\panicking.rs:468
  26:     0x7ff68f662e18 - std::panic::catch_unwind
                               at /rustc/cd674d61790607dfb6faa9d754bd3adfa13aea7c/library\std\src\panic.rs:142
  27:     0x7ff68f662e18 - std::rt::lang_start_internal
                               at /rustc/cd674d61790607dfb6faa9d754bd3adfa13aea7c/library\std\src\rt.rs:148
  28:     0x7ff68e8238ba - std::rt::lang_start<enum2$<core::result::Result<tuple$<>,anyhow::Error> > >
                               at /rustc/cd674d61790607dfb6faa9d754bd3adfa13aea7c\library\std\src\rt.rs:166
  29:     0x7ff68e825e29 - main
  30:     0x7ff68f738090 - invoke_main
                               at D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:78
  31:     0x7ff68f738090 - __scrt_common_main_seh
                               at D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288
  32:     0x7ffa54b77344 - BaseThreadInitThunk
  33:     0x7ffa559426b1 - RtlUserThreadStart
error: process didn't exit successfully: `D:\Projects\cargo-smart-release\target\debug\cargo-smart-release.exe smart-release --no-changelog-preview --allow-fully-generated-changelogs --bump patch --bump-dependencies auto --no-publish hydro_deploy/hydro_cli` (exit code: 101)

https://github.com/Byron/cargo-smart-release/blob/7892013f41557d8df5390a6f2855bb5e79632fe6/src/git/history.rs#L35-L43

Byron commented 9 months ago

Thanks for reporting! It's true, the assertion is wrong as 'handled above' will in fact fail for an unborn HEAD, but not for a detached one.

I have fixed-up the logic and you are welcome to try it out. Since it now doesn't collect history anymore, it won't generate changelogs at all which might not be what you want.

MingweiSamuel commented 9 months ago

Seems to work now. I don't actually have a use case for releasing on detached head besides for testing