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.

Export fields so we can use dot-notation

data ProjectBranch #

A project branch.

Instances

Instances details
Generic ProjectBranch 
Instance details

Defined in U.Codebase.Sqlite.ProjectBranch

Associated Types

type Rep ProjectBranch :: Type -> Type #

Show ProjectBranch 
Instance details

Defined in U.Codebase.Sqlite.ProjectBranch

Eq ProjectBranch 
Instance details

Defined in U.Codebase.Sqlite.ProjectBranch

FromRow ProjectBranch 
Instance details

Defined in U.Codebase.Sqlite.ProjectBranch

ToRow ProjectBranch 
Instance details

Defined in U.Codebase.Sqlite.ProjectBranch

Methods

toRow :: ProjectBranch -> [SQLData] #

Pathy ProjectPath 
Instance details

Defined in Unison.Codebase.ProjectPath

From ProjectPath Text 
Instance details

Defined in Unison.Codebase.ProjectPath

Methods

from :: ProjectPath -> Text #

type Rep ProjectBranch 
Instance details

Defined in U.Codebase.Sqlite.ProjectBranch

type Rep ProjectBranch = D1 ('MetaData "ProjectBranch" "U.Codebase.Sqlite.ProjectBranch" "unison-codebase-sqlite-0.0.0-K7IzWXvt8n58rD901TQF1T" 'False) (C1 ('MetaCons "ProjectBranch" 'PrefixI 'True) ((S1 ('MetaSel ('Just "projectId") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 ProjectId) :*: S1 ('MetaSel ('Just "branchId") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 ProjectBranchId)) :*: (S1 ('MetaSel ('Just "name") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 ProjectBranchName) :*: S1 ('MetaSel ('Just "parentBranchId") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Maybe ProjectBranchId)))))

data Project #

A project.

Constructors

Project 

Instances

Instances details
Generic Project 
Instance details

Defined in U.Codebase.Sqlite.Project

Associated Types

type Rep Project :: Type -> Type #

Methods

from :: Project -> Rep Project x #

to :: Rep Project x -> Project #

Show Project 
Instance details

Defined in U.Codebase.Sqlite.Project

Eq Project 
Instance details

Defined in U.Codebase.Sqlite.Project

Methods

(==) :: Project -> Project -> Bool #

(/=) :: Project -> Project -> Bool #

FromRow Project 
Instance details

Defined in U.Codebase.Sqlite.Project

ToRow Project 
Instance details

Defined in U.Codebase.Sqlite.Project

Methods

toRow :: Project -> [SQLData] #

Pathy ProjectPath 
Instance details

Defined in Unison.Codebase.ProjectPath

From ProjectPath Text 
Instance details

Defined in Unison.Codebase.ProjectPath

Methods

from :: ProjectPath -> Text #

type Rep Project 
Instance details

Defined in U.Codebase.Sqlite.Project

type Rep Project = D1 ('MetaData "Project" "U.Codebase.Sqlite.Project" "unison-codebase-sqlite-0.0.0-K7IzWXvt8n58rD901TQF1T" 'False) (C1 ('MetaCons "Project" 'PrefixI 'True) (S1 ('MetaSel ('Just "projectId") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 ProjectId) :*: S1 ('MetaSel ('Just "name") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 ProjectName)))