Skip to content

Commit 44fc84b

Browse files
author
OpenShift Bot
authored
Merge pull request #12011 from soltysh/fix_godeps
Merged by openshift-bot
2 parents 9240997 + 765277b commit 44fc84b

File tree

80 files changed

+32503
-1556
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+32503
-1556
lines changed

Godeps/Godeps.json

+1,042-70
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

hack/godep-restore.sh

+2
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ preload-remote "github.com/google" "cadvisor" "github.com/openshift" "cadvisor"
8282
preload-dep "github.com/elazarl" "goproxy" "$( go run "${OS_ROOT}/tools/godepversion/godepversion.go" "${OS_ROOT}/Godeps/Godeps.json" "github.com/elazarl/goproxy" )"
8383
# rkt test dep
8484
preload-dep "github.com/golang/mock" "gomock" "$( go run "${OS_ROOT}/tools/godepversion/godepversion.go" "${OS_ROOT}/Godeps/Godeps.json" "github.com/golang/mock/gomock" )"
85+
# docker storage dep
86+
preload-dep "google.golang.org" "cloud" "$( go run "${OS_ROOT}/tools/godepversion/godepversion.go" "${OS_ROOT}/Godeps/Godeps.json" "google.golang.org/cloud" )"
8587

8688
# fill out that nice clean place with the origin godeps
8789
echo "Starting to download all godeps. This takes a while"

tools/rebasehelpers/commitchecker/commitchecker.go

+7-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,13 @@ func main() {
3636

3737
errs := []string{}
3838
for _, validate := range AllValidators {
39-
err := validate(nonbumpCommits)
40-
if err != nil {
39+
if err := validate(nonbumpCommits); err != nil {
40+
errs = append(errs, err.Error())
41+
}
42+
}
43+
if len(os.Getenv("RESTORE_AND_VERIFY_GODEPS")) > 0 {
44+
// Godeps verifies all commits, including bumps and UPSTREAM
45+
if err := ValidateGodeps(commits); err != nil {
4146
errs = append(errs, err.Error())
4247
}
4348
}

tools/rebasehelpers/commitchecker/validate.go

+29-4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package main
33
import (
44
"bytes"
55
"fmt"
6+
"os/exec"
67
"regexp"
78
"strings"
89
"text/template"
@@ -51,7 +52,7 @@ var AllValidators = []func([]util.Commit) error{
5152
func ValidateUpstreamCommitsWithoutGodepsChanges(commits []util.Commit) error {
5253
problemCommits := []util.Commit{}
5354
for _, commit := range commits {
54-
if commit.HasGodepsChanges() && !commit.DeclaresUpstreamChange() {
55+
if commit.HasVendoredCodeChanges() && !commit.DeclaresUpstreamChange() {
5556
problemCommits = append(problemCommits, commit)
5657
}
5758
}
@@ -114,7 +115,7 @@ func ValidateUpstreamCommitSummaries(commits []util.Commit) error {
114115
func ValidateUpstreamCommitModifiesOnlyGodeps(commits []util.Commit) error {
115116
problemCommits := []util.Commit{}
116117
for _, commit := range commits {
117-
if commit.HasGodepsChanges() && commit.HasNonGodepsChanges() {
118+
if commit.HasVendoredCodeChanges() && commit.HasNonVendoredCodeChanges() {
118119
problemCommits = append(problemCommits, commit)
119120
}
120121
}
@@ -155,6 +156,30 @@ func ValidateUpstreamCommitModifiesOnlyDeclaredGodepRepo(commits []util.Commit)
155156
return nil
156157
}
157158

159+
// ValidateGodeps invokes hack/godep-restore.sh whenever it finds at least one commit
160+
// modifying Godeps/Godeps.json file or vendor/ directory.
161+
func ValidateGodeps(commits []util.Commit) error {
162+
runGodepsRestore := false
163+
for _, commit := range commits {
164+
if commit.HasVendoredCodeChanges() || commit.HasGodepsChanges() {
165+
runGodepsRestore = true
166+
break
167+
}
168+
}
169+
if runGodepsRestore {
170+
fmt.Println("Running godep-restore")
171+
cmd := exec.Command("hack/godep-restore.sh")
172+
var stdout bytes.Buffer
173+
var stderr bytes.Buffer
174+
cmd.Stdout = &stdout
175+
cmd.Stderr = &stderr
176+
if err := cmd.Run(); err != nil {
177+
return fmt.Errorf("Error running hack/godep-restore.sh: %v\n%s\n%s", err, stderr.String(), stdout.String())
178+
}
179+
}
180+
return nil
181+
}
182+
158183
type CommitFilesRenderOption int
159184

160185
const (
@@ -175,8 +200,8 @@ func renderGodepFilesError(label string, commits []util.Commit, opt CommitFilesR
175200
}
176201
for _, file := range commit.Files {
177202
if opt == RenderAllFiles ||
178-
(opt == RenderOnlyGodepsFiles && file.HasGodepsChanges()) ||
179-
(opt == RenderOnlyNonGodepsFiles && !file.HasGodepsChanges()) {
203+
(opt == RenderOnlyGodepsFiles && file.HasVendoredCodeChanges()) ||
204+
(opt == RenderOnlyNonGodepsFiles && !file.HasVendoredCodeChanges()) {
180205
msg += fmt.Sprintf(" - %s\n", file)
181206
}
182207
}

tools/rebasehelpers/util/git.go

+26-5
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,18 @@ func (c Commit) DeclaredUpstreamRepo() (string, error) {
5959
return repo, nil
6060
}
6161

62+
// HasVendoredCodeChanges verifies if the commit has any changes to Godeps/_workspace/
63+
// or vendor/ directories.
64+
func (c Commit) HasVendoredCodeChanges() bool {
65+
for _, file := range c.Files {
66+
if file.HasVendoredCodeChanges() {
67+
return true
68+
}
69+
}
70+
return false
71+
}
72+
73+
// HasGodepsChanges verifies if the commit has any changes to Godeps/Godeps.json file.
6274
func (c Commit) HasGodepsChanges() bool {
6375
for _, file := range c.Files {
6476
if file.HasGodepsChanges() {
@@ -68,9 +80,11 @@ func (c Commit) HasGodepsChanges() bool {
6880
return false
6981
}
7082

71-
func (c Commit) HasNonGodepsChanges() bool {
83+
// HasNonVendoredCodeChanges verifies if the commit didn't modify Godeps/_workspace/
84+
// or vendor directories.
85+
func (c Commit) HasNonVendoredCodeChanges() bool {
7286
for _, file := range c.Files {
73-
if !file.HasGodepsChanges() {
87+
if !file.HasVendoredCodeChanges() {
7488
return true
7589
}
7690
}
@@ -80,7 +94,7 @@ func (c Commit) HasNonGodepsChanges() bool {
8094
func (c Commit) GodepsReposChanged() ([]string, error) {
8195
repos := map[string]struct{}{}
8296
for _, file := range c.Files {
83-
if !file.HasGodepsChanges() {
97+
if !file.HasVendoredCodeChanges() {
8498
continue
8599
}
86100
repo, err := file.GodepsRepoChanged()
@@ -98,12 +112,19 @@ func (c Commit) GodepsReposChanged() ([]string, error) {
98112

99113
type File string
100114

101-
func (f File) HasGodepsChanges() bool {
115+
// HasVendoredCodeChanges verifies if the modified file is from Godeps/_workspace/
116+
// or vendor/ directories.
117+
func (f File) HasVendoredCodeChanges() bool {
102118
return strings.HasPrefix(string(f), "Godeps/_workspace") || strings.HasPrefix(string(f), "vendor")
103119
}
104120

121+
// HasGodepsChanges verifies if the modified file is Godeps/Godeps.json.
122+
func (f File) HasGodepsChanges() bool {
123+
return f == "Godeps/Godeps.json"
124+
}
125+
105126
func (f File) GodepsRepoChanged() (string, error) {
106-
if !f.HasGodepsChanges() {
127+
if !f.HasVendoredCodeChanges() {
107128
return "", fmt.Errorf("file doesn't appear to be a Godeps or vendor change")
108129
}
109130
// Find the _workspace or vendor path segment index.

vendor/github.com/codegangsta/negroni/LICENSE

+21
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/codegangsta/negroni/README.md

+181
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/codegangsta/negroni/doc.go

+25
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)