forge
Clone
https://git.tahinli.com/Tahinli/forge.git
0 watching0 forksRustAGPL-3.07.1 MiB490f099Tahinli7 hours ago322 commits
| 1 | //! Merging a pull request: the merge gate, the merge itself and what follows it, shared by the |
| 2 | //! merge page, auto-merge and the merge queue. |
| 3 | |
| 4 | use ; |
| 5 | use StatusState; |
| 6 | use ; |
| 7 | use ; |
| 8 | use |
| 9 | |
| 10 | |
| 11 | ; |
| 12 | use repo_path; |
| 13 | use StatusCode; |
| 14 | |
| 15 | use cratetrigger_maintenance; |
| 16 | use crate; |
| 17 | use crateafter_ref_update; |
| 18 | use crateAppState; |
| 19 | use cratenow_unix; |
| 20 | use crate; |
| 21 | |
| 22 | /// Commits listed in a squash message. |
| 23 | pub const MAX_SQUASH_COMMITS: usize = 250; |
| 24 | |
| 25 | /// Refusal codes, sent as `?merge_error=<code>` on the pull request page. The page owns the |
| 26 | /// wording for each code; a code outside this set is never echoed back. |
| 27 | pub const ERR_CONFLICT: &str = "conflict"; |
| 28 | pub const ERR_UP_TO_DATE: &str = "up_to_date"; |
| 29 | pub const ERR_FF_IMPOSSIBLE: &str = "ff_impossible"; |
| 30 | pub const ERR_BASE_MOVED: &str = "base_moved"; |
| 31 | pub const ERR_HEAD_MOVED: &str = "head_moved"; |
| 32 | pub const ERR_ALREADY_MERGED: &str = "already_merged"; |
| 33 | pub const ERR_NOT_OPEN: &str = "not_open"; |
| 34 | pub const ERR_HEAD_MISSING: &str = "head_missing"; |
| 35 | pub const ERR_BASE_MISSING: &str = "base_missing"; |
| 36 | pub const ERR_MESSAGE_INVALID: &str = "message_invalid"; |
| 37 | pub const ERR_NEEDS_APPROVALS: &str = "needs_approvals"; |
| 38 | pub const ERR_CHANGES_REQUESTED: &str = "changes_requested"; |
| 39 | pub const ERR_NOT_UP_TO_DATE: &str = "not_up_to_date"; |
| 40 | pub const ERR_DRAFT: &str = "draft"; |
| 41 | pub const ERR_NEEDS_CHECKS: &str = "needs_checks"; |
| 42 | pub const ERR_REBASE_CONFLICT: &str = "rebase_conflict"; |
| 43 | pub const ERR_AUTO_MERGE_BLOCKED: &str = "auto_merge_blocked"; |
| 44 | pub const ERR_QUEUE_REQUIRED: &str = "queue_required"; |
| 45 | pub const ERR_QUEUE_ALREADY: &str = "queue_already"; |
| 46 | |
| 47 | pub const REBASE_CONFLICT_MSG: &str = "Rebase failed: a commit does not apply cleanly on the base branch. Resolve the conflicts or use another merge style."; |
| 48 | pub const CONFLICTS_MSG: &str = "This branch has conflicts that must be resolved"; |
| 49 | pub const MOVED_MSG: &str = "The base branch moved; reload and try again."; |
| 50 | pub const UP_TO_DATE_MSG: &str = |
| 51 | "Nothing to merge: the head is already contained in the base branch."; |
| 52 | pub const FF_MSG: &str = |
| 53 | "fast-forward not possible: the base branch has commits the head does not contain"; |
| 54 | pub const ALREADY_MERGED_MSG: &str = "This pull request is already merged."; |
| 55 | pub const CLOSED_MSG: &str = "This pull request is closed."; |
| 56 | pub const HEAD_MISSING_MSG: &str = |
| 57 | "The head repository was deleted, so this pull request cannot be merged."; |
| 58 | pub const BASE_MISSING_MSG: &str = "The base branch does not exist."; |
| 59 | |
| 60 | /// What a merge attempt did: the base branch now points at `commit`, or the attempt was refused |
| 61 | /// with an HTTP status and a message for the viewer. |
| 62 | |
| 63 | |
| 64 | |
| 65 | |
| 66 | |
| 67 | |
| 68 | /// The refusal code for a message `perform_merge` returns, if it has one. |
| 69 | |
| 70 | |
| 71 | |
| 72 | |
| 73 | |
| 74 | |
| 75 | |
| 76 | |
| 77 | |
| 78 | |
| 79 | |
| 80 | |
| 81 | |
| 82 | |
| 83 | |
| 84 | |
| 85 | |
| 86 | |
| 87 | |
| 88 | |
| 89 | |
| 90 | |
| 91 | /// Whether `user` is a reviewer whose approvals and change requests count under merge rules: |
| 92 | /// the repo owner, an instance admin, or a collaborator with Write, Maintain or Admin. |
| 93 | |
| 94 | |
| 95 | |
| 96 | |
| 97 | |
| 98 | |
| 99 | /// The base branch's merge rule for a pull request, with the facts that rule checks. |
| 100 | |
| 101 | |
| 102 | |
| 103 | |
| 104 | |
| 105 | |
| 106 | |
| 107 | |
| 108 | |
| 109 | |
| 110 | |
| 111 | |
| 112 | |
| 113 | |
| 114 | |
| 115 | /// One required status check and where it stands on the pull request head. |
| 116 | |
| 117 | |
| 118 | |
| 119 | |
| 120 | |
| 121 | |
| 122 | |
| 123 | |
| 124 | |
| 125 | |
| 126 | |
| 127 | |
| 128 | |
| 129 | |
| 130 | |
| 131 | |
| 132 | |
| 133 | |
| 134 | |
| 135 | |
| 136 | |
| 137 | |
| 138 | |
| 139 | |
| 140 | |
| 141 | |
| 142 | |
| 143 | |
| 144 | |
| 145 | |
| 146 | |
| 147 | |
| 148 | |
| 149 | |
| 150 | |
| 151 | |
| 152 | |
| 153 | |
| 154 | |
| 155 | |
| 156 | |
| 157 | |
| 158 | |
| 159 | |
| 160 | |
| 161 | |
| 162 | /// Evaluates the effective rule for the pull request's base branch. Approvals and change requests |
| 163 | /// count only from `counts_for_merge_rules` reviewers, using each reviewer's latest review; an |
| 164 | /// approval counts only while the head is the commit it was given on. |
| 165 | /// Repo admins are not exempt. A base branch that does not exist counts as up to date; the merge |
| 166 | /// itself reports that. |
| 167 | pub async |
| 168 | |
| 169 | |
| 170 | |
| 171 | |
| 172 | |
| 173 | |
| 174 | |
| 175 | |
| 176 | |
| 177 | |
| 178 | |
| 179 | |
| 180 | |
| 181 | |
| 182 | |
| 183 | |
| 184 | |
| 185 | |
| 186 | |
| 187 | |
| 188 | |
| 189 | |
| 190 | |
| 191 | |
| 192 | |
| 193 | |
| 194 | |
| 195 | |
| 196 | |
| 197 | |
| 198 | |
| 199 | |
| 200 | |
| 201 | |
| 202 | |
| 203 | |
| 204 | |
| 205 | |
| 206 | |
| 207 | |
| 208 | |
| 209 | |
| 210 | |
| 211 | |
| 212 | |
| 213 | |
| 214 | |
| 215 | |
| 216 | |
| 217 | |
| 218 | |
| 219 | |
| 220 | |
| 221 | |
| 222 | |
| 223 | |
| 224 | |
| 225 | |
| 226 | |
| 227 | |
| 228 | |
| 229 | |
| 230 | |
| 231 | |
| 232 | |
| 233 | /// Merges `pr` into its base branch in `repo` as `viewer`. |
| 234 | /// |
| 235 | /// The base tip is `expected_base` when given, otherwise the current tip of the base branch. The |
| 236 | /// merge is checked and built against that tip, and the ref moves only if it still points there. |
| 237 | /// `message` replaces the default commit message (not used by fast-forward). Refusals that the |
| 238 | /// viewer can act on come back as `MergeOutcome::Refused`; git and database failures are errors. |
| 239 | pub async |
| 240 | |
| 241 | |
| 242 | |
| 243 | |
| 244 | |
| 245 | |
| 246 | |
| 247 | |
| 248 | |
| 249 | |
| 250 | |
| 251 | |
| 252 | |
| 253 | |
| 254 | |
| 255 | |
| 256 | |
| 257 | |
| 258 | |
| 259 | |
| 260 | |
| 261 | |
| 262 | |
| 263 | |
| 264 | |
| 265 | |
| 266 | |
| 267 | |
| 268 | |
| 269 | |
| 270 | |
| 271 | |
| 272 | |
| 273 | |
| 274 | |
| 275 | |
| 276 | /// The commit that merging `pr` into `base_tip` makes in `style`, committed as `committer`. No ref |
| 277 | /// moves. A refusal the caller can act on comes back as the inner `Err`. Fast-forward returns the |
| 278 | /// head itself. |
| 279 | pub async |
| 280 | |
| 281 | |
| 282 | |
| 283 | |
| 284 | |
| 285 | |
| 286 | |
| 287 | |
| 288 | |
| 289 | |
| 290 | |
| 291 | |
| 292 | |
| 293 | |
| 294 | |
| 295 | |
| 296 | |
| 297 | |
| 298 | |
| 299 | |
| 300 | |
| 301 | |
| 302 | |
| 303 | |
| 304 | |
| 305 | |
| 306 | |
| 307 | |
| 308 | |
| 309 | |
| 310 | |
| 311 | |
| 312 | |
| 313 | |
| 314 | |
| 315 | |
| 316 | |
| 317 | |
| 318 | |
| 319 | |
| 320 | |
| 321 | |
| 322 | |
| 323 | |
| 324 | |
| 325 | |
| 326 | |
| 327 | |
| 328 | |
| 329 | |
| 330 | |
| 331 | |
| 332 | |
| 333 | |
| 334 | |
| 335 | |
| 336 | |
| 337 | |
| 338 | |
| 339 | |
| 340 | |
| 341 | |
| 342 | |
| 343 | |
| 344 | |
| 345 | |
| 346 | |
| 347 | |
| 348 | |
| 349 | |
| 350 | |
| 351 | |
| 352 | |
| 353 | |
| 354 | |
| 355 | |
| 356 | |
| 357 | |
| 358 | |
| 359 | |
| 360 | |
| 361 | |
| 362 | |
| 363 | |
| 364 | |
| 365 | |
| 366 | |
| 367 | |
| 368 | |
| 369 | |
| 370 | |
| 371 | |
| 372 | |
| 373 | /// The work after a merge moved `refname` from `base_tip` to `new`: the pull request is marked |
| 374 | /// merged, its events and notifications go out, and the ref update runs its post-update work. |
| 375 | /// Failures here are logged, not reported: the merge is already in place. |
| 376 | pub async |
| 377 | |
| 378 | |
| 379 | |
| 380 | |
| 381 | |
| 382 | |
| 383 | |
| 384 | |
| 385 | |
| 386 | |
| 387 | |
| 388 | |
| 389 | |
| 390 | |
| 391 | |
| 392 | |
| 393 | |
| 394 | |
| 395 | |
| 396 | |
| 397 | |
| 398 | |
| 399 | |
| 400 | |
| 401 | |
| 402 | |
| 403 | |
| 404 | |
| 405 | |
| 406 | /// The address written into a commit for `user`: their email, or a noreply address on this |
| 407 | /// instance's host when they have none. |
| 408 | |
| 409 | |
| 410 | |
| 411 | |
| 412 | |
| 413 | |
| 414 | |
| 415 | |
| 416 | |
| 417 | |
| 418 | |
| 419 | |
| 420 | |
| 421 | |
| 422 | |
| 423 | |
| 424 | |
| 425 | |
| 426 | |
| 427 | |
| 428 | |
| 429 | |
| 430 | |
| 431 | |
| 432 | /// `Merge pull request #N from owner/branch`, a blank line, then the pull request title. |
| 433 | pub async |
| 434 | |
| 435 | |
| 436 | |
| 437 | |
| 438 | |
| 439 | |
| 440 | |
| 441 | |
| 442 | |
| 443 | |
| 444 | |
| 445 | |
| 446 | |
| 447 | |
| 448 | |
| 449 | |
| 450 | |
| 451 | |
| 452 | |
| 453 | |
| 454 | |
| 455 | /// `<title> (#N)`, a blank line, then one `- <summary>` line per commit, oldest first. |
| 456 | |
| 457 | |
| 458 | |
| 459 | |
| 460 | |
| 461 | |
| 462 | |
| 463 | |
| 464 |