robfig / glock

MIT License
230 stars 27 forks source link

Aliasing imports. #15

Closed birkirb closed 7 years ago

birkirb commented 10 years ago

Great tool you've made. I really like the single file listing and the cmd feature. A problem I'm having is when I have to patch a 3rd party dependency (i.e. fork, fix and update). To check out the right repo, I need to change the path in the GLOCKFILE and that will further necessitate a change in all my import paths. Anyway to alias the import path to the original library, even if I work with a fork?

robfig commented 10 years ago

Forks for me always divide into two situations:

For long-lived forks, I think that changing the GLOCKFILE and rewriting your imports to use it is appropriate.

For short-lived forks, I add my fork as a remote to the primary repo location (so that I don't have to rewrite imports to have my code use the change locally), and when the main repo merges the change, then I update the GLOCKFILE so that others on the team get the change.

This article describes that flow pretty well http://blog.campoy.cat/2014/03/github-and-go-forking-pull-requests-and.html

Does that address your use case?

Thanks for using Glock!

birkirb commented 10 years ago

This makes sense, and I've pretty much been using the short-lived forks approach for most things. However I don't always know from the outset if I'll have a long or short lived forks, and inevitably I'll have to share the build dependencies with other team members before this.

Even for medium/long-lived forks, rewriting imports can be a challenge. I have a patch for revel that brings a-feature-I-really-need-right-now-but-isnt-on-the-roadmap-until-next-release-or-the-release-after-that, and for a library like revel changing all the import statements is a non-trivial task (and affects many of the tools used), especially since I really would like to get up to date once said feature is out.

I've only seen a few of dependency managers (https://github.com/mattn/gom, https://github.com/vube/depman, https://github.com/nitrous-io/goop) that support some kind of workaround for these situations, but they have other deficiencies that kept me from going with them.

robfig commented 10 years ago

It seems like it would be complicated for Glock to support that use case. (The ability to specify a destination directory different from the natural location)

It sounds like a large part of the difficulty you have is the rewriting-imports step. Maybe addressing that would be the easiest thing? I believe that there are dedicated programs for that, but doesn't a simple find-replace of the full import paths

birkirb commented 10 years ago

For something like revel, it's not just import paths, but template paths, modules etc... I have a work around for now, but will seek some permanent solution. It could be something as simple as manually specifying the clone command... but granted, perhaps not your itch at the moment.