|
1 | | -use std::env; |
2 | | - |
3 | 1 | use clap::{Args, Subcommand, ValueEnum}; |
4 | 2 | use xshell::cmd; |
5 | 3 |
|
6 | | -use crate::{sh, workspace, Result}; |
| 4 | +use crate::{sh, Result}; |
7 | 5 |
|
8 | 6 | #[derive(Args)] |
9 | 7 | pub struct ReleaseArgs { |
@@ -36,10 +34,6 @@ enum ReleaseCommand { |
36 | 34 | }, |
37 | 35 | /// Get a list of interesting changes that happened in the last week. |
38 | 36 | WeeklyReport, |
39 | | - /// Generate the changelog for a specific crate, this shouldn't be run |
40 | | - /// manually, cargo-release will call this. |
41 | | - #[clap(hide = true)] |
42 | | - Changelog, |
43 | 37 | } |
44 | 38 |
|
45 | 39 | #[derive(Clone, Copy, Debug, Default, PartialEq, ValueEnum)] |
@@ -68,22 +62,10 @@ impl ReleaseArgs { |
68 | 62 | pub fn run(self) -> Result<()> { |
69 | 63 | check_prerequisites(); |
70 | 64 |
|
71 | | - // The changelog needs to be generated from the directory of the crate, |
72 | | - // `cargo-release` changes the directory for us but we need to |
73 | | - // make sure to not switch back to the workspace dir. |
74 | | - // |
75 | | - // More info: https://git-cliff.org/docs/usage/monorepos |
76 | | - let sh = sh(); |
77 | | - let _p; |
78 | | - if self.cmd != ReleaseCommand::Changelog { |
79 | | - _p = sh.push_dir(workspace::root_path()?); |
80 | | - } |
81 | | - |
82 | 65 | match self.cmd { |
83 | 66 | ReleaseCommand::Prepare { version, execute } => prepare(version, execute), |
84 | 67 | ReleaseCommand::Publish { execute } => publish(execute), |
85 | 68 | ReleaseCommand::WeeklyReport => weekly_report(), |
86 | | - ReleaseCommand::Changelog => changelog(), |
87 | 69 | } |
88 | 70 | } |
89 | 71 | } |
@@ -167,41 +149,3 @@ fn weekly_report() -> Result<()> { |
167 | 149 |
|
168 | 150 | Ok(()) |
169 | 151 | } |
170 | | - |
171 | | -/// Generate the changelog for a given crate. |
172 | | -/// |
173 | | -/// This will be called by `cargo-release` and it will set the correct |
174 | | -/// environment and call it from within the correct directory. |
175 | | -fn changelog() -> Result<()> { |
176 | | - let dry_run = env::var("DRY_RUN").map(|dry| str::parse::<bool>(&dry)).unwrap_or(Ok(true))?; |
177 | | - let crate_name = env::var("CRATE_NAME").expect("CRATE_NAME must be set"); |
178 | | - let new_version = env::var("NEW_VERSION").expect("NEW_VERSION must be set"); |
179 | | - |
180 | | - if dry_run { |
181 | | - println!( |
182 | | - "\nGenerating a changelog for {} (dry run), the following output will be prepended to the CHANGELOG.md file:\n", |
183 | | - crate_name |
184 | | - ); |
185 | | - } else { |
186 | | - println!("Generating a changelog for {}.", crate_name); |
187 | | - } |
188 | | - |
189 | | - let sh = sh(); |
190 | | - let command = cmd!(sh, "git cliff") |
191 | | - .arg("cliff") |
192 | | - .arg("--config") |
193 | | - .arg("../../cliff.toml") |
194 | | - .arg("--include-path") |
195 | | - .arg(format!("crates/{}/**/*", crate_name)) |
196 | | - .arg("--repository") |
197 | | - .arg("../../") |
198 | | - .arg("--unreleased") |
199 | | - .arg("--tag") |
200 | | - .arg(&new_version); |
201 | | - |
202 | | - let command = if dry_run { command } else { command.arg("--prepend").arg("CHANGELOG.md") }; |
203 | | - |
204 | | - command.run()?; |
205 | | - |
206 | | - Ok(()) |
207 | | -} |
0 commit comments