Skip to content

Commit

Permalink
✨ lib
Browse files Browse the repository at this point in the history
  • Loading branch information
fabienjuif authored Dec 31, 2018
1 parent a548d95 commit 584d853
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/changelog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,10 @@ impl Changelog {
})
.collect::<Vec<_>>();

if versions.is_empty() {
versions.push(Version::new("HEAD"));
}

versions.sort();

versions.push(Version::new("HEAD"));

let mut revwalk = repository.revwalk().unwrap();
let mut previous_version_name = from.unwrap_or("");
let versions_len = versions.len();
Expand All @@ -80,6 +78,17 @@ impl Changelog {
Changelog { versions }
}

#[allow(dead_code)]
pub fn keep_last_version_only(&self) -> Changelog {
let mut versions = vec![];

if let Some(last_version) = self.versions.first() {
versions.push(last_version.clone());
}

Changelog { versions }
}

pub fn to_markdown(&self, release: Option<&str>, print_authors: bool) -> String {
let mut versions = self.versions.clone();

Expand Down
16 changes: 16 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#[macro_use]
extern crate serde_derive;
#[macro_use]
extern crate serde_json;
#[macro_use]
extern crate lazy_static;

mod changelog;
mod commit;
mod group;
mod version;

pub use crate::changelog::Changelog;
pub use crate::commit::Commit;
pub use crate::group::Group;
pub use crate::version::Version;

0 comments on commit 584d853

Please # to comment.