File tree Expand file tree Collapse file tree 2 files changed +23
-10
lines changed Expand file tree Collapse file tree 2 files changed +23
-10
lines changed Original file line number Diff line number Diff line change @@ -24,7 +24,8 @@ use std::time::{
2424/// Changelog generator.
2525#[ derive( Debug ) ]
2626pub struct Changelog < ' a > {
27- releases : Vec < Release < ' a > > ,
27+ /// Releases that the changelog will contain.
28+ pub releases : Vec < Release < ' a > > ,
2829 body_template : Template ,
2930 footer_template : Option < Template > ,
3031 config : & ' a Config ,
Original file line number Diff line number Diff line change @@ -464,16 +464,28 @@ pub fn run(mut args: Opt) -> Result<()> {
464464
465465 // Print the result.
466466 if args. bump || args. bumped_version {
467- if let Some ( next_version) = changelog. bump_version ( ) ? {
468- if args. bumped_version {
469- if let Some ( path) = args. output {
470- let mut output = File :: create ( path) ?;
471- output. write_all ( next_version. as_bytes ( ) ) ?;
472- } else {
473- println ! ( "{next_version}" ) ;
474- }
475- return Ok ( ( ) ) ;
467+ let next_version = if let Some ( next_version) = changelog. bump_version ( ) ? {
468+ next_version
469+ } else if let Some ( last_version) = changelog
470+ . releases
471+ . iter ( )
472+ . next ( )
473+ . cloned ( )
474+ . and_then ( |v| v. version )
475+ {
476+ warn ! ( "There is nothing to bump." ) ;
477+ last_version
478+ } else {
479+ return Ok ( ( ) ) ;
480+ } ;
481+ if args. bumped_version {
482+ if let Some ( path) = args. output {
483+ let mut output = File :: create ( path) ?;
484+ output. write_all ( next_version. as_bytes ( ) ) ?;
485+ } else {
486+ println ! ( "{next_version}" ) ;
476487 }
488+ return Ok ( ( ) ) ;
477489 }
478490 }
479491 if args. context {
You can’t perform that action at this time.
0 commit comments