Skip to content
This repository has been archived by the owner on Sep 9, 2020. It is now read-only.

gps: Adaptively clean dirty git repos #1279

Merged
merged 5 commits into from
Oct 29, 2017
Merged

Conversation

sdboyer
Copy link
Member

@sdboyer sdboyer commented Oct 17, 2017

What does this do / why do we need it?

Instead of forcing the user to clean up dirty git repositories, we can
take at least basic steps to doing it ourselves - or, if we detect
problems, instructing the user to fix it.

The overhead introduced here is a git status call, which will be
non-negligible on larger repos, but it's probably worth it for the
resilient behavior.

Eventually, once we get to #534, we'll want to issue a warning when we undertake a cleanup.

This needs tests. Also, let's delay merging this until after the next release so that it can percolate on tip for a while.

Might want to also refactor maybeGitSource.try() to do this check earlier, and os.RemoveAll() then try again if it doesn't work.

What should your reviewer look out for in this PR?

Possible failure modes. It'd be great if this attempt at making things better didn't inadvertently make things worse!

Do you need help or clarification on anything?

Which issue(s) does this PR fix?

fixes #1016
fixes #618

@sdboyer
Copy link
Member Author

sdboyer commented Oct 26, 2017

uggghhh, appveyor.

@jmank88 care to have a look over this before i merge? note that this'll also disrupt #1250 a bit.

@sdboyer
Copy link
Member Author

sdboyer commented Oct 26, 2017

ugh. windows failures. like, actual ones on the new tests. oh frabjous day!

@kanishkdudeja
Copy link

Results of some testing I could do on Windows:

Windows Version: Windows 10 Fall creators update (Build 1709)

Go version: 1.8.5 and 1.9.2 (Tested on both)

Go Env variables: Default. Changed no environment variable explicitly.

1. go get github.com/golang/dep

2. cd into $GOPATH/src/github.com/golang/dep/internal/gps

3. git pull https://github.com/sdboyer/dep.git git-autorecover

4. go test -run=TestGitSourceAdaptiveCleanup

C:\Users\Kanishk\go\src\github.com\golang\dep\internal\gps>go test -run=TestGitSourceAdaptiveCleanup
PASS
ok      github.com/golang/dep/internal/gps      14.452s

5. git checkout 7e96bb29245f7ff4b8bc96aea4cc657e1684f0f6

C:\Users\Kanishk\go\src\github.com\golang\dep\internal\gps>go test -run=TestGitSourceAdaptiveCleanup
PASS
ok      github.com/golang/dep/internal/gps      15.017s

Result: The test case passed for both the git-autorecover branch and the 7e96bb2 commit for both Go 1.8 and 1.9

@sdboyer
Copy link
Member Author

sdboyer commented Oct 27, 2017

so yeah, i don't know why that error occurred on appveyor earlier (and i can't reproduce because the parallelism is killing it - i have to get rid of that tonight) but this appears to work on windows. which is tony-the-tiger-level grrrrrrreat news

Instead of forcing the user to clean up dirty git repositories, we can
take at least basic steps to doing it ourselves - or, if we detect
problems, instructing the user to fix it.

The overhead introduced here is a `git status` call, which will be
non-negligible on larger repos, but it's probably worth it for the
resilient behavior.
This covers three basic cases - untracked files, modified files, and
some corruption in the .git directory. The first two are plausible; the
third is less so, as we don't know much about what real git failure
patterns could look like in the .git directory itself. However, it's
an adequate test inasmuch as it triggers failure in the basic git calls
we make, thereby triggering the recovery procedure.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
3 participants