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: LinkStyleThe 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: ChangelogFormatThe format to output the changelog in (Defaults to Markdown)
grep: StringThe grep search pattern used to find commits we are interested in (Defaults to: “^ft|^feat|^fx|^fix|^perf|^unk|BREAKING'”)
format: StringThe 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: RegexThe regex used to get components, aliases, and messages
closes_regex: RegexThe regex used to get closes issue links
breaks_regex: RegexThe 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: StringWhere 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: boolWhether 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
impl Clog
Sourcepub fn new() -> Result<Self>
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();Sourcepub fn with_git_work_tree<P: AsRef<Path>>(dir: P) -> Result<Self>
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();Sourcepub fn from_config<P: AsRef<Path>>(cfg: P) -> Result<Self>
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();Sourcepub fn grep<S: Into<String>>(self, g: S) -> Self
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");Sourcepub fn format<S: Into<String>>(self, f: S) -> Self
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==");Sourcepub fn repository<S: Into<String>>(self, r: S) -> Self
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");Sourcepub fn link_style(self, l: LinkStyle) -> Self
pub fn link_style(self, l: LinkStyle) -> Self
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);Sourcepub fn version<S: Into<String>>(self, v: S) -> Self
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");Sourcepub fn subtitle<S: Into<String>>(self, s: S) -> Self
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");Sourcepub fn from<S: Into<String>>(self, f: S) -> Self
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");Sourcepub fn to<S: Into<String>>(self, t: S) -> Self
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");Sourcepub fn changelog<S: Into<String> + Clone>(self, c: S) -> Self
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");Sourcepub fn outfile<S: Into<String>>(self, c: S) -> Self
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");Sourcepub fn infile<S: Into<String>>(self, c: S) -> Self
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");Sourcepub fn git_dir<P: AsRef<Path>>(self, d: P) -> Self
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");Sourcepub fn git_work_tree<P: AsRef<Path>>(self, d: P) -> Self
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");Sourcepub fn patch_ver(self, p: bool) -> Self
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);Sourcepub fn output_format(self, f: ChangelogFormat) -> Self
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);Sourcepub fn get_commits(&self) -> Result<Commits>
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();Sourcepub fn get_latest_tag(&self) -> Result<String>
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();Sourcepub fn get_latest_tag_ver(&self) -> Result<String>
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();Sourcepub fn get_last_commit(&self) -> Result<String>
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();Sourcepub fn section_for(&self, alias: &str) -> Option<&str>
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);Sourcepub fn component_for(&self, alias: &str) -> Option<&String>
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);Sourcepub fn write_changelog(&self) -> Result<()>
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();Sourcepub fn write_changelog_to<P: AsRef<Path>>(&self, cl: P) -> Result<()>
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();Sourcepub fn write_changelog_from<P: AsRef<Path>>(&self, cl: P) -> Result<()>
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();Sourcepub fn write_changelog_with<W>(&self, writer: &mut W) -> Result<()>where
W: FormatWriter,
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();