Explorer

core.check-event-branch

description
Branch rules of a project snapshot: only the creator of a branch can take snapshots on it, and the parent is the latest snapshot of the branch. A new branch starts from a snapshot of the project, and the first branch of a project is main without a parent. See docs/branch.md
type
Fn(commit: @core.project-snapshot, state: @core.event-check-state) -> List<@core.event-rejection>
expression
fn(commit$0, state$1) =>
  match $1.branch_latest_commit_hash {
    #some(latest$2) =>
      @core.list-concat(
        left: match $1.is_branch_creator {
          true =>
            [],
          false =>
            [#not_branch_creator<@core.event-rejection>]
        },
        right: match @core.option-string-same(a: $0.parent_commit_hash, b: $1.branch_latest_commit_hash) {
          true =>
            [],
          false =>
            [#parent_commit_mismatch<@core.event-rejection>]
        }
      ),
    #none(_) =>
      match $1.project_has_commits {
        true =>
          match $1.parent_in_project {
            true =>
              [],
            false =>
              [#parent_commit_mismatch<@core.event-rejection>]
          },
        false =>
          @core.list-concat(
            left: match @core.equal(left: $0.branch, right: "main") {
              true =>
                [],
              false =>
                [#first_branch_must_be_main<@core.event-rejection>]
            },
            right: match match $0.parent_commit_hash {
                #none(_) =>
                  true,
                #some(p$9) =>
                  false
              } {
              true =>
                [],
              false =>
                [#parent_commit_mismatch<@core.event-rejection>]
            }
          )
      }
  }
visibility
public
core.check-event-branch (project definy, branch auto-release, snapshot oiQgPqhJm-TbM4kexXeRHBaJB_tS7gwBSewII64P-44)
id: GcA0De0WrJZy13txpcjKhOHGInKswySnazN9JUzlcs4
content hash: P1kCTEdBPqAyH8lUwcg81KjKJbwrn3Yy2pUMVdguOVI