changelog: allow writing changelog in a non-git package
All checks were successful
CI / build (push) Successful in 3m0s
All checks were successful
CI / build (push) Successful in 3m0s
This commit is contained in:
@@ -19,26 +19,22 @@ pub fn generate_entry(
|
||||
Path::new(changelog_file).to_path_buf()
|
||||
};
|
||||
|
||||
// 1. Parse existing changelog to get current (old) version
|
||||
// Parse existing changelog to get current (old) version
|
||||
let (package, old_version, series) = parse_changelog_header(&changelog_path)?;
|
||||
println!("Found package: {}, version: {}", package, old_version);
|
||||
|
||||
// 2. Open git repo
|
||||
// Open git repo, and find commits since last version tag
|
||||
let repo_path = if let Some(path) = cwd {
|
||||
path.to_path_buf()
|
||||
} else {
|
||||
std::env::current_dir()?
|
||||
};
|
||||
let repo = Repository::open(&repo_path)?;
|
||||
|
||||
// 3. Find commits since the tag corresponding to the version
|
||||
|
||||
let commits = get_commits_since_version(&repo, &old_version)?;
|
||||
|
||||
if commits.is_empty() {
|
||||
println!("No new commits found since version {}", old_version);
|
||||
// return Ok(());
|
||||
}
|
||||
let commits = match Repository::open(&repo_path) {
|
||||
Ok(repo) => get_commits_since_version(&repo, &old_version)?,
|
||||
// If there is no git repo (e.g. package downloaded from archive),
|
||||
// we just generate an empty list of changes
|
||||
Err(_e) => Vec::new(),
|
||||
};
|
||||
|
||||
// Compute new version if needed, or use user-supplied one
|
||||
let new_version = if let Some(version) = user_version {
|
||||
|
||||
Reference in New Issue
Block a user