Skip to content
This repository has been archived by the owner on Sep 9, 2020. It is now read-only.

Commit

Permalink
dep: Catch DeltaWriter diff bookkeeping errors
Browse files Browse the repository at this point in the history
Relates to #1945.

While this doesn't fix the issue, it at least prevents a panic from
occurring that blows up a `dep ensure` run, and should give us enough
information to debug it if/when someone runs into it.
  • Loading branch information
sdboyer committed Jul 20, 2018
1 parent 22dc1dd commit 68441f7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/glossary.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ The root import path for a project. A project root is defined as:
* For the current project, the location of the `Gopkg.toml` file defines the project root
* For dependencies, the root of the network [source](#source) (VCS repository) is treated as the project root

These are generally one and the same, though not always. When using dep inside a monorepo, multiple `Gopkg.toml` files may exist at subpaths for discrete projects, designating each of those import paths as Project Roots. This works fine when working directly on those projects. If, however, any project not in the repository seeks to import the monorepo, dep will treat the monorepo's as one big Project, with the root directory being the Project Root; it will disregard any and all `Gopkg.toml` files in subdirectories.
These are generally one and the same, though not always. When using dep inside a monorepo, multiple `Gopkg.toml` files may exist at subpaths for discrete projects, designating each of those import paths as Project Roots. This works fine when working directly on those projects. If, however, any project not in the repository seeks to import the monorepo, dep will treat the monorepo as one big Project, with the root directory being the Project Root; it will disregard any and all `Gopkg.toml` files in subdirectories.

This may also be referred to as the "import root" or "root import path."

Expand Down
10 changes: 9 additions & 1 deletion txn_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,15 @@ func (dw *DeltaWriter) Write(path string, sm gps.SourceManager, examples bool, l
}

to := filepath.FromSlash(filepath.Join(vnewpath, string(pr)))
po := projs[pr].(verify.VerifiableProject).PruneOpts
po, has := projs[pr].(verify.VerifiableProject).PruneOpts
if !has {
// This shouldn't be reachable, but it's preferable to print an
// error and continue rather than panic. https://github.com/golang/dep/issues/1945
// TODO(sdboyer) remove this once we've increased confidence around
// this case.
fmt.Fprintf(os.Stderr, "Internal error - %s had change code %v but was not in new Gopkg.lock. Re-running dep ensure should fix this. Please file a bug!\n", pr, reason)
continue
}
if err := sm.ExportPrunedProject(context.TODO(), projs[pr], po, to); err != nil {
return errors.Wrapf(err, "failed to export %s", pr)
}
Expand Down
1 change: 1 addition & 0 deletions website/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"daily-dep": "Daily Dep",
"deduction": "Import Path Deduction",
"ensure-mechanics": "Models and Mechanisms",
"env-vars": "Environment Variables",
"failure-modes": "Failure Modes",
"FAQ": "FAQ",
"glossary": "Glossary",
Expand Down

0 comments on commit 68441f7

Please sign in to comment.