Skip to main content

Clog

Struct Clog 

Source
pub struct Clog {
Show 20 fields pub repo: Option<String>, pub link_style: LinkStyle, pub infile: Option<String>, pub subtitle: Option<String>, pub outfile: Option<String>, pub section_map: IndexMap<String, Vec<String>>, pub component_map: HashMap<String, Vec<String>>, pub git_dir: Option<PathBuf>, pub out_format: ChangelogFormat, pub grep: String, pub format: String, pub git_work_tree: Option<PathBuf>, pub regex: Regex, pub closes_regex: Regex, pub breaks_regex: Regex, pub breaking_regex: Regex, pub from: Option<String>, pub to: String, pub version: Option<String>, pub patch_ver: bool,
}
Expand description

The base struct used to set options and interact with the library.

Fields§

§repo: Option<String>

The repository used for the base of hyper-links

§link_style: LinkStyle

The link style to used for commit and issue hyper-links

§infile: Option<String>

The file to use as the old changelog data to be appended to anything new found.

§subtitle: Option<String>

The subtitle for the release

§outfile: Option<String>

The file to use as the changelog output file (Defaults to stdout)

§section_map: IndexMap<String, Vec<String>>

Maps out the sections and aliases used to trigger those sections. The keys are the section name, and the values are an array of aliases.

§component_map: HashMap<String, Vec<String>>

Maps out the components and aliases used to trigger those components. The keys are the component name, and the values are an array of aliases.

§git_dir: Option<PathBuf>

The git dir with all the meta-data (Typically the .git sub-directory of the project)

§out_format: ChangelogFormat

The format to output the changelog in (Defaults to Markdown)

§grep: String

The grep search pattern used to find commits we are interested in (Defaults to: “^ft|^feat|^fx|^fix|^perf|^unk|BREAKING'”)

§format: String

The format of the commit output from git log (Defaults to: “%H%n%s%n%b%n==END==”)

§git_work_tree: Option<PathBuf>

The working directory of the git project (typically the project directory, or parent of the .git directory)

§regex: Regex

The regex used to get components, aliases, and messages

§closes_regex: Regex

The regex used to get closes issue links

§breaks_regex: Regex

The regex used to get closes issue links

§breaking_regex: Regex§from: Option<String>

Where to start looking for commits using a hash (or short hash)

§to: String

Where to stop looking for commits using a hash (or short hash). (Defaults to HEAD)

§version: Option<String>

The version tag for the release (Defaults to the short hash of the latest commit)

§patch_ver: bool

Whether or not this is a patch version update or not. Patch versions use a lower markdown header (### instead of ## for major and minor releases)

Implementations§

Source§

impl Clog

Source

pub fn new() -> Result<Self>

Creates a default Clog struct using the current working directory and searches for the default .clog.toml configuration file.

§Example
let clog = Clog::new().unwrap();
Source

pub fn with_git_work_tree<P: AsRef<Path>>(dir: P) -> Result<Self>

Creates a Clog struct using a specific git working directory OR project directory. Searches for the default configuration TOML file .clog.toml

NOTE: If you specify a .git folder the parent will be used as the working tree, and vice versa.

§Example
let clog = Clog::with_git_work_tree("/myproject").unwrap();
Source

pub fn from_config<P: AsRef<Path>>(cfg: P) -> Result<Self>

Creates a Clog struct a custom named TOML configuration file. Sets the parent directory of the configuration file to the working tree and sibling .git directory as the git directory.

NOTE: If you specify a .git folder the parent will be used as the working tree, and vice versa.

§Example
let clog = Clog::from_config("/myproject/clog_conf.toml").unwrap();
Source

pub fn grep<S: Into<String>>(self, g: S) -> Self

Sets the grep search pattern for finding commits.

§Example
let clog = Clog::new().unwrap().grep("BREAKS");
Source

pub fn format<S: Into<String>>(self, f: S) -> Self

Sets the format for git log output

§Example
let clog = Clog::new().unwrap().format("%H%n%n==END==");
Source

pub fn repository<S: Into<String>>(self, r: S) -> Self

Sets the repository used for the base of hyper-links

NOTE: Leave off the trailing .git

NOTE: Anything set here will override anything in a configuration TOML file

§Example
let clog = Clog::new()
    .unwrap()
    .repository("https://github.com/thoughtram/clog");

Sets the link style to use for hyper-links

NOTE: Anything set here will override anything in a configuration TOML file

§Example
let clog = Clog::new().unwrap().link_style(LinkStyle::Stash);
Source

pub fn version<S: Into<String>>(self, v: S) -> Self

Sets the version for the release

NOTE: Anything set here will override anything in a configuration TOML file

§Example
let clog = Clog::new().unwrap().version("v0.2.1-beta3");
Source

pub fn subtitle<S: Into<String>>(self, s: S) -> Self

Sets the subtitle for the release

§Example
let clog = Clog::new().unwrap().subtitle("My Awesome Release Title");
Source

pub fn from<S: Into<String>>(self, f: S) -> Self

Sets how far back to begin searching commits using a short hash or full hash

NOTE: Anything set here will override anything in a configuration TOML file

§Example
let clog = Clog::new().unwrap().from("6d8183f");
Source

pub fn to<S: Into<String>>(self, t: S) -> Self

Sets what point to stop searching for commits using a short hash or full hash (Defaults to HEAD)

§Example
let clog = Clog::new().unwrap().to("123abc4d");
Source

pub fn changelog<S: Into<String> + Clone>(self, c: S) -> Self

Sets the changelog file to output or prepend to (Defaults to stdout if omitted)

NOTE: Anything set here will override anything in a configuration TOML file

§Example
let clog = Clog::new().unwrap().changelog("/myproject/my_changelog.md");
Source

pub fn outfile<S: Into<String>>(self, c: S) -> Self

Sets the changelog output file to output or prepend to (Defaults to stdout if omitted), this is useful inconjunction with Clog::infile() because it allows to read previous commits from one place and output to another.

NOTE: Anything set here will override anything in a configuration TOML file

NOTE: This should not be used in conjunction with Clog::changelog()

§Example
let clog = Clog::new().unwrap().outfile("/myproject/my_changelog.md");
Source

pub fn infile<S: Into<String>>(self, c: S) -> Self

Sets the changelog input file to read previous commits or changelog data from. This is useful inconjunction with Clog::infile() because it allows to read previous commits from one place and output to another.

NOTE: Anything set here will override anything in a configuration TOML file

NOTE: This should not be used in conjunction with Clog::changelog()

§Example
let clog = Clog::new()
    .unwrap()
    .infile("/myproject/my_old_changelog.md");
Source

pub fn git_dir<P: AsRef<Path>>(self, d: P) -> Self

Sets the git metadata directory (typically .git child of your project working tree)

§Example
let clog = Clog::new().unwrap().git_dir("/myproject/.git");
Source

pub fn git_work_tree<P: AsRef<Path>>(self, d: P) -> Self

Sets the git working tree directory (typically your project directory)

§Example
let clog = Clog::new().unwrap().git_work_tree("/myproject");
Source

pub fn patch_ver(self, p: bool) -> Self

Sets whether or not this is a patch release (defaults to false)

NOTE: Setting this to true will cause the release subtitle to use a smaller markdown heading

§Example
let clog = Clog::new().unwrap().patch_ver(true);
Source

pub fn output_format(self, f: ChangelogFormat) -> Self

The format of output for the changelog (Defaults to Markdown)

§Example
let clog = Clog::new().unwrap().output_format(ChangelogFormat::Json);
Source

pub fn get_commits(&self) -> Result<Commits>

Retrieves a Vec<Commit> of only commits we care about.

§Example
let clog = Clog::new().unwrap();
let commits = clog.get_commits();
Source

pub fn get_latest_tag(&self) -> Result<String>

Retrieves the latest tag from the git directory

§Example
let clog = Clog::new().unwrap();
let tag = clog.get_latest_tag().unwrap();
Source

pub fn get_latest_tag_ver(&self) -> Result<String>

Retrieves the latest tag version from the git directory

§Example
let clog = Clog::new().unwrap();
let tag_ver = clog.get_latest_tag_ver().unwrap();
Source

pub fn get_last_commit(&self) -> Result<String>

Retrieves the hash of the most recent commit from the git directory (i.e. HEAD)

§Example
let clog = Clog::new().unwrap();
let head_hash = clog.get_last_commit().unwrap();
Source

pub fn section_for(&self, alias: &str) -> Option<&str>

Retrieves the section title for a given alias

§Example
let clog = Clog::new().unwrap();
let section = clog.section_for("feat");
assert_eq!(Some("Features"), section);
Source

pub fn component_for(&self, alias: &str) -> Option<&String>

Retrieves the full component name for a given alias (if one is defined)

§Example
let clog = Clog::new().unwrap();
let component = clog.component_for("will_be_none");
assert_eq!(None, component);
Source

pub fn write_changelog(&self) -> Result<()>

Writes the changelog using whatever options have been specified thus far.

§Example
let clog = Clog::new().unwrap();
clog.write_changelog();
Source

pub fn write_changelog_to<P: AsRef<Path>>(&self, cl: P) -> Result<()>

Writes the changelog to a specified file, and prepends new commits if file exists, or creates the file if it doesn’t.

§Example
let clog = Clog::new().unwrap();

clog.write_changelog_to("/myproject/new_changelog.md")
    .unwrap();
Source

pub fn write_changelog_from<P: AsRef<Path>>(&self, cl: P) -> Result<()>

Writes the changelog from a specified input file, and appends new commits

§Example
let clog = Clog::new().unwrap();

clog.write_changelog_from("/myproject/new_old_changelog.md")
    .unwrap();
Source

pub fn write_changelog_with<W>(&self, writer: &mut W) -> Result<()>
where W: FormatWriter,

Writes a changelog with a specified FormatWriter format

§Examples
let clog = Clog::new().unwrap();

// Write changelog to stdout in Markdown format
let out = io::stdout();
let mut out_buf = io::BufWriter::new(out.lock());
let mut writer = MarkdownWriter::new(&mut out_buf);

clog.write_changelog_with(&mut writer).unwrap();

Trait Implementations§

Source§

impl Clone for Clog

Source§

fn clone(&self) -> Clog

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Clog

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Clog

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for Clog

§

impl RefUnwindSafe for Clog

§

impl Send for Clog

§

impl Sync for Clog

§

impl Unpin for Clog

§

impl UnsafeUnpin for Clog

§

impl UnwindSafe for Clog

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.