Skip to content

Add rollup mode management #221

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 11, 2025
Merged
Show file tree
Hide file tree
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

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions migrations/20250307150834_add_rollup_to_pr.down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- Add up migration script here
ALTER TABLE pull_request DROP COLUMN rollup;
2 changes: 2 additions & 0 deletions migrations/20250307150834_add_rollup_to_pr.up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- Add up migration script here
ALTER TABLE pull_request ADD COLUMN rollup TEXT;
43 changes: 43 additions & 0 deletions src/bors/command/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
mod parser;
use std::fmt;
use std::str::FromStr;

use crate::github::CommitSha;
pub use parser::{CommandParseError, CommandParser};

Expand All @@ -22,6 +25,42 @@ pub enum Approver {
Specified(String),
}

const ROLLUP_VALUES: [&str; 4] = ["always", "iffy", "maybe", "never"];

#[derive(Copy, Clone, Debug, PartialEq)]
pub enum RollupMode {
Always,
Iffy,
Maybe,
Never,
}

impl fmt::Display for RollupMode {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let s = match self {
RollupMode::Always => "always",
RollupMode::Iffy => "iffy",
RollupMode::Never => "never",
RollupMode::Maybe => "maybe",
};
write!(f, "{}", s)
}
}

impl FromStr for RollupMode {
type Err = ();

fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"always" => Ok(RollupMode::Always),
"iffy" => Ok(RollupMode::Iffy),
"never" => Ok(RollupMode::Never),
"maybe" => Ok(RollupMode::Maybe),
_ => Err(()),
}
}
}

/// Bors command specified by a user.
#[derive(Debug, PartialEq)]
pub enum BorsCommand {
Expand All @@ -31,6 +70,8 @@ pub enum BorsCommand {
approver: Approver,
/// Priority of the commit.
priority: Option<Priority>,
// Rollup status of the commit.
rollup: Option<RollupMode>,
},
/// Unapprove a commit.
Unapprove,
Expand All @@ -53,4 +94,6 @@ pub enum BorsCommand {
Delegate,
/// Revoke any previously granted delegation.
Undelegate,
/// Rollup status.
Rollup(RollupMode),
}
Loading