chlog: add -f/--file to target a specific changelog
The changelog path was hardcoded to debian/changelog in the series detection, the entry generation and the editor invocation. Packages keeping the changelog elsewhere (e.g. a staging copy) could not use chlog on it. Add -f/--file defaulting to debian/changelog, threaded through all three uses. The library side was already parameterized on the file, so no changelog.rs behavior changes beyond a test pinning the non-default path.
This commit is contained in:
1 parent
babddad505
commit
6bb31ea533
3 files changed
+57
-3
No files matched your search
@@ -1363,6 +1363,52 @@ mod tests {
|
||||
assert!(!content.contains("* Initial commit"));
|
||||
}
|
||||
|
||||
/// A non-default changelog file (pkh chlog -f): the entry is
|
||||
/// prepended to that file, and its version is parsed from it
|
||||
#[tokio::test]
|
||||
async fn test_generate_entry_custom_changelog_file() {
|
||||
let temp_dir = TempDir::new().unwrap();
|
||||
let repo_dir = temp_dir.path();
|
||||
setup_repo(repo_dir);
|
||||
|
||||
let changelog_path = repo_dir.join("debian/changelog.local");
|
||||
std::fs::create_dir_all(repo_dir.join("debian")).unwrap();
|
||||
std::fs::write(
|
||||
&changelog_path,
|
||||
"mypackage (0.1.0-1) unstable; urgency=medium\n\n * Initial release\n\n -- Maintainer <m@e.com> Wed, 01 Jan 2020 00:00:00 +0000\n",
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let _identity = IDENTITY_LOCK.lock().await;
|
||||
unsafe {
|
||||
std::env::set_var("DEBFULLNAME", "Maintainer Maintainer");
|
||||
std::env::set_var("DEBEMAIL", "maintainer@maintainer.com");
|
||||
}
|
||||
let entry = generate_entry(
|
||||
"debian/changelog.local",
|
||||
Some(repo_dir),
|
||||
None,
|
||||
None,
|
||||
EntryKind::Normal,
|
||||
0,
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
unsafe {
|
||||
std::env::remove_var("DEBFULLNAME");
|
||||
std::env::remove_var("DEBEMAIL");
|
||||
}
|
||||
|
||||
assert_eq!(entry.previous_version, "0.1.0-1");
|
||||
assert_eq!(entry.new_version, "0.1.0-2");
|
||||
let content = std::fs::read_to_string(&changelog_path).unwrap();
|
||||
assert!(content.starts_with("mypackage (0.1.0-2) unstable; urgency=medium"));
|
||||
assert!(content.contains("mypackage (0.1.0-1) unstable; urgency=medium"));
|
||||
|
||||
// The default file is not created next to it
|
||||
assert!(!repo_dir.join("debian/changelog").exists());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_compute_new_version() {
|
||||
// Debian upload
|
||||
|
||||
Reference in new issue
Block a user