Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
walkowif committed Feb 9, 2024
1 parent 9968fad commit 7ee9305
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
19 changes: 11 additions & 8 deletions cmd/renv.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,20 +241,15 @@ func UpdateRepositoryPackages(renvLock *RenvLock, updatePackageRegexp string,
log.Trace("Package ", k, " matches updated packages regexp ",
updatePackageRegexp)
var repositoryPackagesFile PackagesFile
var notFoundRepositoryName string
repositoryName := v.Repository
repositoryPackagesFile, ok := packagesFiles[repositoryName]
if !ok {
// Package coming from a repository not defined in the lockfile.
// Check which of the defined repositories has the latest version of that package.
notFoundRepositoryName := repositoryName
repositoryName := GetLatestPackageVersionFromAnyRepository(k, packagesFiles)
notFoundRepositoryName = repositoryName
repositoryName = GetLatestPackageVersionFromAnyRepository(k, packagesFiles)
repositoryPackagesFile = packagesFiles[repositoryName]
log.Warn(
"Repository ", notFoundRepositoryName, " referenced by package ", k,
"has not been defined in the lockfile. Therefore, the package will be updated to ",
"the version found in ", repositoryName, " which contains the latest version of this ",
"package among the repositories defined in the lockfile.",
)
}
var newPackageVersion string
for _, singlePackage := range repositoryPackagesFile.Packages {
Expand All @@ -269,6 +264,14 @@ func UpdateRepositoryPackages(renvLock *RenvLock, updatePackageRegexp string,
}
if entry, ok := renvLock.Packages[k]; ok {
if newPackageVersion != entry.Version {
if notFoundRepositoryName != "" {
log.Warn(
"Repository ", notFoundRepositoryName, " referenced by package ", k,
"has not been defined in the lockfile. Therefore, the package will be updated to ",
"the version found in ", repositoryName, " which contains the latest version of this ",
"package among the repositories defined in the lockfile.",
)
}
log.Info("Updating package ", k, " version: ",
entry.Version, " → ", newPackageVersion)
entry.Version = newPackageVersion
Expand Down
4 changes: 2 additions & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ var rootCmd *cobra.Command

func newRootCommand() {
rootCmd = &cobra.Command{
Use: "locksmith",
Use: "locksmith",
Short: "renv.lock generator",
Long: `locksmith is a utility to generate renv.lock file containing all dependencies
of given set of R packages. Given the input list of git repositories containing the R packages,
Expand Down Expand Up @@ -154,7 +154,7 @@ in an renv.lock-compatible file.`,
rootCmd.AddCommand(extension.NewVersionCobraCmd())

cfg := envy.CobraConfig{
Prefix: "LOCKSMITH",
Prefix: "LOCKSMITH",
Persistent: true,
}
envy.ParseCobra(rootCmd, cfg)
Expand Down

0 comments on commit 7ee9305

Please sign in to comment.