Skip to content
Open
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
10 changes: 10 additions & 0 deletions src/bin/pr-metadata-validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ async fn main() {
expected_files_pattern,
} => &format!("{}`{}`", WRONG_FILES, expected_files_pattern),
ValidationResult::NoFiles => NO_FILES,
ValidationResult::TooManyFiles => TOO_MANY_FILES,
};

let full_message = format!(
Expand Down Expand Up @@ -145,6 +146,10 @@ const NO_FILES: &str = r#"This PR is missing any submitted files.

Please check that you committed the right files and pushed to the repository"#;

const TOO_MANY_FILES: &str = r#"There are too many files comitted in this pull request.

Please check and make sure you have not accidentally comitted a cache, virtual environment, or npm package directory."#;

#[derive(strum_macros::Display)]
enum ValidationResult {
Ok,
Expand All @@ -154,6 +159,7 @@ enum ValidationResult {
UnknownRegion,
WrongFiles { expected_files_pattern: String },
NoFiles,
TooManyFiles,
}

async fn validate_pr(
Expand Down Expand Up @@ -307,6 +313,10 @@ async fn check_pr_file_changes(
return Ok(ValidationResult::NoFiles); // no files committed
}

if pr_files.len() > 100 {
return Ok(ValidationResult::TooManyFiles); // too many files probably a venv or npm cache
}

// check each file and error if one is in unexpected place
for pr_file in pr_files {
if pr_file.filename == ".gitignore" {
Expand Down