Explorer

core.branch-status-of

description
The status of a branch (not main): the newest of the status changes by its creator (project_branch_status) and the merges of its latest snapshot into main (which mean done). In progress if there is neither. A change at the same time as a merge wins. See docs/branch.md
type
Fn(
  project_name: String,
  branch: String,
  creator_account_id: String,
  latest_event_hash: String,
  records: List<@core.branch-status-record>,
  merges: List<@core.branch-merge>
) -> @core.branch-status
expression
fn(project_name$0, branch$1, creator_account_id$2, latest_event_hash$3, records$4, merges$5) =>
  let explicit$6 = @core.list-fold(
      T: @core.branch-status-record,
      A: Union{#none, #some(@core.branch-status-record)},
      reducer: fn(acc$7, item$8) =>
        match @core.and(
            left: @core.and(
              left: @core.equal(left: $8.change.project_name, right: $0),
              right: @core.equal(left: $8.change.branch, right: $1)
            ),
            right: @core.equal(left: $8.account_id, right: $2)
          ) {
          false =>
            $7,
          true =>
            match $7 {
              #none(_) =>
                #some($8),
              #some(found$9) =>
                match @core.less-than(left: $9.time, right: $8.time) {
                  true =>
                    #some($8),
                  false =>
                    $7
                }
            }
        },
      init: #none,
      xs: $4
    );
  let merged$10 = @core.list-fold(
      T: @core.branch-merge,
      A: Union{#none, #some(Number)},
      reducer: fn(acc$11, item$12) =>
        match @core.and(
            left: @core.equal(left: $12.project_name, right: $0),
            right: @core.equal(left: $12.merged_commit_hash, right: $3)
          ) {
          false =>
            $11,
          true =>
            match $11 {
              #none(_) =>
                #some($12.time),
              #some(time$13) =>
                match @core.less-than(left: $12.time, right: $13) {
                  true =>
                    #some($12.time),
                  false =>
                    $11
                }
            }
        },
      init: #none,
      xs: $5
    );
  match $10 {
    #none(_) =>
      match $6 {
        #none(_) =>
          #in_progress<@core.branch-status>,
        #some(record$14) =>
          $14.change.status
      },
    #some(merged_time$15) =>
      match $6 {
        #none(_) =>
          #done<@core.branch-status>,
        #some(record$16) =>
          match @core.less-than(left: $16.time, right: $15) {
            true =>
              #done<@core.branch-status>,
            false =>
              $16.change.status
          }
      }
  }
visibility
public
core.branch-status-of (project definy, branch main, snapshot l0VFjJZP174d8CbZWFoujAGTYjgsQu4uTq5uWCZaXgo)
id: su_aq7OPxjmSX3mUvaCNhmfzjK_SUgDZ4cRwFa4g4yc
content hash: SGMHQ6YlZqEd2VKa9G4Q010JFPOECTDplnJLCSBKsT4