Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion git-cliff-core/src/changelog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,11 @@ pub struct Changelog<'a> {
impl<'a> Changelog<'a> {
/// Constructs a new instance.
pub fn new(releases: Vec<Release<'a>>, config: Config, range: Option<&str>) -> Result<Self> {
let is_offline = config.remote.offline;
let mut changelog = Changelog::build(releases, config)?;
changelog.add_remote_data(range)?;
if !is_offline {
changelog.add_remote_data(range)?;
}
changelog.process_commits()?;
changelog.process_releases();
Ok(changelog)
Expand Down Expand Up @@ -954,6 +957,7 @@ mod test {
exclude_paths: Vec::new(),
},
remote: RemoteConfig {
offline: false,
github: Remote {
owner: String::from("coolguy"),
repo: String::from("awesome"),
Expand Down
3 changes: 3 additions & 0 deletions git-cliff-core/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,9 @@ mod serde_pattern {
/// Remote configuration.
#[derive(Default, Debug, Clone, Serialize, Deserialize)]
pub struct RemoteConfig {
/// Run generation fully offline
#[serde(default)]
pub offline: bool,
/// GitHub remote.
#[serde(default)]
pub github: Remote,
Expand Down
3 changes: 3 additions & 0 deletions git-cliff/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,9 @@ pub struct Opt {
/// Load TLS certificates from the native certificate store.
#[arg(long, help_heading = Some("FLAGS"), hide = !cfg!(feature = "remote"))]
pub use_native_tls: bool,
/// Use only local git history in actions
#[arg(long, help_heading = Some("FLAGS"))]
pub offline: bool,
}

/// Custom type for the remote value.
Expand Down
3 changes: 3 additions & 0 deletions git-cliff/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,9 @@ pub fn run_with_changelog_modifier<'a>(
.token
.clone_from(&args.azure_devops_token);
}
if args.offline {
config.remote.offline = args.offline;
}
if let Some(ref remote) = args.github_repo {
config.remote.github.owner = remote.0.owner.to_string();
config.remote.github.repo = remote.0.repo.to_string();
Expand Down
4 changes: 3 additions & 1 deletion git-cliff/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ fn main() -> Result<()> {

// Check if there is a new version available.
#[cfg(feature = "update-informer")]
git_cliff::check_new_version();
if !args.offline {
git_cliff::check_new_version();
}

// Create the configuration file if init flag is given.
if let Some(path) = &args.init {
Expand Down
4 changes: 4 additions & 0 deletions website/docs/configuration/remote.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ However, in some cases, you may want to use the platform's native certificate st

:::

### offline

When the `offline` argument or configuration parameter is set `git-cliff` ensures that no external calls or requests are made, despite a remote being configured. This can be useful when running `--bumped-version` or in a limited environment.

---

Here is a complete example for a project hosted on GitLab:
Expand Down
Loading