-
Notifications
You must be signed in to change notification settings - Fork 1k
Conversation
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). 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 (or fixed any issues), please reply here (e.g. What to do if you already signed the CLAIndividual signers
Corporate signers
|
1 similar comment
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). 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 (or fixed any issues), please reply here (e.g. What to do if you already signed the CLAIndividual signers
Corporate signers
|
7c0d5d6
to
078c630
Compare
Please note that I should be covered by a company CLA between Intel and Google. Let me know if you need more details to find that CLA. |
Wow. Who'dve thought there'd be yet another reason i'd hate git submodules. If you could provide a bit more info on the Intel<>Google CLA, that'd be helpful - being that i'm not a Google employee, i don't have ready access to that information, and i'd rather not trip over anything here.
On OSX, yes. i'm not sure about Windows. That tests pass on appveyor suggests it's probably fine, but if you can think of any way to test this reasonably easily, it would be helpful. Also, a CHANGELOG entry, please! |
sam boyer <[email protected]> writes:
If you could provide a bit more info on the Intel<>Google CLA, that'd
be helpful - being that i'm not a Google employee, i don't have ready
access to that information, and i'd rather not trip over anything here.
I'll try to sort that out with some Google employees.
> Does the usage of POSIX shell syntax work also on Mac OS and Windows?
On OSX, yes. i'm not sure about Windows. That tests pass on appveyor
suggests it's _probably_ fine,
I'm not sure whether existing tests cover this case. Is there any test
where a repo gets vendored which has submodules? Without those, "git
submodule foreach" will never invoke the shell command and might pass
on Windows because of that.
I had a brief look at how tests are done, but it looked a bit daunting,
so I wanted to send this PR first to get some opinions before investing
more time.
but if you can think of any way to test
this reasonably easily, it would be helpful.
Construct two repos, include the first one in the second one with a
submodule, then vendor the second one into a project. Check that the
resulting "vendor" directory contains the files from the first repo.
Also, a CHANGELOG entry, please!
I had already added one in commit 078c630. The way I understand it, one
has to create a PR to get a pull request number, then force-push a
commit with changelog entry - at least that's how I did it.
|
078c630
to
2b9f10f
Compare
2b9f10f
to
e7d68db
Compare
@sdboyer I've rebased and added a testcase with recursive submodules. I don't think there were any test cases which had a submodule at all. The new test revealed that my original code only worked for exporting submodules from the main repo - it failed for submodules inside submodules. In order to test this, I had to extend the integration testing a bit. Otherwise it would not have detected the missing submodule files. The new testing should now confirm whether the code also works on non-Linux platforms. Regarding the CLA: I'm still working on it :-/ In the meantime consider this a RFC patch, and not a contribution - it cannot be merged yet. |
About the test: the new repos are under github.com/pohly and I can keep them there in perpetuity, but it might be better to move them to github.com/sdboyer so that they are under your control. You don't need a CLA for that, do you? |
541c402
to
2230db0
Compare
Hmm, it failed on appvoyer once (https://ci.appveyor.com/project/golang/dep/build/3389) but after I changed the appvoyer config to be more verbose it succeeded without any other changes. |
Cool - i'll aim to have a look at this next week, as this week is focused on shipping v0.5.0. |
I signed it! This is for the CLA bot - I should be on the approved contributor list now. |
CLAs look good, thanks! |
CLAs look good, thanks! |
2230db0
to
996d706
Compare
When running "internal" and "external" versions of the same test case in parallel, the test case data must be read-only to avoid race conditions. When it is read/write because the tests were asked to update the reference files with "-update", running in parallel must be disabled. This broke in practice when updating entire directory trees. The risk of hitting the race is smaller when only updating single files, but it is still a race.
Debugging a failing test with dlv is possible, but in contrast to "go test", "dlv test" doesn't change the current working directory, which is necessary for the test to find its test data.
@sdboyer I understand that your priorities may have shifted now, but as I depend on "dep" and go modules don't look like a viable alternative it would be nice to get this merged. |
gps/vcs_source.go
Outdated
// "<root>/foo" for bar. By stripping our root | ||
// directory we get a relative path that we can | ||
// append to the target directory. | ||
"(cd $(grep gitdir .git | sed -e 's;gitdir: *;;' .git) && mv index origindex && trap 'mv origindex index' EXIT && git read-tree \"$sha1\" && git checkout-index -a --prefix=\""+to+"$(echo \"$toplevel\" | sed -e 's;"+r.LocalPath()+";;')/$path/\")", |
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.
grep
, sed
, etc., - not gonna be portable to windows 😢
Let's take an approach with two execs - call out to git to enumerate the submodules, loop over the results with a call to fs.RenameWithFallback()
, then call out again with git submodule foreach
. Simplicity, correctness and portability are worth the performance hit.
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.
What command should be used to enumerate the submodules?
If it's "git submodule foreach", then I still have the same problem: what can I put into that script that is portable?
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 think you should be able to get what you need from git submodule status
output. Icky, but it's there.
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.
FWIW, you mentioned before (#1909 (comment)) that the shell code might be okay because "tests pass on appveyor suggests it's probably fine". That was before I added an explicit test for submodules, but it continued to pass also after I added the new testcase. So just to be sure, automatic testing in appveyor includes running dep on Windows?
But I've rewritten the code such that it is based on the output of git submodule status
anyway, with the "export tree" functionality done by the same Go code as before, just moved to a new method. It's easier to understand this way. The only thing I don't like about it is parsing the output of git submodule status
, because there is no well-defined, machine-readable output format.
internal/fs/fs.go
Outdated
|
||
// CopyTree recursively copies a source directory into a target directory. | ||
// Target directories are created if they don't exist yet. | ||
func CopyTree(dest, src string) error { |
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.
We didn't have something like this already?
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.
Not sure how hard I searched for it. It's possible that I just overlooked such an utility function. If so, can your provide a pointer?
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.
We've got CopyDir
-
Line 356 in 22125cf
func CopyDir(src, dst string) error { |
i think that should do it.
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.
Actually, this CopyTree
wasn't something that I created ;-) I just moved it here from testproj.go
. But replacing it with CopyDir
still sounds like a good idea.
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've added a separate commit which removes this code duplication.
This PR is starting to collect some commits which could also be merged separately, like that cleanup commit. Please let me know whether I should create separate PRs for that or whether you are fine with merging everything in one go.
996d706
to
3a2fadb
Compare
The functionality is the same and some minor differences (target directory must not exist when using fs.CopyDir) can be handled by being careful about creating the temporary directories.
So far, only the list of vendored projects and the top-level Gopk.toml/lock files were compared. This way it was impossible to write integration tests that also check the content of the vendored projects. Now a test case can specify that it's 'final' directory contains a complete set of reference files, and then all files are checked respectively updated (when --updated is given). Directories and file meta still aren't checked. The reference files of existing tests can be changed on a case-by-case basis. This new comparison mode cannot be enabled unconditionally because a few tests then fail because each test run creates _vendor-<datetime> directories which are named differently in each test run.
The "git checkout-index" command is unaware of git submodules, therefore their content was missed when exporting files. With "git submodule foreach" the same operation (read-tree + checkout-index) can also be done for all submodules, recursively. The downside is that "foreach" invokes a shell command with certain variables set. To achieve the desired functionality, we have to rely on POSIX shell support. OTOH, the command seems to get embedded by git in a larger shell script because error messages when there are syntax errors show that the command gets invoked via `eval`, so git already depends on a POSIX shell.
This new test fails if the content of two recursive submodules is not exported. Verification depends on comparing the entire "final" directory.
Without the logs it is impossible to understand why certain commands fail.
3a2fadb
to
8447e4c
Compare
@sdboyer please have another look. There are test failures, but they seem unrelated to this PR. |
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! |
What does this do / why do we need it?
The "git checkout-index" command is unaware of git submodules,
therefore their content was missed when exporting files. Only a few projects have submodules (for example, git-hooks in github.com/nightlyone/lockfile and idl in github.com/uber/jaeger-client-go) and it seems that so far those submodules were not needed.
But nonetheless, the extra files are part of the source tree and thus should be exported because some projects might depend on them.
What should your reviewer look out for in this PR?
The tests for this feature depend on repos that I created under github.com/pohly. I can keep them there, but it might be cleaner to clone them into your own org and then update the tests.