Struct clog::Clog [] [src]

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

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

Fields

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

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

The repository used for the base of hyper-links

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

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

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)

The subtitle for the release

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

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

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

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

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.

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

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

The regex used to get components, aliases, and messages

The regex used to get closes issue links

The regex used to get closes issue links

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

Methods

impl Clog
[src]

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_or_else(|e| {
    // Prints the error to stderr and exits
    e.exit();
});

Creates a Clog struct using a specific git working directory and project directory as well as a custom named TOML configuration file.

Example

let clog = Clog::with_all("/myproject/.git",
                          "/myproject",
                          "/myproject/clog_conf.toml").unwrap_or_else(|e| {
    e.exit();
});

Creates a Clog struct using a specific git working directory OR project directory as well as a custom named TOML configuration file.

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

Example

let clog = Clog::with_dir_and_file("/myproject",
                          "/myproject/clog_conf.toml").unwrap_or_else(|e| {
    e.exit();
});

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_dir("/myproject").unwrap_or_else(|e| {
    e.exit();
});

Creates a Clog struct using a specific git working directory AND a 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_dirs("/myproject", "/myproject/.git").unwrap_or_else(|e| {
    e.exit();
});

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_file("/myproject/clog_conf.toml").unwrap_or_else(|e| {
    e.exit();
});

Sets the grep search pattern for finding commits.

Example

let mut clog = Clog::new().unwrap_or_else(|e| {
    e.exit();
});

clog.grep("BREAKS");

Sets the format for git log output

Example

let mut clog = Clog::new().unwrap_or_else(|e| {
    e.exit();
});

clog.format("%H%n%n==END==");

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 mut clog = Clog::new().unwrap_or_else(|e| {
    e.exit();
});

clog.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 mut clog = Clog::new().unwrap_or_else(|e| {
    e.exit();
});

clog.link_style(LinkStyle::Stash);

Sets the version for the release

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

Example

let mut clog = Clog::new().unwrap_or_else(|e| {
    e.exit();
});

clog.version("v0.2.1-beta3");

Sets the subtitle for the release

Example

let mut clog = Clog::new().unwrap_or_else(|e| {
    e.exit();
});

clog.subtitle("My Awesome Release Title");

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 mut clog = Clog::new().unwrap_or_else(|e| {
    e.exit();
});

clog.from("6d8183f");

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

Example

let mut clog = Clog::new().unwrap_or_else(|e| {
    e.exit();
});

clog.to("123abc4d");

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 mut clog = Clog::new().unwrap_or_else(|e| {
    e.exit();
});

clog.changelog("/myproject/my_changelog.md");

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 mut clog = Clog::new().unwrap_or_else(|e| {
    e.exit();
});

clog.outfile("/myproject/my_changelog.md");

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 mut clog = Clog::new().unwrap_or_else(|e| {
    e.exit();
});

clog.infile("/myproject/my_old_changelog.md");

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

Example

let mut clog = Clog::new().unwrap_or_else(|e| {
    e.exit();
});

clog.git_dir("/myproject/.git");

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

Example

let mut clog = Clog::new().unwrap_or_else(|e| {
    e.exit();
});

clog.git_work_tree("/myproject");

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 mut clog = Clog::new().unwrap_or_else(|e| {
    e.exit();
});

clog.patch_ver(true);

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

Example

let mut clog = Clog::new().unwrap_or_else(|e| {
    e.exit();
});

clog.output_format(ChangelogFormat::Json);

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

Example

let mut clog = Clog::new().unwrap_or_else(|e| {
    e.exit();
});

let commits = clog.get_commits();

Retrieves the latest tag from the git directory

Example

let mut clog = Clog::new().unwrap_or_else(|e| {
    e.exit();
});

let tag = clog.get_latest_tag();

Retrieves the latest tag version from the git directory

Example

let mut clog = Clog::new().unwrap_or_else(|e| {
    e.exit();
});

let tag_ver = clog.get_latest_tag_ver();

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

Example

let mut clog = Clog::new().unwrap_or_else(|e| {
    e.exit();
});

let head_hash = clog.get_last_commit();

Retrieves the section title for a given alias

Example

let mut clog = Clog::new().unwrap_or_else(|e| {
    e.exit();
});

let section = clog.section_for("feat");
assert_eq!("Features", section);

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

Example

let mut clog = Clog::new().unwrap_or_else(|e| {
    e.exit();
});

clog.write_changelog();

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

Example

let mut clog = Clog::new().unwrap_or_else(|e| e.exit());

clog.write_changelog_to("/myproject/new_changelog.md").unwrap_or_else(|e| {
    // Prints the error and exits appropriately
    e.exit();
});

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

Example

let mut clog = Clog::new().unwrap_or_else(|e| e.exit());

clog.write_changelog_from("/myproject/new_old_changelog.md").unwrap_or_else(|e| {
    // Prints the error and exits appropriately
    e.exit();
});

Writes a changelog with a specified FormatWriter format

Examples

let clog = Clog::new().unwrap_or_else(|e| {
    e.exit();
});

// 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_or_else(|e| {
    // Prints the error and exits appropriately
    e.exit();
});

Trait Implementations

impl Debug for Clog
[src]

Formats the value using the given formatter.