gps

package
v0.5.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 13, 2019 License: BSD-3-Clause Imports: 44 Imported by: 0

Documentation

Overview

Package gps is a Go packaging solver library.

Index

Constants

This section is empty.

Variables

View Source
var ErrSourceManagerIsReleased = fmt.Errorf("this SourceManager has been released, its methods can no longer be called")

ErrSourceManagerIsReleased is the error returned by any SourceManager method called after the SourceManager has been released, rendering its methods no longer safe to call.

Functions

func IsAny

func IsAny(c Constraint) bool

IsAny indicates if the provided constraint is the wildcard "Any" constraint.

func PruneProject

func PruneProject(baseDir string, lp LockedProject, options PruneOptions) error

PruneProject remove excess files according to the options passed, from the lp directory in baseDir.

func SortForDowngrade

func SortForDowngrade(vl []Version)

SortForDowngrade sorts a slice of []Version in roughly ascending order, so that presumably older versions are visited first.

This is *not* the same as reversing SortForUpgrade (or you could simply sort.Reverse()). The type precedence is the same, including the semver vs. semver-with-prerelease relation. Lexicographical comparisons within non-semver tags, branches, and revisions remains the same as well; because we treat these domains as having no ordering relation, there can be no real concept of "upgrade" vs "downgrade", so there is no reason to reverse them.

Thus, the only binary relation that is reversed for downgrade is within-type comparisons for semver.

So, given a slice of the following versions:

  • Branch: master devel
  • Semver tags: v1.0.0, v1.1.0, v1.1.0-alpha1
  • Non-semver tags: footag
  • Revision: f6e74e8d

Sorting for downgrade will result in the following slice:

[v1.0.0 v1.1.0 v1.1.0-alpha1 footag devel master f6e74e8d]

func SortForUpgrade

func SortForUpgrade(vl []Version)

SortForUpgrade sorts a slice of []Version in roughly descending order, so that presumably newer versions are visited first. The rules are:

  • All semver versions come first, and sort mostly according to the semver 2.0 spec (as implemented by github.com/Masterminds/semver lib), with one exception:
  • Semver versions with a prerelease are after *all* non-prerelease semver. Within this subset they are sorted first by their numerical component, then lexicographically by their prerelease version.
  • The default branch(es) is next; the exact semantics of that are specific to the underlying source.
  • All other branches come next, sorted lexicographically.
  • All non-semver versions (tags) are next, sorted lexicographically.
  • Revisions, if any, are last, sorted lexicographically. Revisions do not typically appear in version lists, so the only invariant we maintain is determinism - deeper semantics, like chronology or topology, do not matter.

So, given a slice of the following versions:

  • Branch: master devel
  • Semver tags: v1.0.0, v1.1.0, v1.1.0-alpha1
  • Non-semver tags: footag
  • Revision: f6e74e8d

Sorting for upgrade will result in the following slice:

[v1.1.0 v1.0.0 v1.1.0-alpha1 master devel footag f6e74e8d]

func SortPairedForDowngrade

func SortPairedForDowngrade(vl []PairedVersion)

SortPairedForDowngrade has the same behavior as SortForDowngrade, but operates on []PairedVersion types.

func SortPairedForUpgrade

func SortPairedForUpgrade(vl []PairedVersion)

SortPairedForUpgrade has the same behavior as SortForUpgrade, but operates on []PairedVersion types.

func ValidateParams

func ValidateParams(params SolveParameters, sm SourceManager) error

ValidateParams validates the solver parameters to ensure solving can be completed.

func VersionComponentStrings

func VersionComponentStrings(v Version) (revision string, branch string, version string)

VersionComponentStrings decomposes a Version into the underlying number, branch and revision.

func WriteDepTree

func WriteDepTree(basedir string, l Lock, sm SourceManager, co CascadingPruneOptions, onWrite func(WriteProgress)) error

WriteDepTree takes a basedir, a Lock and a RootPruneOptions and exports all the projects listed in the lock to the appropriate target location within basedir.

If the goal is to populate a vendor directory, basedir should be the absolute path to that vendor directory, not its parent (a project root, typically).