opam

package
v0.4.4 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

opam parses, modifies, and updates dependencies in opam files

Specialized to using pin-depends with git dependencies. These require maintaining the indirect pin-depends (which opam ignores). This package also implements updating these dependencies to the latest git commit.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindOpamPackage

func FindOpamPackage(gitURL, commit string) (string, error)

FindOpamPackage tries to find the unique opam package in a repository at a specific commit. Returns the package name (without .opam extension) if a unique opam file is found.

Types

type OpamFile

type OpamFile struct {
	Lines []string
	// contains filtered or unexported fields
}

func Parse

func Parse(r io.Reader) (*OpamFile, error)

func (*OpamFile) AddDependency

func (f *OpamFile) AddDependency(packageName string)

AddDependency adds a new dependency to the depends block. If the dependency already exists, it does nothing. The dependency is added without version constraints.

func (*OpamFile) AddPinDepend

func (f *OpamFile) AddPinDepend(dep PinDepend)

AddPinDepend adds or updates a pin-depends entry in the opam file. If an entry for the package already exists, it will be replaced. If the package is in the indirect section, it will be removed from there. If no pin-depends block exists in the file, the function returns without changes. The new entry is added immediately after the "pin-depends: [" line if it doesn't already exist.

func (*OpamFile) ExtendCommitHashes added in v0.4.0

func (f *OpamFile) ExtendCommitHashes() error

ExtendCommitHashes extends any abbreviated commit hashes in direct pin-depends to full hashes.

func (*OpamFile) GetDependencies

func (f *OpamFile) GetDependencies() []string

GetDependencies returns all dependencies listed in the depends block, ignoring version constraints. Returns just the package names.

func (*OpamFile) GetIndirect

func (f *OpamFile) GetIndirect() []PinDepend

func (*OpamFile) GetPinDepends

func (f *OpamFile) GetPinDepends() []PinDepend

GetPinDepends returns all direct pin-depends (excluding indirect dependencies).

func (*OpamFile) SetIndirect

func (f *OpamFile) SetIndirect(indirects []PinDepend)

func (*OpamFile) String

func (f *OpamFile) String() string

String returns the opam file as a string

func (*OpamFile) UpdateIndirectDependencies

func (f *OpamFile) UpdateIndirectDependencies() (bool, error)

UpdateIndirectDependencies updates the indirect dependencies of an opam file. It also extends any abbreviated commit hashes to full hashes.

It returns true if the indirect dependencies were updated, false otherwise.

type PinDepend

type PinDepend struct {
	Package string // package name (e.g., rocq-iris)
	URL     string // URL (always has git+https protocol)
	Commit  string // commit hash
}

func (*PinDepend) BaseUrl

func (dep *PinDepend) BaseUrl() string

func (*PinDepend) ExtendCommitHash added in v0.4.0

func (dep *PinDepend) ExtendCommitHash() (bool, error)

ExtendCommitHash resolves an abbreviated commit hash to a full hash. If the commit is already 40 characters (full hash), it returns without change. Returns true if the hash was extended, false otherwise.

func (*PinDepend) FetchDependencies

func (dep *PinDepend) FetchDependencies() ([]PinDepend, error)

FetchDependencies fetches the (transitive) dependencies of a package. It fetches the package's opam file at the specified git commit and returns its pin-depends.

func (*PinDepend) Normalize

func (dep *PinDepend) Normalize() *PinDepend

Normalize fixes dep.

Returns dep.

func (PinDepend) String

func (dep PinDepend) String() string

String formats a PinDepend as an opam pin-depends line

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL