Documentation
¶
Overview ¶
Package rust implements omnibump support for Rust projects. Ported from cargobump with enhancements for the unified omnibump architecture.
Package rust implements omnibump support for Rust projects. Ported from cargobump with enhancements for the unified omnibump architecture.
Package rust implements omnibump support for Rust projects. Ported from cargobump with enhancements for the unified omnibump architecture.
Index ¶
- Variables
- func CargoUpdate(ctx context.Context, cargoRoot string) (string, error)
- func CargoUpdatePackage(ctx context.Context, name, oldVersion, newVersion, cargoRoot string) (string, error)
- func DoUpdate(ctx context.Context, packages map[string]*Package, ...) error
- func GetCargoLockPath(cargoRoot string) (string, error)
- func LatestCrateVersion(ctx context.Context, pkg string) (string, error)
- func ParseBumpFile(r io.Reader) (map[string]*Package, error)
- type CargoPackage
- type Lockfile
- type Package
- type PackageList
- type Rust
- func (r *Rust) Detect(ctx context.Context, dir string) (bool, error)
- func (r *Rust) GetManifestFiles() []string
- func (r *Rust) Name() string
- func (r *Rust) SupportsAnalysis() bool
- func (r *Rust) Update(ctx context.Context, cfg *languages.UpdateConfig) error
- func (r *Rust) Validate(ctx context.Context, cfg *languages.UpdateConfig) error
- type RustAnalyzer
- func (ra *RustAnalyzer) Analyze(ctx context.Context, projectPath string) (*analyzer.AnalysisResult, error)
- func (ra *RustAnalyzer) AnalyzeRemote(ctx context.Context, files map[string][]byte) (*analyzer.RemoteAnalysisResult, error)
- func (ra *RustAnalyzer) RecommendStrategy(ctx context.Context, analysis *analyzer.AnalysisResult, ...) (*analyzer.Strategy, error)
- type UpdateConfig
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidCrateName is returned when a crate name is invalid. ErrInvalidCrateName = errors.New("invalid crate name") // ErrInvalidVersion is returned when a version string is invalid. ErrInvalidVersion = errors.New("invalid version string") )
var ( // ErrCargoLockNotFound is returned when Cargo.lock is not found. ErrCargoLockNotFound = errors.New("cargo.lock not found") // ErrRemoteAnalysisNotImplemented is returned when remote analysis is not implemented. ErrRemoteAnalysisNotImplemented = errors.New("remote analysis not yet implemented") )
var ErrAmbiguousTarget = errors.New("crate resolves to multiple versions")
ErrAmbiguousTarget is returned when a bare crate name resolves to multiple present versions, so the caller must pin one explicitly as name@<version>.
var ErrCrateNotFound = errors.New("crate not found in crates.io index")
ErrCrateNotFound is returned when the crates.io index has no entry for a crate.
var ErrInvalidPackageSpec = errors.New("invalid package spec")
ErrInvalidPackageSpec is returned when a package spec is missing required fields.
var ErrNoCompatibleVersion = errors.New("no compatible version can be upgraded to")
ErrNoCompatibleVersion is returned when a crate is pinned below the requested floor by a dependent's caret constraint and so cannot be upgraded to a compatible version. This is a genuine failure: omnibump must not silently pass.
var ErrNoMatchingVersion = errors.New("no published version satisfies the constraint")
ErrNoMatchingVersion is returned when no published version of a crate satisfies the requested SemVer constraint.
var ErrUnexpectedIndexStatus = errors.New("unexpected status from crates.io index")
ErrUnexpectedIndexStatus is returned when the crates.io index responds with an unexpected (non-200, non-404) HTTP status.
Functions ¶
func CargoUpdate ¶
CargoUpdate runs 'cargo update' to refresh the Cargo.lock file. Ported from cargobump/pkg/run/cargo.go.
func CargoUpdatePackage ¶
func CargoUpdatePackage(ctx context.Context, name, oldVersion, newVersion, cargoRoot string) (string, error)
CargoUpdatePackage updates a specific package to a precise version. Uses: cargo update --precise <newVersion> --package <name>@<oldVersion> Ported from cargobump/pkg/run/cargo.go.
func DoUpdate ¶
func DoUpdate(ctx context.Context, packages map[string]*Package, cargoPackages []CargoPackage, cfg *UpdateConfig) error
DoUpdate performs the actual update of Rust package dependencies. Ported from cargobump/pkg/update.go.
func GetCargoLockPath ¶ added in v0.17.0
GetCargoLockPath returns the path to Cargo.lock in the given cargo root directory.
func LatestCrateVersion ¶ added in v0.18.6
LatestCrateVersion queries the crates.io index for the crate referenced by `pkg` and returns its latest published version within the SemVer constraint. A bare crate name ("rand") returns the highest stable version overall (e.g. 0.10.1); a pinned name ("rand@0.9.0") returns the highest stable version in that caret-compatible line (e.g. 0.9.4). Yanked and pre-release versions are ignored. Returns ErrNoMatchingVersion when no version qualifies.
The constraint comes from the `@version` only; any `=precise` component of a "name@from=to" arg is ignored.
Types ¶
type CargoPackage ¶
CargoPackage represents a package from Cargo.lock.
func GetCurrentPackages ¶ added in v0.17.0
func GetCurrentPackages(ctx context.Context, cargoRoot string) ([]CargoPackage, error)
GetCurrentPackages parses Cargo.lock to get the current packages.
func ParseCargoLock ¶
func ParseCargoLock(r io.Reader) ([]CargoPackage, error)
ParseCargoLock parses a Cargo.lock file and returns the list of packages.
func (CargoPackage) IsLocal ¶ added in v0.20.0
func (c CargoPackage) IsLocal() bool
IsLocal reports whether the package is the local/workspace crate itself rather than an external dependency. Local crates have no Source in Cargo.lock, whereas registry, git, and remote-path dependencies always carry one.
type Lockfile ¶
type Lockfile struct {
Packages []cargoLockPackage `toml:"package"`
}
Lockfile represents a Cargo.lock file structure. Based on https://doc.rust-lang.org/cargo/reference/manifest.html
type PackageList ¶
type PackageList struct {
Packages []Package `json:"packages" yaml:"packages"`
}
PackageList is used to marshal from yaml/json file to get the list of packages.
type Rust ¶
type Rust struct{}
Rust implements the Language interface for Rust projects.
func (*Rust) GetManifestFiles ¶
GetManifestFiles returns Rust manifest files.
func (*Rust) SupportsAnalysis ¶
SupportsAnalysis returns true since Rust now has analysis capabilities.
type RustAnalyzer ¶
type RustAnalyzer struct {
// contains filtered or unexported fields
}
RustAnalyzer implements the Analyzer interface for Rust projects.
func (*RustAnalyzer) Analyze ¶
func (ra *RustAnalyzer) Analyze(ctx context.Context, projectPath string) (*analyzer.AnalysisResult, error)
Analyze performs dependency analysis on a Rust project.
func (*RustAnalyzer) AnalyzeRemote ¶
func (ra *RustAnalyzer) AnalyzeRemote(ctx context.Context, files map[string][]byte) (*analyzer.RemoteAnalysisResult, error)
AnalyzeRemote performs dependency analysis on remotely-fetched Rust files. Not yet implemented for Rust - returns error. TODO: Implement this function and use ctx for logging and files for analysis.
func (*RustAnalyzer) RecommendStrategy ¶
func (ra *RustAnalyzer) RecommendStrategy(ctx context.Context, analysis *analyzer.AnalysisResult, deps []analyzer.Dependency) (*analyzer.Strategy, error)
RecommendStrategy suggests update strategy for Rust dependencies. For Rust, updates are always direct using cargo update.
type UpdateConfig ¶
type UpdateConfig struct {
CargoRoot string
Update bool // Run 'cargo update' before updating packages
ShowDiff bool
}
UpdateConfig holds configuration for Rust project updates.