syntax = "proto2";

package janitor;

enum Mode {
    // Push changes directly to the packaging repository
    push = 1;

    // Propose the changes in a pull request
    propose = 2;

    // Attempt to push the changes, but if that fails, create a pull request
    // instead.
    attempt_push = 3;

    // Build the package, but don't propose/push the changes.
    build_only = 4;

    // Create bug in the BTS with patch attached.
    bts = 5;

    // Don't even build
    skip = 6;
}

enum ReviewPolicy {
    not_required = 1;

    required = 2;

    // TODO(jelmer): perhaps support optional post-landing review for QA purposes?
};

enum NotifyMode {
    no_notification = 0;

    email = 1;

    // TODO(jelmer): support debianbts
};

message Match {
    // Maintainer e-mail
    repeated string maintainer = 1;

    // Uploader e-mail
    repeated string uploader = 2;

    // Source package name
    repeated string source_package = 3;

    // Source package VCS URL
    repeated string vcs_url_regex = 4;

    // Match on whether the package is present in the base distribution
    optional bool in_base = 5;

    // Match before a particular stage of the release is reached.
    optional string before_stage = 6;
}

message PublishPolicy {
    optional Mode mode = 1;

    optional int32 max_frequency_days = 3;

    optional string role = 2 [ default = "main" ];
}

message CampaignPolicy {
    // Name of the campaign
    optional string name = 1;

    optional string command = 2;

    optional ReviewPolicy qa_review = 5;

    repeated PublishPolicy publish = 4;

    optional NotifyMode broken_notify = 6 [ default=no_notification ];
};

message Environment {
    optional string name = 1;
    optional string value = 2;
};

message Policy {
    repeated Match match = 1;

    repeated Environment env = 3;

    repeated CampaignPolicy campaign = 4;
}

message PolicyConfig {
    repeated Policy policy = 1;
    optional string freeze_dates_url = 2;
}
