Skip to content

Commit

Permalink
feat: also support .convco instead of .versionrc
Browse files Browse the repository at this point in the history
  • Loading branch information
hdevalke committed Jan 9, 2024
1 parent fb1b018 commit 08802fc
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
File renamed without changes.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ The configuration file is loaded in the following order
1. Load the internal defaults
- specified in [src/conventional/config.rs](src/conventional/config.rs),
- see these defaults at [`convco config --default`](https://convco.github.io/configuration#default-configuration).
2. Then override with values from the command line, `convco -c|--config path/to/.versionrc`
3. Or, if not specified via `-c|--config`, load `${PWD}/.versionrc` if it exists.
2. Then override with values from the command line, `convco -c|--config path/to/.convco`
3. Or, if not specified via `-c|--config`, load `${PWD}/.convco` if it exists (or `${PWD}/.versionrc` for compatibility with conventional-changelog).

To get the final derived configuration run `convco config`.

Expand Down
4 changes: 2 additions & 2 deletions src/conventional/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,9 +318,9 @@ fn host_info_from_url(url: Url) -> Result<HostOwnerRepo, Error> {
}

pub(crate) fn make_cl_config(git: Option<GitHelper>, path: impl AsRef<Path>) -> Config {
let mut config: Config = (std::fs::read(path))
let mut config: Config = std::fs::read(path)
.ok()
.and_then(|versionrc| (serde_yaml::from_reader(versionrc.as_slice())).ok())
.and_then(|vec| (serde_yaml::from_reader(vec.as_slice())).ok())
.unwrap_or_default();
if let Config {
host: None,
Expand Down
11 changes: 9 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ mod git;
mod semver;
mod strip;

use std::process::exit;
use std::{path::PathBuf, process::exit};

use clap::Parser;
use conventional::config::make_cl_config;
Expand All @@ -26,7 +26,14 @@ fn main() -> anyhow::Result<()> {
eprintln!("{e}")
}
).ok();
let config = make_cl_config(git, opt.config.unwrap_or_else(|| ".versionrc".into()));
let config = make_cl_config(
git,
opt.config
.unwrap_or_else(|| match PathBuf::from(".convco") {
p if p.is_file() => p,
_ => ".versionrc".into(),
}),
);
let res = match opt.cmd {
cli::Command::Config(cmd) => cmd.exec(config),
cli::Command::Check(cmd) => cmd.exec(config),
Expand Down

0 comments on commit 08802fc

Please sign in to comment.