From ff7240633fcb46e6190dfed22150cbf8d3012df5 Mon Sep 17 00:00:00 2001 From: Albrecht Date: Mon, 26 Aug 2024 20:07:19 +0200 Subject: [PATCH] fix(changelog): don't change the context when provided via `--from-context` (#820) closes orhun/git-cliff/issues/819 --- git-cliff-core/src/changelog.rs | 13 ++++++++++--- git-cliff/src/lib.rs | 2 +- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/git-cliff-core/src/changelog.rs b/git-cliff-core/src/changelog.rs index 3a42697dcc..06b77a252c 100644 --- a/git-cliff-core/src/changelog.rs +++ b/git-cliff-core/src/changelog.rs @@ -430,13 +430,20 @@ impl<'a> Changelog<'a> { } } - /// Adds remote data (e.g. GitHub commits) to the releases. - pub fn add_remote_data(&mut self) -> Result<()> { - debug!("Adding remote data..."); + /// Adds information about the remote to the template context. + pub fn add_remote_context(&mut self) -> Result<()> { self.additional_context.insert( "remote".to_string(), serde_json::to_value(self.config.remote.clone())?, ); + Ok(()) + } + + /// Adds remote data (e.g. GitHub commits) to the releases. + pub fn add_remote_data(&mut self) -> Result<()> { + debug!("Adding remote data..."); + self.add_remote_context()?; + #[cfg(feature = "github")] let (github_commits, github_pull_requests) = if self.config.remote.github.is_set() { diff --git a/git-cliff/src/lib.rs b/git-cliff/src/lib.rs index f689b0e8c4..ea8dcb2299 100644 --- a/git-cliff/src/lib.rs +++ b/git-cliff/src/lib.rs @@ -535,7 +535,7 @@ pub fn run(mut args: Opt) -> Result<()> { Box::new(File::open(context_path)?) }; let mut changelog = Changelog::from_context(&mut input, &config)?; - changelog.add_remote_data()?; + changelog.add_remote_context()?; changelog } else { // Process the repositories.