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 ¶
- func FindOpamPackage(gitURL, commit string) (string, error)
- type OpamFile
- func (f *OpamFile) AddDependency(packageName string)
- func (f *OpamFile) AddPinDepend(dep PinDepend)
- func (f *OpamFile) ExtendCommitHashes() error
- func (f *OpamFile) GetDependencies() []string
- func (f *OpamFile) GetIndirect() []PinDepend
- func (f *OpamFile) GetPinDepends() []PinDepend
- func (f *OpamFile) SetIndirect(indirects []PinDepend)
- func (f *OpamFile) String() string
- func (f *OpamFile) UpdateIndirectDependencies() (bool, error)
- type PinDepend
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FindOpamPackage ¶
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 (*OpamFile) AddDependency ¶
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 ¶
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
ExtendCommitHashes extends any abbreviated commit hashes in direct pin-depends to full hashes.
func (*OpamFile) GetDependencies ¶
GetDependencies returns all dependencies listed in the depends block, ignoring version constraints. Returns just the package names.
func (*OpamFile) GetIndirect ¶
func (*OpamFile) GetPinDepends ¶
GetPinDepends returns all direct pin-depends (excluding indirect dependencies).
func (*OpamFile) SetIndirect ¶
func (*OpamFile) UpdateIndirectDependencies ¶
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) ExtendCommitHash ¶ added in v0.4.0
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 ¶
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.