Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cargo-changelog currently does not 'bump' versions #240

Open
TheNeikos opened this issue Apr 30, 2023 · 2 comments
Open

cargo-changelog currently does not 'bump' versions #240

TheNeikos opened this issue Apr 30, 2023 · 2 comments

Comments

@TheNeikos
Copy link
Contributor

TheNeikos commented Apr 30, 2023

Currently, when running cargo changelog create-release minor it does not actually 'bump' versions or anything. It just reads out the current version through this call chain:

let version_string = find_version_string(workdir, &self.version)?;

Which then calls find_version_string:

pub fn find_version_string(workdir: &Path, version: &VersionSpec) -> Result<String, Error> {
use cargo_metadata::MetadataCommand;
if let VersionSpec::Custom { custom } = version {
Ok(custom.clone())
} else {
let metadata = MetadataCommand::new()
.manifest_path(workdir.join("./Cargo.toml"))
.exec()?;
let workspace_member_ids = &metadata.workspace_members;
let versions = metadata
.packages
.iter()
.filter(|pkg| workspace_member_ids.contains(&pkg.id))
.map(|pkg| &pkg.version)
.collect::<Vec<_>>();
if versions.is_empty() {
return Err(Error::NoVersionInCargoToml);
}
let first = versions[0];
let all_versions_same = versions.iter().all(|v| *v == first);
if !all_versions_same {
return Err(Error::WorkspaceVersionsNotEqual);
}
Ok(first.to_string())
}
}

This only reads out the version of the Cargo.toml in the project and ultimately returns the first it finds. No bumping or otherwise.

It is unclear to me how to solve this, as cargo-changelog is not a release manager. Hence running cargo changelog create-release major could not do much other than 'trust' the version it is given.

This impacts #239 as that requires the input to be 'truthful' to actually be able to work.

@matthiasbeyer
Copy link
Owner

🤦

Yeah,... alpha software! 👍

@TheNeikos
Copy link
Contributor Author

after discussion, we've come to the following conclusion:

  • cargo-changelog will not read any Cargo.toml anymore
  • The user specifies what version they plan on releasing, the tool then checks the last released version and based on that bumps the version that has been given (major/minor/patch) and puts all the files in there
  • It defaults to 0.0.0 and goes on from there (so a minor bump on an empty project will release 0.1.0)
  • if custom versions are required, then they can still be given with the custom switch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants