-
Notifications
You must be signed in to change notification settings - Fork 1k
[WIP] Add project initialization warnings to dep init cmd #798
[WIP] Add project initialization warnings to dep init cmd #798
Conversation
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed, please reply here (e.g.
|
I signed it |
e19b78a
to
e2ee00b
Compare
CLAs look good, thanks! |
Thanks for an initiative to fix/discuss this issue. I'm not sure if we should warn or do anything when dep is run in a sub directory. I see dep works similar to git, which too doesn't care about creating a git repo inside an existing one. Doing If we do it, and considering the PR, how about printing the warning message and ask the user to use a force flag ( |
@darkowlzz Sam has said previously that FYI, I haven't reviewed this PR yet, hoping to get to that today. |
bump - need me on this? |
facepalm Sorry, no this just fell through the cracks on my part... |
@sdboyer : Your input would be helpful! As @darkowlzz mentioned, if our goal was to mirror the behaviors of |
Sorry that I took so long to review this! This PR is solving multiple things: determining if we are running dep init is a subpackage instead of the root package, and also if dep has been run before in another directory. The original issue (#193) was only about the former. I am inclined to not check for existing dep config in subdirs upon init, @sdboyer? Just looking at how we can tell if we are running
If we can determine a project root, and it doesn't match the import path, then we should display a warning that this init may not work, but then try anyway. The warning you have in this scenario seems just right. I really don't want to introduce a force flag, keeping it only as a warning that can help the user just in case the init didn't go right. |
i don't think of this is as actually being our goal - i just use it as a convenient shorthand when explaining to people roughly what we do need to be able to facilitate initializing a project not at a repo root, for a variety of reasons (including some that @carolynvs and i heard about yesterday on a call with k8s folks). i'd also prefer to avoid a |
Dep was officially deprecated earlier this year, and the proposal to archive this repository was accepted. As such, I'm closing outstanding issues before archiving the repository. For any further comments, please use the proposal thread on the Go issue tracker. Thanks! |
Note that I still need to write tests for my solution.
What does this do / why do we need it?
To provide general guidance around new project initialization using the
dep init
command. That is, display warnings to the user when initializing a project in a project subdirectory, or within a subdirectory of an already initialized project.For example, given the following project structure:
Running
dep init
inA/
will be print out the following warning to the console:If we were to run the command in
A/
in an already initialized project, the following warning(s) will be observed:What should your reviewer look out for in this PR?
SplitAbsoluteProjectRoot()
andDeduceProjectRoot()
as a solution.dep init
is executed in a project subdirectory as defined incheckInSubdir()
.Which issue(s) does this PR fix?
Fixes #193