robfig / glock

MIT License
230 stars 27 forks source link

support for single repository layouts #21

Closed insasho closed 9 years ago

insasho commented 9 years ago

(Warning: This is mostly a copy of a similar feature request filed for godep: https://github.com/tools/godep/issues/43)

glock and other Go dependency management tools share a strong opinion about how the source tree of a project is managed. Our repository (and the repository of the last two startups I worked at) contains the entire source tree (and more). This allows us to have a company-wide Makefile that implements various policies and procedures useful to our workflow, and allows stuff related to the project to be stored in the same git repo (ex: Vagrantfiles). Also, we have a policy where all of our code must use the same dependencies. This layout is similar to Google's internal layout, or any other company that has a single-repository policy.

I recognize that this is not the "recommended" layout as described in the Go documentation but it is a layout that offers many benefits and is common in corporate environments.

In summary, our single GOPATH git repository structure:

/
/ops
/go      # this is $GOPATH
/go/src/company.com/proj1
/go/src/company.com/proj2

glock seems incompatible with this structure because it expects the .git directory to be at the same level of the package. However, in the example above, / contains .git and the src/company.com/proj1 directory does not.

I would be happy to use a single GLOCKFILE for all Go projects in the repository, but glock as implemented doesn't support this behavior.

Thanks.

robfig commented 9 years ago

Please give this a shot and let me know if it works for you.

Cheers, Rob

insasho commented 8 years ago

Sorry for being late to get to this, but I still care about this (I've just been lucky that deps haven't bitten me too badly yet..). The issue isn't so much that we want a GLOCKFILE in a particular location, but that we want a single set of dependencies for all of our company's subpackages in a git repository that happens to not be rooted in the package directory. Either $GOPATH/GLOCKFILE or $GOPATH/src/company.com/GLOCKFILE would make sense to us.

Our directory structure looks like this:

/          # this is the git root of our repo
/.git
/ops       # vagrant, ansible, jenkins, etc etc
/go        # this is $GOPATH
/go/.gitignore
/go/src/github.com/revel/...
/go/src/company.com/package1
/go/src/company.com/package2

I'd like to be able to run glock save company.com and have all of the dependencies from all of the dependencies of company.com/... tracked in a single GLOCKFILE. We have a .gitignore in /go/src/ to exclude from committing anything other than our company.com directory:

# Exclude 3rd party packages
src/*
# ... but include company.com
!src/company.com

Unfortunately glock seems to want all the packages under company.com to have their own repositories. Example:

$ bin/glock save company.com
no version control directory found for "company.com/common/mail/message"

It seems reasonable that if I'm asking "foo.com" to be tracked that "foo.com/project" wouldn't need to have its own version control directory.

Is this expected behavior, or am I missing something?

Thanks!

boljen commented 7 years ago

I faced the same issue, the cause appears to be the domain name extension.

It doesn't work with:

src/company.com

It does work with:

src/company