unison-cli-0.0.0
Safe HaskellSafe-Inferred
LanguageHaskell2010

Unison.Cli.ProjectUtils

Description

Project-related utilities.

Synopsis

Project/path helpers

resolveProjectBranch :: ProjectAndBranch (Maybe ProjectName) (Maybe ProjectBranchName) -> Cli (ProjectAndBranch Project ProjectBranch) Source #

Expect/resolve branch reference with the following rules:

  1. If the project is missing, use the current project.
  2. If we have an unambiguous `branch` or `projectbranch`, resolve it using the current project, defaulting to main if branch is unspecified.

resolveProjectBranchInProject :: Project -> ProjectAndBranch (Maybe ProjectName) (Maybe ProjectBranchName) -> Cli (ProjectAndBranch Project ProjectBranch) Source #

Expect/resolve branch reference with the following rules:

  1. If the project is missing, use the provided project.
  2. If we have an unambiguous `branch` or `projectbranch`, resolve it using the provided project, defaulting to main if branch is unspecified.

Name hydration

Loading local project info

getProjectBranchCausalHash :: ProjectBranch -> Transaction CausalHash Source #

Get the causal hash of a project branch.

Loading remote project info

expectRemoteProjectById :: RemoteProjectId -> ProjectName -> Cli RemoteProject Source #

Expect a remote project by id. Its latest-known name is also provided, for error messages.

Projecting out common things

Other helpers

expectLatestReleaseBranchName :: RemoteProject -> Cli ProjectBranchName Source #

Expect the given remote project to have a latest release, and return it as a valid branch name.

Merge/upgrade branch utils

getMergeBranchParent :: ProjectBranch -> Maybe ProjectBranchId Source #

getMergeBranchParent branch returns the parent branch of a "merge" branch.

When a merge fails, we put you on a branch called `merge-source-into-target`. That's a "merge" branch. It's not currently distinguished in the database, so we first just switch on whether its name begins with "merge-". If it does, then we get the branch's parent, which should exist, but perhaps wouldn't if the user had manually made a parentless branch called "merge-whatever" for whatever reason.

getUpgradeBranchParent :: ProjectBranch -> Maybe ProjectBranchId Source #

getUpgradeBranchParent branch returns the parent branch of an "upgrade" branch.

When an upgrade fails, we put you on a branch called `upgrade-old-to-new`. That's an "upgrade" branch. It's not currently distinguished in the database, so we first just switch on whether its name begins with "upgrade-". If it does, then we get the branch's parent, which should exist, but perhaps wouldn't if the user had manually made a parentless branch called "upgrade-whatever" for whatever reason.