8000 feat(bump): option to append skip-ci pattern for bump commit by Wassim-AB · Pull Request #274 · cocogitto/cocogitto · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat(bump): option to append skip-ci pattern for bump commit #274

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 1, 2023
Merged
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
8 changes: 8 additions & 0 deletions src/bin/cog/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,10 @@ enum Command {
/// Dry-run: print the target version. No action taken
#[arg(short, long)]
dry_run: bool,

/// Specify a "Skip CI" string to append to the end of the commit
#[arg(long = "skip-ci")]
skip_ci: Option<String>,
},

/// Install cog config files
Expand Down Expand Up @@ -357,6 +361,7 @@ fn main() -> Result<()> {
package,
annotated,
dry_run,
skip_ci,
} => {
let mut cocogitto = CocoGitto::get()?;
let is_monorepo = !SETTINGS.packages.is_empty();
Expand Down Expand Up @@ -391,6 +396,7 @@ fn main() -> Result<()> {
hook_profile.as_deref(),
annotated,
dry_run,
skip_ci,
)?
}
None => cocogitto.create_monorepo_version(
Expand All @@ -399,6 +405,7 @@ fn main() -> Result<()> {
hook_profile.as_deref(),
annotated,
dry_run,
skip_ci,
)?,
}
} else {
Expand All @@ -408,6 +415,7 @@ fn main() -> Result<()> {
hook_profile.as_deref(),
annotated,
dry_run,
skip_ci,
)?
}
}
Expand Down
44 changes: 38 additions & 6 deletions src/command/bump/monorepo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,28 @@ impl CocoGitto {
hooks_config: Option<&str>,
annotated: Option<String>,
dry_run: bool,
skip_ci: Option<String>,
) -> Result<()> {
match increment {
IncrementCommand::Auto => {
if SETTINGS.generate_mono_repository_global_tag {
self.create_monorepo_version_auto(pre_release, hooks_config, annotated, dry_run)
self.create_monorepo_version_auto(
pre_release,
hooks_config,
annotated,
dry_run,
skip_ci,
)
} else {
if annotated.is_some() {
warn!("--annotated flag is not supported for package bumps without a global tag");
}
self.create_all_package_version_auto(pre_release, hooks_config, dry_run)
self.create_all_package_version_auto(
pre_release,
hooks_config,
dry_run,
skip_ci,
)
}
}
_ => self.create_monorepo_version_manual(
Expand All @@ -63,6 +75,7 @@ impl CocoGitto {
hooks_config,
annotated,
dry_run,
skip_ci,
),
}
}
Expand All @@ -72,6 +85,7 @@ impl CocoGitto {
pre_release: Option<&str>,
hooks_config: Option<&str>,
dry_run: bool,
skip_ci: Option<String>,
) -> Result<()> {
self.pre_bump_checks()?;
// Get package bumps
Expand All @@ -96,8 +110,13 @@ impl CocoGitto {
self.bump_packages(pre_release, hooks_config, &bumps)?;

let sign = self.repository.gpg_sign();
self.repository
.commit("chore(version): bump packages", sign)?;

let skip_ci_pattern = skip_ci.unwrap_or(SETTINGS.skip_ci.clone().unwrap_or_default());

self.repository.commit(
&format!("chore(version): bump packages {}", skip_ci_pattern),
sign,
)?;

for bump in &bumps {
self.repository.create_tag(&bump.new_version.prefixed_tag)?;
Expand Down Expand Up @@ -131,6 +150,7 @@ impl CocoGitto {
hooks_config: Option<&str>,
annotated: Option<String>,
dry_run: bool,
skip_ci: Option<String>,
) -> Result<()> {
self.pre_bump_checks()?;
// Get package bumps
Expand Down Expand Up @@ -227,8 +247,14 @@ impl CocoGitto {
self.bump_packages(pre_release, hooks_config, &bumps)?;

let sign = self.repository.gpg_sign();

let skip_ci_pattern = skip_ci.unwrap_or(SETTINGS.skip_ci.clone().unwrap_or_default());

self.repository.commit(
&format!("chore(version): {}", next_version.prefixed_tag),
&format!(
"chore(version): {} {}",
next_version.prefixed_tag, skip_ci_pattern
),
sign,
)?;

Expand Down Expand Up @@ -279,6 +305,7 @@ impl CocoGitto {
hooks_config: Option<&str>,
annotated: Option<String>,
dry_run: bool,
skip_ci: Option<String>,
) -> Result<()> {
self.pre_bump_checks()?;
// Get package bumps
Expand Down Expand Up @@ -343,8 +370,13 @@ impl CocoGitto {
self.unwrap_or_stash_and_exit(&tag, hook_result);

let sign = self.repository.gpg_sign();
let skip_ci_pattern = skip_ci.unwrap_or(SETTINGS.skip_ci.clone().unwrap_or_default());

self.repository.commit(
&format!("chore(version): {}", next_version.prefixed_tag),
&format!(
"chore(version): {} {}",
next_version.prefixed_tag, skip_ci_pattern
),
sign,
)?;

Expand Down
7 changes: 6 additions & 1 deletion src/command/bump/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use semver::Prerelease;
use tera::Tera;

impl CocoGitto {
#[allow(clippy::too_many_arguments)]
pub fn create_package_version(
&mut self,
(package_name, package): (&str, &MonoRepoPackage),
Expand All @@ -23,6 +24,7 @@ impl CocoGitto {
hooks_config: Option<&str>,
annotated: Option<String>,
dry_run: bool,
skip_ci: Option<String>,
) -> Result<()> {
self.pre_bump_checks()?;

Expand Down Expand Up @@ -82,8 +84,11 @@ impl CocoGitto {
self.unwrap_or_stash_and_exit(&tag, hook_result);

let sign = self.repository.gpg_sign();

let skip_ci_pattern = skip_ci.unwrap_or(SETTINGS.skip_ci.clone().unwrap_or_default());

self.repository
.commit(&format!("chore(version): {tag}"), sign)?;
.commit(&format!("chore(version): {tag} {}", skip_ci_pattern), sign)?;

if let Some(msg_tmpl) = annotated {
let mut context = tera::Context::new();
Expand Down
8 changes: 7 additions & 1 deletion src/command/bump/standard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ impl CocoGitto {
hooks_config: Option<&str>,
annotated: Option<String>,
dry_run: bool,
skip_ci: Option<String>,
) -> Result<()> {
self.pre_bump_checks()?;

Expand Down Expand Up @@ -70,8 +71,13 @@ impl CocoGitto {

let sign = self.repository.gpg_sign();

let skip_ci_pattern = skip_ci.unwrap_or(SETTINGS.skip_ci.clone().unwrap_or_default());

self.repository.commit(
&format!("chore(version): {}", next_version.prefixed_tag),
&format!(
"chore(version): {} {}",
next_version.prefixed_tag, skip_ci_pattern
),
sign,
)?;

Expand Down
2 changes: 2 additions & 0 deletions src/settings/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ pub struct Settings {
pub monorepo_version_separator: Option<String>,
pub branch_whitelist: Vec<String>,
pub tag_prefix: Option<String>,
pub skip_ci: Option<String>,
pub pre_bump_hooks: Vec<String>,
pub post_bump_hooks: Vec<String>,
pub pre_package_bump_hooks: Vec<String>,
Expand All @@ -56,6 +57,7 @@ impl Default for Settings {
monorepo_version_separator: None,
branch_whitelist: vec![],
tag_prefix: None,
skip_ci: None,
pre_bump_hooks: vec![],
post_bump_hooks: vec![],
pre_package_bump_hooks: vec![],
Expand Down
Loading
0