Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.
| Merge rulesets: branch and tag rules, agent-first, enforced on push and merge | 1 | //! The rules engine: which rulesets hold for a branch or tag, and whether a |
| 2 | //! change to it meets them. | |
| 3 | //! | |
| 4 | //! Everything here is pure: the work service (merges, and where rulesets | |
| 5 | //! are kept) and the repos service (pushes, and every other change to a | |
| 6 | //! branch or tag) gather the facts and ask. The types are in | |
| 7 | //! `g1t_contracts::rules`. | |
| 8 | //! | |
| 9 | //! - [`select`]: which rulesets hold in a repository and for a name, who | |
| 10 | //! may bypass them, and the effective rules of one branch. | |
| 11 | //! - [`push`]: judging a push, or a branch created, deleted or renamed. | |
| 12 | //! - [`merge`]: judging a pull request's merge, and what the active rules | |
| 13 | //! ask of g1t's lifecycle and merge queue ([`merge::requirements`]). | |
| 14 | //! - [`content`]: rules about what commits bring, for both. | |
| 15 | //! - [`validate`]: whether a ruleset can be saved. | |
| 16 | //! - [`legacy`]: branch protection as it was, as a ruleset. | |
| 17 | //! - [`report`]: what git and people are told. | |
| 18 | ||
| 19 | pub mod content; | |
| 20 | pub mod glob; | |
| 21 | pub mod legacy; | |
| 22 | pub mod merge; | |
| 23 | pub mod outcome; | |
| 24 | pub mod push; | |
| 25 | pub mod report; | |
| 26 | pub mod select; | |
| 27 | pub mod text; | |
| 28 | pub mod validate; | |
| 29 | pub mod window; | |
| 30 | ||
| 31 | pub use outcome::Judged; | |
| 32 | pub use select::{ActorFacts, RepoFacts, Who}; | |
| 33 | ||
| 34 | use g1t_contracts::rules::{Action, NewEvaluation}; | |
| 35 | ||
| 36 | /// The evaluations to record for a change: one per ruleset that holds. | |
| 37 | pub fn evaluations( | |
| 38 | judged: &[Judged], | |
| 39 | repo_id: &str, | |
| 40 | workspace: &str, | |
| 41 | action: Action, | |
| 42 | actor: &ActorFacts, | |
| 43 | number: Option<u32>, | |
| 44 | sha: Option<&str>, | |
| 45 | ) -> Vec<NewEvaluation> { | |
| 46 | judged | |
| 47 | .iter() | |
| 48 | .map(|one| NewEvaluation { | |
| 49 | repo_id: repo_id.to_owned(), | |
| 50 | workspace: workspace.to_lowercase(), | |
| 51 | ruleset_id: one.id.clone(), | |
| 52 | ruleset_name: one.name.clone(), | |
| 53 | enforcement: one.enforcement, | |
| 54 | action, | |
| 55 | git_ref: one.git_ref.clone(), | |
| 56 | actor: actor.username.clone(), | |
| 57 | actor_kind: actor.kind.as_str().to_owned(), | |
| 58 | verdict: one.verdict(), | |
| 59 | violations: one.violations.clone(), | |
| 60 | number, | |
| 61 | sha: sha.map(str::to_owned), | |
| 62 | }) | |
| 63 | .collect() | |
| 64 | } |
This file's history is long; its oldest lines are credited to the oldest commit read.