Skip to content

Commit

Permalink
Fixed support for +incompatible modules. (#107)
Browse files Browse the repository at this point in the history
Fixes #100

Signed-off-by: Bartlomiej Plotka <bwplotka@gmail.com>
  • Loading branch information
bwplotka authored Dec 21, 2021
1 parent 38a0f49 commit a4e7297
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 9 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ We use *breaking* word for marking changes that are not backward compatible (rel

## Unreleased

## [v0.5.2](https://github.com/bwplotka/bingo/releases/tag/v0.5.2) - 2021.12.21

### Fixed

* Fixed support for modules / packages with upper case in it and Go 1.17 logic.
* Fixed support for modules with +incompatible version.

## [v0.5.1](https://github.com/bwplotka/bingo/releases/tag/v0.5.1) - 2021.07.20

### Added
Expand Down
33 changes: 24 additions & 9 deletions get.go
Original file line number Diff line number Diff line change
Expand Up @@ -476,13 +476,14 @@ func resolveInGoModCache(logger *log.Logger, verbose bool, update runner.GetUpda
}() {
modMetaDir := filepath.Join(modMetaCache, lookupModulePath, "@v")
if _, err := os.Stat(modMetaDir); err != nil {
if os.IsNotExist(err) {
if verbose {
logger.Println("resolveInGoModCache:", modMetaDir, "directory does not exists")
}
continue
if !os.IsNotExist(err) {
return err
}
return err
if verbose {
logger.Println("resolveInGoModCache:", modMetaDir, "directory does not exists")
}
continue

}
if verbose {
logger.Println("resolveInGoModCache: Found", modMetaDir, "directory")
Expand All @@ -506,14 +507,28 @@ func resolveInGoModCache(logger *log.Logger, verbose bool, update runner.GetUpda
// Look for .info files that have exact version or sha.
if strings.HasPrefix(target.Module.Version, "v") {
if _, err := os.Stat(filepath.Join(modMetaDir, target.Module.Version+".info")); err != nil {
if os.IsNotExist(err) {
if !os.IsNotExist(err) {
return err
}

if verbose {
logger.Println("resolveInGoModCache:", filepath.Join(modMetaDir, target.Module.Version+".info"),
"file not exists. Looking for +incompatible info file")
}

// Try +incompatible.
if _, err := os.Stat(filepath.Join(modMetaDir, target.Module.Version+"+incompatible.info")); err != nil {
if !os.IsNotExist(err) {
return err
}

if verbose {
logger.Println("resolveInGoModCache:", filepath.Join(modMetaDir, target.Module.Version+".info"),
logger.Println("resolveInGoModCache:", filepath.Join(modMetaDir, target.Module.Version+"+incompatible.info"),
"file not exists. Looking for different module")
}
continue
}
return err
target.Module.Version += "+incompatible"
}
target.Module.Path = modulePath
target.RelPath = strings.TrimPrefix(strings.TrimPrefix(target.RelPath, target.Module.Path), "/")
Expand Down
5 changes: 5 additions & 0 deletions pkg/bingo/mod.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,11 @@ func (mf *ModFile) DirectPackage() *Package {

// Flush saves all changes made to parsed syntax and reloads the parsed file.
func (mf *ModFile) Flush() error {
if mf.m == nil {
// Nothing to flush.
// Happens when previous flush had errors.
return nil
}
newB := modfile.Format(mf.m.Syntax)
if err := mf.f.Truncate(0); err != nil {
return errors.Wrap(err, "truncate")
Expand Down

0 comments on commit a4e7297

Please sign in to comment.