Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitda459de

Browse files
Wassim Ahmed-Belkacemoknozor
Wassim Ahmed-Belkacem
authored andcommitted
fix(bump): option to disable untracked changes error
1 parent5d11d5a commitda459de

File tree

3 files changed

+54
-2
lines changed

3 files changed

+54
-2
lines changed

‎src/command/bump/mod.rs‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,12 @@ impl CocoGitto {
143143
}
144144
let statuses =self.repository.get_statuses()?;
145145

146-
// Fail if repo contains un-staged or un-committed changes
147-
ensure!(statuses.0.is_empty(),"{}",self.repository.get_statuses()?);
146+
// Warning if repository contains untracked or uncomitted changes
147+
ifSETTINGS.skip_untracked{
148+
println!("{}",self.repository.get_statuses()?);
149+
}else{
150+
ensure!(statuses.0.is_empty(),"{}",self.repository.get_statuses()?);
151+
}
148152

149153
if !SETTINGS.branch_whitelist.is_empty(){
150154
ifletSome(branch) =self.repository.get_branch_shorthand(){

‎src/settings/mod.rs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ pub struct Settings {
3737
pubbranch_whitelist:Vec<String>,
3838
pubtag_prefix:Option<String>,
3939
pubskip_ci:Option<String>,
40+
pubskip_untracked:bool,
4041
pubpre_bump_hooks:Vec<String>,
4142
pubpost_bump_hooks:Vec<String>,
4243
pubpre_package_bump_hooks:Vec<String>,
@@ -58,6 +59,7 @@ impl Default for Settings {
5859
branch_whitelist:vec![],
5960
tag_prefix:None,
6061
skip_ci:None,
62+
skip_untracked:false,
6163
pre_bump_hooks:vec![],
6264
post_bump_hooks:vec![],
6365
pre_package_bump_hooks:vec![],

‎tests/cog_tests/bump.rs‎

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use crate::helpers::*;
44

55
use anyhow::Result;
66
use assert_cmd::prelude::*;
7+
use cmd_lib::run_cmd;
78
use cocogitto::settings::Settings;
89
use indoc::indoc;
910
use sealed_test::prelude::*;
@@ -333,3 +334,48 @@ fn package_dry_run() -> Result<()> {
333334
assert_tag_does_not_exist("1.1.0")?;
334335
Ok(())
335336
}
337+
338+
#[sealed_test]
339+
fnuncommited_changes_should_throw_error_by_default() ->Result<()>{
340+
init_monorepo(&mutSettings::default())?;
341+
342+
run_cmd!(
343+
echo two > two;
344+
)?;
345+
346+
Command::cargo_bin("cog")?
347+
.arg("bump")
348+
.arg("--auto")
349+
.arg("--dry-run")
350+
.assert()
351+
.failure();
352+
353+
Ok(())
354+
}
355+
356+
#[sealed_test]
357+
fnuncommited_changes_should_not_throw_error_with_option() ->Result<()>{
358+
letmut settings =Settings{
359+
skip_untracked:true,
360+
..Default::default()
361+
};
362+
363+
init_monorepo(&mut settings)?;
364+
365+
run_cmd!(
366+
echo two > two;
367+
echo"other changes" > one/file;
368+
)?;
369+
370+
Command::cargo_bin("cog")?
371+
.arg("bump")
372+
.arg("--auto")
373+
.arg("--dry-run")
374+
.assert()
375+
.success()
376+
.stdout(indoc!("Untracked files :\n\tmodified: one/file\n\tnew: two\n\nnothing added to commit but untracked files present (use\"git add\" to track)\n\none-0.1.0\n0.1.0\n"));
377+
378+
assert_that!(Path::new("CHANGELOG.md")).does_not_exist();
379+
assert_tag_does_not_exist("1.1.0")?;
380+
Ok(())
381+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp