mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-28 17:19:11 +01:00
970 lines
25 KiB
Rust
970 lines
25 KiB
Rust
use std::sync::OnceLock;
|
|
|
|
use anyhow::Context;
|
|
use pico_args::Arguments;
|
|
use regex_lite::Regex;
|
|
use xshell::Shell;
|
|
|
|
pub(crate) fn check_changelog(shell: Shell, mut args: Arguments) -> anyhow::Result<()> {
|
|
const CHANGELOG_PATH_RELATIVE: &str = "./CHANGELOG.md";
|
|
let allow_released_changes = args.contains("--allow-released-changes");
|
|
|
|
let from_branch = args
|
|
.free_from_str()
|
|
.ok()
|
|
.unwrap_or_else(|| "trunk".to_owned());
|
|
let to_commit: Option<String> = args.free_from_str().ok();
|
|
|
|
let from_commit = shell
|
|
.cmd("git")
|
|
.args([
|
|
"merge-base",
|
|
&from_branch,
|
|
to_commit.as_deref().unwrap_or("HEAD"),
|
|
])
|
|
.read()
|
|
.context("could not find the common ancestor for the changelog comparison")?;
|
|
|
|
let diff = shell
|
|
.cmd("git")
|
|
.args(["diff", &from_commit])
|
|
// NOTE: If `to_commit` is not specified, we compare against the working tree, instead of
|
|
// between commits.
|
|
.args(to_commit.as_ref())
|
|
.args(["--", CHANGELOG_PATH_RELATIVE])
|
|
.read()
|
|
.unwrap();
|
|
|
|
let old_changelog_contents = shell
|
|
.cmd("git")
|
|
.arg("show")
|
|
.arg(format!("{from_commit}:{CHANGELOG_PATH_RELATIVE}"))
|
|
.arg("--")
|
|
.read()
|
|
.unwrap();
|
|
|
|
// NOTE: If `to_commit` is not specified, we fetch from the file system, instead of `git show`.
|
|
let new_changelog_contents = if let Some(to_commit) = to_commit.as_ref() {
|
|
shell
|
|
.cmd("git")
|
|
.arg("show")
|
|
.arg(format!("{to_commit}:{CHANGELOG_PATH_RELATIVE}"))
|
|
.arg("--")
|
|
.read()
|
|
.unwrap()
|
|
} else {
|
|
shell.read_file(CHANGELOG_PATH_RELATIVE).unwrap()
|
|
};
|
|
|
|
let mut failed = false;
|
|
|
|
let odd_characters = find_odd_characters(&new_changelog_contents);
|
|
if !odd_characters.is_empty() {
|
|
failed = true;
|
|
|
|
#[expect(clippy::uninlined_format_args)]
|
|
{
|
|
eprintln!("Found odd character(s) in `{}`:\n", CHANGELOG_PATH_RELATIVE,);
|
|
}
|
|
|
|
for odd_character in &odd_characters {
|
|
eprintln!("{odd_character}");
|
|
}
|
|
|
|
eprintln!();
|
|
eprintln!(
|
|
"hint: these are usually invisible characters such as non-breaking or zero-width \
|
|
spaces; replace them with regular spaces (or delete them) and try again."
|
|
);
|
|
}
|
|
|
|
let hunks_in_a_released_section =
|
|
hunks_in_a_released_section(&old_changelog_contents, &new_changelog_contents, &diff);
|
|
log::info!(
|
|
"# of hunks in a released section of `{CHANGELOG_PATH_RELATIVE}`: {}",
|
|
hunks_in_a_released_section.len()
|
|
);
|
|
if !hunks_in_a_released_section.is_empty() {
|
|
failed = true;
|
|
|
|
#[expect(clippy::uninlined_format_args)]
|
|
{
|
|
eprintln!(
|
|
"Found hunk(s) in released sections of `{}`, which we don't want:\n",
|
|
CHANGELOG_PATH_RELATIVE,
|
|
);
|
|
}
|
|
|
|
for hunk in &hunks_in_a_released_section {
|
|
eprintln!("{hunk}");
|
|
}
|
|
|
|
eprintln!();
|
|
eprintln!(
|
|
"hint: a release likely happened after this change was first added to `## Unreleased`. \
|
|
Move the affected entries back up under `## Unreleased` in `{CHANGELOG_PATH_RELATIVE}` \
|
|
and try again."
|
|
);
|
|
}
|
|
|
|
if failed {
|
|
#[expect(clippy::uninlined_format_args)]
|
|
let msg = format!(
|
|
"one or more checks against `{}` failed; see above for details",
|
|
CHANGELOG_PATH_RELATIVE,
|
|
);
|
|
if allow_released_changes {
|
|
log::warn!("{msg}");
|
|
Ok(())
|
|
} else {
|
|
Err(anyhow::Error::msg(msg))
|
|
}
|
|
} else {
|
|
Ok(())
|
|
}
|
|
}
|
|
|
|
/// Given some `old_changelog_contents` and `new_changelog_contents` (in Markdown) containing the
|
|
/// full start and end states of the provided `diff` (in [unified diff format]), return all hunks
|
|
/// that modify content that is (1) below a `## Unreleased` section _and_ (2) above all other
|
|
/// second-level (i.e., `## …`) headings.
|
|
///
|
|
/// [unified diff format]: https://www.gnu.org/software/diffutils/manual/html_node/Detailed-Unified.html
|
|
///
|
|
/// This function makes a few assumptions that are necessary to uphold for correctness, in the
|
|
/// interest of a simple implementation:
|
|
///
|
|
/// - The provided `diff`'s start and end states _must_ correspond to `old_changelog_contents` and
|
|
/// `new_changelog_contents`.
|
|
/// - The provided `diff` must _only_ contain a single entry for the file containing
|
|
/// `old_changelog_contents` and `new_changelog_contents`.
|
|
///
|
|
/// Failing to uphold these assumptons is not unsafe, but will yield incorrect results.
|
|
fn hunks_in_a_released_section<'a>(
|
|
old_changelog_contents: &str,
|
|
new_changelog_contents: &str,
|
|
diff: &'a str,
|
|
) -> Vec<&'a str> {
|
|
let old_first_release_section_line_num = first_release_section_line_num(old_changelog_contents);
|
|
let new_first_release_section_line_num = first_release_section_line_num(new_changelog_contents);
|
|
|
|
let hunks = {
|
|
let first_hunk_match = diff.match_indices("\n@@").next();
|
|
let Some((first_hunk_idx, _)) = first_hunk_match else {
|
|
log::info!("no diff found");
|
|
return vec![];
|
|
};
|
|
SplitPrefixInclusive::new("\n@@", &diff[first_hunk_idx..]).map(|s| &s['\n'.len_utf8()..])
|
|
};
|
|
let hunks_in_a_released_section = hunks
|
|
.filter(|hunk| {
|
|
let (hunk_header, hunk_contents) = hunk.split_once('\n').unwrap();
|
|
|
|
// Reference: This is of the format `@@ -86,6 +88,10 @@ …`.
|
|
static HUNK_HEADER_RE: OnceLock<Regex> = OnceLock::new();
|
|
let hunk_header_re = HUNK_HEADER_RE
|
|
.get_or_init(|| Regex::new(r"@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@.*").unwrap());
|
|
let captures = hunk_header_re.captures_at(hunk_header, 0).unwrap();
|
|
let mut old_line_num = captures.get(1).unwrap().as_str().parse::<u64>().unwrap();
|
|
let mut new_line_num = captures.get(2).unwrap().as_str().parse::<u64>().unwrap();
|
|
|
|
for line in hunk_contents.lines() {
|
|
match line.as_bytes().first().copied() {
|
|
Some(b' ') => {
|
|
old_line_num += 1;
|
|
new_line_num += 1;
|
|
}
|
|
Some(b'-') => {
|
|
if old_line_num >= old_first_release_section_line_num {
|
|
return true;
|
|
}
|
|
old_line_num += 1;
|
|
}
|
|
Some(b'+') => {
|
|
if new_line_num >= new_first_release_section_line_num {
|
|
return true;
|
|
}
|
|
new_line_num += 1;
|
|
}
|
|
_ => {}
|
|
}
|
|
}
|
|
|
|
false
|
|
})
|
|
.collect::<Vec<_>>();
|
|
|
|
hunks_in_a_released_section
|
|
}
|
|
|
|
fn first_release_section_line_num(changelog_contents: &str) -> u64 {
|
|
let mut changelog_lines = changelog_contents.lines();
|
|
|
|
let unreleased_line_num =
|
|
changelog_lines.position(|l| l == "## Unreleased").unwrap() as u64 + 1;
|
|
unreleased_line_num + 1 + changelog_lines.position(|l| l.starts_with("## ")).unwrap() as u64
|
|
}
|
|
|
|
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
|
struct OddCharacter {
|
|
line: u64,
|
|
column: u64,
|
|
character: char,
|
|
}
|
|
|
|
impl std::fmt::Display for OddCharacter {
|
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
write!(
|
|
f,
|
|
"- line {}, column {}: {}",
|
|
self.line,
|
|
self.column,
|
|
self.character.escape_unicode(),
|
|
)
|
|
}
|
|
}
|
|
|
|
fn find_odd_characters(changelog_contents: &str) -> Vec<OddCharacter> {
|
|
let mut odd_characters = vec![];
|
|
|
|
let mut line = 1;
|
|
let mut column = 1;
|
|
for character in changelog_contents.chars() {
|
|
if is_odd_character(character) {
|
|
odd_characters.push(OddCharacter {
|
|
line,
|
|
column,
|
|
character,
|
|
});
|
|
}
|
|
|
|
if character == '\n' {
|
|
line += 1;
|
|
column = 1;
|
|
} else {
|
|
column += 1;
|
|
}
|
|
}
|
|
|
|
odd_characters
|
|
}
|
|
|
|
fn is_odd_character(character: char) -> bool {
|
|
match character {
|
|
' ' | '\t' | '\n' | '\r' => false,
|
|
_ => {
|
|
character.is_control()
|
|
|| character.is_whitespace()
|
|
|| matches!(
|
|
character,
|
|
'\u{00AD}' // soft hyphen
|
|
| '\u{200B}'..='\u{200F}' // zero-width characters and directional marks
|
|
| '\u{2028}'..='\u{202E}' // separators and bidi overrides
|
|
| '\u{2060}'..='\u{2064}' // invisible operators and joins
|
|
| '\u{FEFF}' // zero-width no-break space / byte order mark
|
|
)
|
|
}
|
|
}
|
|
}
|
|
|
|
struct SplitPrefixInclusive<'haystack, 'prefix> {
|
|
haystack: Option<&'haystack str>,
|
|
prefix: &'prefix str,
|
|
current_pos: usize,
|
|
}
|
|
|
|
impl<'haystack, 'prefix> SplitPrefixInclusive<'haystack, 'prefix> {
|
|
pub fn new(prefix: &'prefix str, haystack: &'haystack str) -> Self {
|
|
assert!(haystack.starts_with(prefix));
|
|
Self {
|
|
haystack: Some(haystack),
|
|
prefix,
|
|
current_pos: 0,
|
|
}
|
|
}
|
|
}
|
|
|
|
impl<'haystack> Iterator for SplitPrefixInclusive<'haystack, '_> {
|
|
type Item = &'haystack str;
|
|
|
|
fn next(&mut self) -> Option<Self::Item> {
|
|
let remaining = &self.haystack?[self.current_pos..];
|
|
|
|
let prefix_len = self.prefix.len();
|
|
|
|
// NOTE: We've guaranteed that the prefix is always at the start of what remains. So, skip
|
|
// the first match manually, and adjust match indices by `prefix_len` later.
|
|
let to_search = &remaining[prefix_len..];
|
|
|
|
match to_search.match_indices(self.prefix).next() {
|
|
None => {
|
|
self.haystack = None;
|
|
Some(remaining)
|
|
}
|
|
Some((idx, _match)) => {
|
|
let length = idx + prefix_len;
|
|
self.current_pos += length;
|
|
Some(&remaining[..length])
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod test_check_changelog {
|
|
use pico_args::Arguments;
|
|
use xshell::Shell;
|
|
|
|
use super::check_changelog;
|
|
|
|
#[test]
|
|
fn base_branch_advanced_without_reflog_history() -> anyhow::Result<()> {
|
|
let shell = Shell::new()?;
|
|
let directory = shell.create_temp_dir()?;
|
|
shell.change_dir(directory.path());
|
|
shell.write_file("gitconfig", "")?;
|
|
shell.set_var("GIT_CONFIG_GLOBAL", directory.path().join("gitconfig"));
|
|
shell.set_var("GIT_CONFIG_NOSYSTEM", "1");
|
|
shell.set_var("GIT_AUTHOR_NAME", "Test");
|
|
shell.set_var("GIT_AUTHOR_EMAIL", "test@example.com");
|
|
shell.set_var("GIT_COMMITTER_NAME", "Test");
|
|
shell.set_var("GIT_COMMITTER_EMAIL", "test@example.com");
|
|
shell
|
|
.cmd("git")
|
|
.args(["init", "--initial-branch=trunk"])
|
|
.run()?;
|
|
|
|
let original = "# Changelog\n\n## Unreleased\n\n## 1.0.0\n\n- Released.\n";
|
|
shell.write_file("CHANGELOG.md", original)?;
|
|
shell.cmd("git").args(["add", "CHANGELOG.md"]).run()?;
|
|
shell
|
|
.cmd("git")
|
|
.args(["commit", "-m", "Initial changelog"])
|
|
.run()?;
|
|
shell.cmd("git").args(["checkout", "-b", "topic"]).run()?;
|
|
let updated = original.replace("## Unreleased\n", "## Unreleased\n\n- New entry.\n");
|
|
shell.write_file("CHANGELOG.md", &updated)?;
|
|
shell
|
|
.cmd("git")
|
|
.args(["commit", "-am", "Add entry"])
|
|
.run()?;
|
|
|
|
shell.cmd("git").args(["checkout", "trunk"]).run()?;
|
|
shell
|
|
.cmd("git")
|
|
.args(["commit", "--allow-empty", "-m", "Advance trunk"])
|
|
.run()?;
|
|
shell
|
|
.cmd("git")
|
|
.args(["update-ref", "refs/remotes/origin/trunk", "HEAD"])
|
|
.run()?;
|
|
shell.cmd("git").args(["checkout", "topic"]).run()?;
|
|
|
|
check_changelog(
|
|
shell.clone(),
|
|
Arguments::from_vec(vec!["origin/trunk".into()]),
|
|
)?;
|
|
shell.write_file(
|
|
"CHANGELOG.md",
|
|
updated.replace("Released.", "Changed release."),
|
|
)?;
|
|
assert!(check_changelog(
|
|
shell.clone(),
|
|
Arguments::from_vec(vec!["origin/trunk".into()])
|
|
)
|
|
.is_err());
|
|
check_changelog(
|
|
shell,
|
|
Arguments::from_vec(vec!["origin/trunk".into(), "topic".into()]),
|
|
)?;
|
|
Ok(())
|
|
}
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod test_find_odd_characters {
|
|
use super::{find_odd_characters, is_odd_character, OddCharacter};
|
|
|
|
#[test]
|
|
fn accepts_regular_text() {
|
|
assert_eq!(
|
|
find_odd_characters(
|
|
"# Changelog\n\n- Em dashes—curly quotes'… accents é and emoji 🎉 are fine.\n"
|
|
),
|
|
[]
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn accepts_ordinary_whitespace() {
|
|
for character in [' ', '\t', '\n', '\r'] {
|
|
assert!(!is_odd_character(character));
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn rejects_invisible_characters() {
|
|
for character in [
|
|
'\u{00A0}', '\u{00AD}', '\u{200B}', '\u{200E}', '\u{202A}', '\u{2060}', '\u{FEFF}',
|
|
'\u{0000}',
|
|
] {
|
|
assert!(is_odd_character(character));
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn reports_line_and_column() {
|
|
assert_eq!(
|
|
find_odd_characters("first line\nse\u{00A0}cond line"),
|
|
[OddCharacter {
|
|
line: 2,
|
|
column: 3,
|
|
character: '\u{00A0}',
|
|
}],
|
|
);
|
|
}
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod test_split_prefix_inclusive {
|
|
#[collapse_debuginfo(yes)]
|
|
macro_rules! assert_chunks {
|
|
($prefix: expr, $haystack: expr, $expected: expr $(,)?) => {
|
|
assert_eq!(
|
|
super::SplitPrefixInclusive::new($prefix, $haystack).collect::<Vec<_>>(),
|
|
$expected.into_iter().collect::<Vec<_>>(),
|
|
);
|
|
};
|
|
}
|
|
|
|
#[test]
|
|
fn it_works() {
|
|
assert_chunks! {
|
|
"\n@@",
|
|
"
|
|
@@ -1,4 +1,5 @@
|
|
<!--
|
|
+ This change should be accepted.
|
|
Pad out some changes here so we force multiple hunks in a diff.
|
|
Pad out some changes here so we force multiple hunks in a diff.
|
|
Pad out some changes here so we force multiple hunks in a diff.
|
|
@@ -17,6 +18,7 @@
|
|
- Pad out some changes here so we force multiple hunks in a diff.
|
|
- Pad out some changes here so we force multiple hunks in a diff.
|
|
- Pad out some changes here so we force multiple hunks in a diff.
|
|
+- This change should be accepted.
|
|
\u{0020}
|
|
## Recently released
|
|
\u{0020}
|
|
@@ -26,6 +28,7 @@
|
|
- Pad out some changes here so we force multiple hunks in a diff.
|
|
- Pad out some changes here so we force multiple hunks in a diff.
|
|
- Pad out some changes here so we force multiple hunks in a diff.
|
|
+- This change was added after release, reject me!
|
|
\u{0020}
|
|
## An older release
|
|
\u{0020}
|
|
",
|
|
[
|
|
"
|
|
@@ -1,4 +1,5 @@
|
|
<!--
|
|
+ This change should be accepted.
|
|
Pad out some changes here so we force multiple hunks in a diff.
|
|
Pad out some changes here so we force multiple hunks in a diff.
|
|
Pad out some changes here so we force multiple hunks in a diff.",
|
|
"
|
|
@@ -17,6 +18,7 @@
|
|
- Pad out some changes here so we force multiple hunks in a diff.
|
|
- Pad out some changes here so we force multiple hunks in a diff.
|
|
- Pad out some changes here so we force multiple hunks in a diff.
|
|
+- This change should be accepted.
|
|
\u{0020}
|
|
## Recently released
|
|
\u{0020}",
|
|
"
|
|
@@ -26,6 +28,7 @@
|
|
- Pad out some changes here so we force multiple hunks in a diff.
|
|
- Pad out some changes here so we force multiple hunks in a diff.
|
|
- Pad out some changes here so we force multiple hunks in a diff.
|
|
+- This change was added after release, reject me!
|
|
\u{0020}
|
|
## An older release
|
|
\u{0020}
|
|
",
|
|
]
|
|
}
|
|
}
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod test_hunks_in_a_released_section {
|
|
#[collapse_debuginfo(yes)]
|
|
macro_rules! assert_released_section_changes {
|
|
($changelog_contents: expr, $diff: expr, $expected: expr $(,)?) => {
|
|
assert_eq!(
|
|
super::hunks_in_a_released_section($changelog_contents, $changelog_contents, $diff),
|
|
$expected
|
|
.map(|h: &str| h.to_owned())
|
|
.into_iter()
|
|
.collect::<Vec<_>>(),
|
|
);
|
|
};
|
|
($old_changelog_contents: expr, $new_changelog_contents: expr, $diff: expr, $expected: expr $(,)?) => {
|
|
assert_eq!(
|
|
super::hunks_in_a_released_section(
|
|
$old_changelog_contents,
|
|
$new_changelog_contents,
|
|
$diff,
|
|
),
|
|
$expected
|
|
.map(|h: &str| h.to_owned())
|
|
.into_iter()
|
|
.collect::<Vec<_>>(),
|
|
);
|
|
};
|
|
}
|
|
|
|
#[test]
|
|
fn change_in_a_release_section_rejects() {
|
|
assert_released_section_changes! {
|
|
"\
|
|
<!-- Some explanatory comment -->
|
|
|
|
## Unreleased
|
|
|
|
## Recently released
|
|
|
|
- This change actually went into the release.
|
|
- This change was added after release, reject me!
|
|
|
|
## An older release
|
|
|
|
- Yada yada.
|
|
",
|
|
"\
|
|
--- a/CHANGELOG.md
|
|
+++ b/CHANGELOG.md
|
|
@@ -5,6 +5,7 @@
|
|
## Recently released
|
|
\u{0020}
|
|
- This change actually went into the release.
|
|
+- This change was added after release, reject me!
|
|
\u{0020}
|
|
## An older release
|
|
",
|
|
[
|
|
"\
|
|
@@ -5,6 +5,7 @@
|
|
## Recently released
|
|
\u{0020}
|
|
- This change actually went into the release.
|
|
+- This change was added after release, reject me!
|
|
\u{0020}
|
|
## An older release
|
|
",
|
|
],
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn change_in_unreleased_not_rejected() {
|
|
assert_released_section_changes! {
|
|
"\
|
|
<!-- Some explanatory comment -->
|
|
|
|
## Unreleased
|
|
|
|
- This change was due to the valiant efforts of a contributor.
|
|
|
|
## Recently released
|
|
|
|
- This change actually went into the release.
|
|
|
|
## An older release
|
|
|
|
- Yada yada.
|
|
",
|
|
"\
|
|
--- a/CHANGELOG.md
|
|
+++ b/CHANGELOG.md
|
|
@@ -2,6 +2,8 @@
|
|
\u{0020}
|
|
## Unreleased
|
|
\u{0020}
|
|
+- This change was due to the valiant efforts of a contributor.
|
|
+
|
|
## Recently released
|
|
\u{0020}
|
|
- This change actually went into the release.
|
|
",
|
|
[],
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn change_above_unreleased_not_rejected() {
|
|
assert_released_section_changes! {
|
|
"\
|
|
<!-- Some explanatory comment -->
|
|
<!-- Turns out, we needed to explain things more. -->
|
|
|
|
## Unreleased
|
|
|
|
- This change was due to the valiant efforts of a contributor.
|
|
|
|
## Recently released
|
|
|
|
- This change actually went into the release.
|
|
|
|
## An older release
|
|
|
|
- Yada yada.
|
|
",
|
|
"\
|
|
--- a/CHANGELOG.md
|
|
+++ b/CHANGELOG.md
|
|
@@ -1,4 +1,5 @@
|
|
<!-- Some explanatory comment -->
|
|
+<!-- Turns out, we needed to explain things more. -->
|
|
\u{0020}
|
|
## Unreleased
|
|
\u{0020}
|
|
",
|
|
[],
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn all_reject_and_not_reject_cases_at_once() {
|
|
assert_released_section_changes! {
|
|
"\
|
|
<!--
|
|
This change should be accepted.
|
|
Pad out some changes here so we force multiple hunks in a diff.
|
|
Pad out some changes here so we force multiple hunks in a diff.
|
|
Pad out some changes here so we force multiple hunks in a diff.
|
|
Pad out some changes here so we force multiple hunks in a diff.
|
|
Pad out some changes here so we force multiple hunks in a diff.
|
|
Pad out some changes here so we force multiple hunks in a diff.
|
|
Pad out some changes here so we force multiple hunks in a diff.
|
|
-->
|
|
|
|
## Unreleased
|
|
|
|
- Pad out some changes here so we force multiple hunks in a diff.
|
|
- Pad out some changes here so we force multiple hunks in a diff.
|
|
- Pad out some changes here so we force multiple hunks in a diff.
|
|
- Pad out some changes here so we force multiple hunks in a diff.
|
|
- Pad out some changes here so we force multiple hunks in a diff.
|
|
- Pad out some changes here so we force multiple hunks in a diff.
|
|
- Pad out some changes here so we force multiple hunks in a diff.
|
|
- This change should be accepted.
|
|
|
|
## Recently released
|
|
|
|
- Pad out some changes here so we force multiple hunks in a diff.
|
|
- Pad out some changes here so we force multiple hunks in a diff.
|
|
- Pad out some changes here so we force multiple hunks in a diff.
|
|
- Pad out some changes here so we force multiple hunks in a diff.
|
|
- Pad out some changes here so we force multiple hunks in a diff.
|
|
- Pad out some changes here so we force multiple hunks in a diff.
|
|
- This change was added after release, reject me!
|
|
|
|
## An older release
|
|
|
|
- Yada yada.
|
|
",
|
|
"\
|
|
--- ../CHANGELOG.md
|
|
+++ ../CHANGELOG.md
|
|
@@ -1,4 +1,5 @@
|
|
<!--
|
|
+ This change should be accepted.
|
|
Pad out some changes here so we force multiple hunks in a diff.
|
|
Pad out some changes here so we force multiple hunks in a diff.
|
|
Pad out some changes here so we force multiple hunks in a diff.
|
|
@@ -17,6 +18,7 @@
|
|
- Pad out some changes here so we force multiple hunks in a diff.
|
|
- Pad out some changes here so we force multiple hunks in a diff.
|
|
- Pad out some changes here so we force multiple hunks in a diff.
|
|
+- This change should be accepted.
|
|
\u{0020}
|
|
## Recently released
|
|
\u{0020}
|
|
@@ -26,6 +28,7 @@
|
|
- Pad out some changes here so we force multiple hunks in a diff.
|
|
- Pad out some changes here so we force multiple hunks in a diff.
|
|
- Pad out some changes here so we force multiple hunks in a diff.
|
|
+- This change was added after release, reject me!
|
|
\u{0020}
|
|
## An older release
|
|
\u{0020}
|
|
",
|
|
[
|
|
"\
|
|
@@ -26,6 +28,7 @@
|
|
- Pad out some changes here so we force multiple hunks in a diff.
|
|
- Pad out some changes here so we force multiple hunks in a diff.
|
|
- Pad out some changes here so we force multiple hunks in a diff.
|
|
+- This change was added after release, reject me!
|
|
\u{0020}
|
|
## An older release
|
|
\u{0020}
|
|
",
|
|
],
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn rejection_ranges() {
|
|
assert_released_section_changes! {
|
|
"\
|
|
<!-- Some explanatory comment -->
|
|
|
|
## Unreleased
|
|
|
|
- This change was due to the valiant efforts of a contributor.
|
|
|
|
## Recently released
|
|
|
|
- This change actually went into the release.
|
|
- terribly
|
|
long
|
|
entry
|
|
please
|
|
save
|
|
me
|
|
|
|
## An older release
|
|
|
|
- Yada yada.
|
|
",
|
|
"\
|
|
diff --git a/../CHANGELOG-old.md b/../CHANGELOG-new.md
|
|
index a6bf3614a..c766d7225 100644
|
|
--- a/../CHANGELOG-old.md
|
|
+++ b/../CHANGELOG-new.md
|
|
@@ -7,6 +7,12 @@
|
|
## Recently released
|
|
\u{0020}
|
|
- This change actually went into the release.
|
|
+- terribly
|
|
+ long
|
|
+ entry
|
|
+ please
|
|
+ save
|
|
+ me
|
|
\u{0020}
|
|
## An older release
|
|
\u{0020}
|
|
",
|
|
[
|
|
"\
|
|
@@ -7,6 +7,12 @@
|
|
## Recently released
|
|
\u{0020}
|
|
- This change actually went into the release.
|
|
+- terribly
|
|
+ long
|
|
+ entry
|
|
+ please
|
|
+ save
|
|
+ me
|
|
\u{0020}
|
|
## An older release
|
|
\u{0020}
|
|
",
|
|
],
|
|
}
|
|
assert_released_section_changes! {
|
|
"\
|
|
<!-- Some explanatory comment -->
|
|
|
|
## Unreleased
|
|
|
|
- This change was due to the valiant efforts of a contributor.
|
|
|
|
## Recently released
|
|
|
|
- This change actually went into the release.
|
|
|
|
## An older release
|
|
|
|
- Accidentally added before.
|
|
- Yada yada.
|
|
- Accidentally added after.
|
|
",
|
|
"\
|
|
diff --git a/../CHANGELOG-old.md b/../CHANGELOG-new.md
|
|
index a6bf3614a..5c2dcdc4e 100644
|
|
--- a/../CHANGELOG-old.md
|
|
+++ b/../CHANGELOG-new.md
|
|
@@ -10,4 +10,6 @@
|
|
\u{0020}
|
|
## An older release
|
|
\u{0020}
|
|
+- Accidentally added before.
|
|
- Yada yada.
|
|
+- Accidentally added after.
|
|
",
|
|
[
|
|
"\
|
|
@@ -10,4 +10,6 @@
|
|
\u{0020}
|
|
## An older release
|
|
\u{0020}
|
|
+- Accidentally added before.
|
|
- Yada yada.
|
|
+- Accidentally added after.
|
|
",
|
|
]
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn deletion_up_to_released() {
|
|
assert_released_section_changes! {
|
|
"\
|
|
<!-- Some explanatory comment -->
|
|
|
|
## Unreleased
|
|
|
|
WHADDUP FOLKS
|
|
|
|
HERE'S SOME STUFF THAT'S GONNA GET DELETED
|
|
|
|
## Released
|
|
|
|
- Blah blah blah.
|
|
",
|
|
"\
|
|
<!-- Some explanatory comment -->
|
|
|
|
## Unreleased
|
|
|
|
WHADDUP FOLKS
|
|
|
|
## Released
|
|
|
|
- Blah blah blah.
|
|
",
|
|
"\
|
|
--- a/CHANGELOG.md
|
|
+++ b/CHANGELOG.md
|
|
@@ -4,8 +4,6 @@
|
|
\u{0020}
|
|
WHADDUP FOLKS
|
|
\u{0020}
|
|
-HERE'S SOME STUFF THAT'S GONNA GET DELETED
|
|
-
|
|
## Released
|
|
\u{0020}
|
|
- Blah blah blah.
|
|
",
|
|
[],
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn change_of_release_section() {
|
|
assert_released_section_changes! {
|
|
"\
|
|
<!-- Some explanatory comment -->
|
|
|
|
## Unreleased
|
|
|
|
WHADDUP FOLKS
|
|
|
|
## Released (hee hee hee)
|
|
|
|
- Blah blah blah.
|
|
",
|
|
"\
|
|
--- a/CHANGELOG.md
|
|
+++ b/CHANGELOG.md
|
|
@@ -4,6 +4,6 @@
|
|
\u{0020}
|
|
WHADDUP FOLKS
|
|
\u{0020}
|
|
-## Released
|
|
+## Released (hee hee hee)
|
|
\u{0020}
|
|
- Blah blah blah.
|
|
",
|
|
[
|
|
"\
|
|
@@ -4,6 +4,6 @@
|
|
\u{0020}
|
|
WHADDUP FOLKS
|
|
\u{0020}
|
|
-## Released
|
|
+## Released (hee hee hee)
|
|
\u{0020}
|
|
- Blah blah blah.
|
|
",
|
|
],
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn deletion_of_released_section() {
|
|
assert_released_section_changes! {
|
|
"\
|
|
## Unreleased
|
|
|
|
Release summary
|
|
|
|
## Release 2
|
|
|
|
- Previously released note.
|
|
|
|
## Release 1
|
|
|
|
- Existing released entry.
|
|
",
|
|
"\
|
|
## Unreleased
|
|
|
|
Release summary
|
|
|
|
## Release 1
|
|
|
|
- Existing released entry.
|
|
",
|
|
"\
|
|
diff --git a/CHANGELOG.md b/CHANGELOG.md
|
|
index 908e22ab6..a7eb3c978 100644
|
|
--- a/CHANGELOG.md
|
|
+++ b/CHANGELOG.md
|
|
@@ -2,10 +2,6 @@
|
|
\u{0020}
|
|
Release summary
|
|
\u{0020}
|
|
-## Release 2
|
|
-
|
|
- Previously released note.
|
|
-
|
|
## Release 1
|
|
\u{0020}
|
|
- Existing released entry.
|
|
",
|
|
[
|
|
"\
|
|
@@ -2,10 +2,6 @@
|
|
\u{0020}
|
|
Release summary
|
|
\u{0020}
|
|
-## Release 2
|
|
-
|
|
- Previously released note.
|
|
-
|
|
## Release 1
|
|
\u{0020}
|
|
- Existing released entry.
|
|
",
|
|
],
|
|
}
|
|
}
|
|
}
|