Skip to content

Commit

Permalink
Allow build directives to bypass schedule type if they match directly.
Browse files Browse the repository at this point in the history
Summary:
https://fb.workplace.com/groups/td.users/posts/3312160132413316/?comment_id=3312215952407734&reply_comment_id=3312238032405526

Mobile users want to make sure their diff didn't break a build that is normally NOT landblocking

Reviewed By: aniketmathur

Differential Revision: D56031572

fbshipit-source-id: 19c63fcbe68c46d4e05a363c0874901bd99a4b37
  • Loading branch information
Aaron Ho authored and facebook-github-bot committed Apr 11, 2024
1 parent 911985d commit 7d5147a
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions td_util/src/directives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,18 @@ pub fn get_app_specific_build_directives(directives: &Option<Vec<String>>) -> Op
pub fn app_specific_build_directives_matches_name(
app_specific_build_directives: &Option<Vec<String>>,
name: &String,
exactly: bool,
) -> bool {
app_specific_build_directives
.as_ref()
.map_or(false, |app_specific_build_directives| {
app_specific_build_directives
.iter()
.any(|directive| name.starts_with(directive))
app_specific_build_directives.iter().any(|directive| {
if exactly {
name == directive
} else {
name.starts_with(directive)
}
})
})
}

Expand Down Expand Up @@ -78,19 +83,22 @@ mod tests {
]);
assert!(app_specific_build_directives_matches_name(
&app_specific_build_directives,
&"directive1".to_string()
&"directive1".to_string(),
true
));
assert!(!app_specific_build_directives_matches_name(
&app_specific_build_directives,
&"directive4".to_string()
&"directive4".to_string(),
true
));
}
#[test]
fn test_app_specific_build_directives_contains_name_none() {
let app_specific_build_directives = None;
assert!(!app_specific_build_directives_matches_name(
&app_specific_build_directives,
&"directive1".to_string()
&"directive1".to_string(),
true
));
}

Expand All @@ -103,7 +111,8 @@ mod tests {
]);
assert!(app_specific_build_directives_matches_name(
&app_specific_build_directives,
&"directive1234".to_string()
&"directive1234".to_string(),
false
));
}
}

0 comments on commit 7d5147a

Please sign in to comment.