Skip to content
This repository was archived by the owner on Sep 9, 2020. It is now read-only.

Document lock.go and manifest.go #692

Merged
merged 1 commit into from
Jun 2, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions lock.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,16 @@ import (
"github.com/pkg/errors"
)

// LockName is the lock file name used by dep.
const LockName = "Gopkg.lock"

// Lock holds lock file data and implements gps.Lock.
type Lock struct {
SolveMeta SolveMeta
P []gps.LockedProject
}

// SolveMeta holds solver meta data.
type SolveMeta struct {
InputsDigest []byte
AnalyzerName string
Expand Down Expand Up @@ -109,10 +112,12 @@ func fromRawLock(raw rawLock) (*Lock, error) {
return l, nil
}

// InputHash returns the hash of inputs which produced this lock data.
func (l *Lock) InputHash() []byte {
return l.SolveMeta.InputsDigest
}

// Projects returns the list of LockedProjects contained in the lock data.
func (l *Lock) Projects() []gps.LockedProject {
return l.P
}
Expand Down Expand Up @@ -146,11 +151,10 @@ func (l *Lock) toRaw() rawLock {
raw.Projects[k] = ld
}

// TODO sort output - #15

return raw
}

// MarshalTOML serializes this lock into TOML via an intermediate raw form.
func (l *Lock) MarshalTOML() ([]byte, error) {
raw := l.toRaw()
result, err := toml.Marshal(raw)
Expand Down Expand Up @@ -180,6 +184,7 @@ func LockFromSolution(in gps.Solution) *Lock {
return l
}

// SortedLockedProjects implements sort.Interface.
type SortedLockedProjects []gps.LockedProject

func (s SortedLockedProjects) Len() int { return len(s) }
Expand Down
8 changes: 8 additions & 0 deletions manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ import (
"github.com/pkg/errors"
)

// ManifestName is the manifest file name used by dep.
const ManifestName = "Gopkg.toml"

// Manifest holds manifest file data and implements gps.RootManifest.
type Manifest struct {
Constraints gps.ProjectConstraints
Ovr gps.ProjectConstraints
Expand Down Expand Up @@ -226,6 +228,7 @@ func (s sortedRawProjects) Less(i, j int) bool {
return l.Source < r.Source
}

// MarshalTOML serializes this manifest into TOML via an intermediate raw form.
func (m *Manifest) MarshalTOML() ([]byte, error) {
raw := m.toRaw()
result, err := toml.Marshal(raw)
Expand Down Expand Up @@ -262,19 +265,23 @@ func toRawProject(name gps.ProjectRoot, project gps.ProjectProperties) rawProjec
return raw
}

// DependencyConstraints returns a list of project-level constraints.
func (m *Manifest) DependencyConstraints() gps.ProjectConstraints {
return m.Constraints
}

// TestDependencyConstraints remains unimplemented by returning nil for now.
func (m *Manifest) TestDependencyConstraints() gps.ProjectConstraints {
// TODO decide whether we're going to incorporate this or not
return nil
}

// Overrides returns a list of project-level override constraints.
func (m *Manifest) Overrides() gps.ProjectConstraints {
return m.Ovr
}

// IgnoredPackages returns a set of import paths to ignore.
func (m *Manifest) IgnoredPackages() map[string]bool {
if len(m.Ignored) == 0 {
return nil
Expand All @@ -288,6 +295,7 @@ func (m *Manifest) IgnoredPackages() map[string]bool {
return mp
}

// RequiredPackages returns a set of import paths to require.
func (m *Manifest) RequiredPackages() map[string]bool {
if len(m.Required) == 0 {
return nil
Expand Down