Skip to content

Commit

Permalink
Use enum directly for ScheduleType
Browse files Browse the repository at this point in the history
Summary: EZ

Differential Revision: D58769679

fbshipit-source-id: e570c2a0af1ad8be40df09d99a2d38c689ee8546
  • Loading branch information
Xiang Gao authored and facebook-github-bot committed Jun 20, 2024
1 parent acb88d1 commit 8b921e9
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions td_util/src/schedules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,13 @@ use serde::Deserialize;
use serde::Serialize;

lazy_static! {
static ref CHANGESET_SCHEDULE_TYPES: HashSet<&'static str> =
HashSet::from(["diff", "landcastle", "master", "postcommit", "relbranch"]);
static ref CHANGESET_SCHEDULE_TYPES: HashSet<ScheduleType> = HashSet::from([
ScheduleType::Diff,
ScheduleType::Landcastle,
ScheduleType::Master,
ScheduleType::Postcommit,
ScheduleType::Relbranch,
]);
}

#[derive(
Expand Down Expand Up @@ -52,13 +57,14 @@ pub enum ScheduleType {
Greenwarden,
Disabled,
Master,
Relbranch,
}

impl ScheduleType {
/// Mobile build TDs use schedule_type to decide whether we need to run build for changeset (e.g. diff and landcastle)
/// See UTD implementation: <https://fburl.com/code/wfps6pag>
pub fn is_changeset_schedule_type(&self) -> bool {
CHANGESET_SCHEDULE_TYPES.contains(self.to_string().as_str())
CHANGESET_SCHEDULE_TYPES.contains(self)
}
}

Expand Down

0 comments on commit 8b921e9

Please sign in to comment.