-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Synchronize dependencies with another package and link to vendor directory #48
Synchronize dependencies with another package and link to vendor directory #48
Conversation
…he map The rewrite map is built recursively scanning the root package dependencies. If two packages in the tree imported the same dependency with different hash the last one to be processed would overwrite the first one. Include a flag in `buildRewriteMapping` to signal when the root package dependencies are being process and allow them to overwrite the map (adding an overwrite flag in `addRewriteForDep`) but don't allow the inverse (transitive dependencies overwriting direct ones). This change has as a side effect that in a scenario where transitive dependencies with different versions were overwriting each other that won't be allowed now, changing in fact the rewrite map, but that would happen only in the already problematic scenario of dependencies with mismatched versions.
(This patch changes the current API.) The previous behavior of `gx-go link` linked packages to the global workspace in `$GOPATH/gx/ipfs/` and affected any packages that would depend on it. Use the Go vendor directory to link packages locally. That implies an explicit parent-dependency relationship where a dependency package is now linked to the vendor directory of a particular parent package (instead of linking it to any package that might depended on that dependency specific hash). Using the vendor directory allows the import paths to remain the same (Go will look in that directory before looking in the `$GOPATH` where the global Gx workspace is located).
Add `--sync` flag that in the case a dependency of the parent package has a version mismatch with a dependency of the linked package it will replace the second with the first. (Most of the implementation logic for this feature had to be added to the `post-install` hook which also has a new `--sync` flag.)
(Each commit should be looked at separately.) |
} | ||
|
||
dvcsimport := GxDvcsImport(&pkg) | ||
target := filepath.Join(srcdir, dvcsimport) | ||
target := filepath.Join(gxSrcDir, dvcsImport) | ||
|
||
uwcmd := exec.Command("gx-go", "uw") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If --sync
was used during the link process we may need to un-write with --fix
.
The --fix
could be added in the unlink for all cases as a general precautionary measure (at the cost of more processing time when it may not be needed, but to simplify the code as much as possible and do not add any sync detection logic).
@@ -53,21 +53,47 @@ unlinked QmVGtdTZdTFaLsaj2RwdVG8jcjNNcp1DE914DKZ2kHmXHw /home/user/go/src/github | |||
Name: "a,all", | |||
Usage: "Remove all existing symlinks and reinstate the gx packages. Use with -r.", | |||
}, | |||
cli.StringFlag{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't add this flag. Instead, we could add a top-level -C
flag (like git
) but we can probably do that later.
|
||
if parentPackagePath == "" { | ||
var err error | ||
parentPackagePath, err = os.Getwd() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should probably use gxutil.GetPackageRoot()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Fixed in the new PR.)
Closing in favor of #51. |
Built on top of #47 (should be merged first).
Closes #46.