Skip to content

Commit 3fdb0c7

Browse files
perryqhjackboberg
authored andcommitted
skipping codeowner file validation when generate-and-validate
1 parent 2fdee9d commit 3fdb0c7

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,13 @@ fn cli() -> Result<(), Error> {
114114
let ownership = Ownership::build(Project::build(&project_root, &codeowners_file_path, &config).change_context(Error::Io)?);
115115

116116
match args.command {
117-
Command::Validate => ownership.validate().change_context(Error::ValidationFailed)?,
117+
Command::Validate => ownership.validate(false).change_context(Error::ValidationFailed)?,
118118
Command::Generate => {
119119
std::fs::write(codeowners_file_path, ownership.generate_file()).change_context(Error::Io)?;
120120
}
121121
Command::GenerateAndValidate => {
122122
std::fs::write(codeowners_file_path, ownership.generate_file()).change_context(Error::Io)?;
123-
ownership.validate().change_context(Error::ValidationFailed)?
123+
ownership.validate(true).change_context(Error::ValidationFailed)?
124124
}
125125
Command::ForFile { name } => {
126126
let file_owners = ownership.for_file(&name).change_context(Error::Io)?;

src/ownership.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,15 @@ impl Ownership {
8686
}
8787

8888
#[instrument(level = "debug", skip_all)]
89-
pub fn validate(&self) -> Result<(), ValidatorErrors> {
89+
pub fn validate(&self, skip_codeowners_file_validation: bool) -> Result<(), ValidatorErrors> {
9090
info!("validating file ownership");
9191
let validator = Validator {
9292
project: self.project.clone(),
9393
mappers: self.mappers(),
9494
file_generator: FileGenerator { mappers: self.mappers() },
9595
};
9696

97-
validator.validate()
97+
validator.validate(skip_codeowners_file_validation)
9898
}
9999

100100
#[instrument(level = "debug", skip_all)]

src/ownership/validator.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ pub struct Errors(Vec<Error>);
3636

3737
impl Validator {
3838
#[instrument(level = "debug", skip_all)]
39-
pub fn validate(&self) -> Result<(), Errors> {
39+
pub fn validate(&self, skip_codeowners_file_validation: bool) -> Result<(), Errors> {
4040
let mut validation_errors = Vec::new();
4141

4242
debug!("validate_invalid_team");
@@ -45,8 +45,10 @@ impl Validator {
4545
debug!("validate_file_ownership");
4646
validation_errors.append(&mut self.validate_file_ownership());
4747

48-
debug!("validate_codeowners_file");
49-
validation_errors.append(&mut self.validate_codeowners_file());
48+
if !skip_codeowners_file_validation {
49+
debug!("validate_codeowners_file");
50+
validation_errors.append(&mut self.validate_codeowners_file());
51+
}
5052

5153
if validation_errors.is_empty() {
5254
Ok(())

0 commit comments

Comments
 (0)