Skip to content

Commit 9aa8c86

Browse files
authored
Merge pull request revel#1243 from notzippy/pre-release
Vendoring fixes
2 parents 8e25775 + 31c9ac4 commit 9aa8c86

File tree

3 files changed

+17
-20
lines changed

3 files changed

+17
-20
lines changed

logger.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ var (
2828
// DEPRECATED
2929
oldLog = AppLog.New("section", "deprecated")
3030
// System logger
31-
sysLog = AppLog.New("section", "system")
31+
SysLog = AppLog.New("section", "system")
3232
// DEPRECATED Use AppLog
3333
TRACE = log.New(os.Stderr, "TRACE ", log.Ldate|log.Ltime|log.Lshortfile)
3434
// DEPRECATED Use AppLog
@@ -82,9 +82,9 @@ func setAppLog(appLog logger.MultiLogger, appHandler *logger.CompositeMultiHandl
8282

8383
// Set the system log handler - this sets golang writer stream to the
8484
// sysLog router
85-
logger.SetDefaultLog(sysLog)
86-
sysLog.SetStackDepth(5)
87-
sysLog.SetHandler(appLogHandler)
85+
logger.SetDefaultLog(SysLog)
86+
SysLog.SetStackDepth(5)
87+
SysLog.SetHandler(appLogHandler)
8888
}
8989
}
9090

module.go

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -83,18 +83,22 @@ func (m *Module) AddController(ct *ControllerType) {
8383
// Only to be used on initialization
8484
func ModuleFromPath(path string, addGopathToPath bool) (module *Module) {
8585
gopathList := filepath.SplitList(build.Default.GOPATH)
86+
// ignore the vendor folder
87+
if i := strings.Index(path, "/vendor/"); i > 0 {
88+
path = path[i+len("vendor/"):]
89+
}
8690

8791
// See if the path exists in the module based
8892
for i := range Modules {
8993
if addGopathToPath {
9094
for _, gopath := range gopathList {
91-
if strings.HasPrefix(filepath.ToSlash(filepath.Clean(filepath.Join(gopath,"src",path))), Modules[i].Path) {
95+
if strings.Contains(filepath.ToSlash(filepath.Clean(filepath.Join(gopath, "src", path))), Modules[i].Path) {
9296
module = Modules[i]
9397
break
9498
}
9599
}
96100
} else {
97-
if strings.HasPrefix(path, Modules[i].Path) {
101+
if strings.Contains(path, Modules[i].ImportPath) {
98102
module = Modules[i]
99103
break
100104
}
@@ -159,17 +163,10 @@ func loadModules() {
159163

160164
// Modules loaded, now show module path
161165
for key, callback := range appModule.initializedModules {
162-
found := false
163-
for _, m := range Modules {
164-
if strings.HasPrefix(key, m.ImportPath) {
165-
moduleLog.Debug("Module called callback", "moduleKey", m.ImportPath, "callbackKey", key)
166-
callback(m)
167-
found = true
168-
break
169-
}
170-
}
171-
if !found {
172-
RevelLog.Error("Callback for non registered module initializing with application module","modulePath",key)
166+
if m := ModuleFromPath(key, false); m != nil {
167+
callback(m)
168+
} else {
169+
RevelLog.Error("Callback for non registered module initializing with application module", "modulePath", key)
173170
callback(appModule)
174171
}
175172
}

revel.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ func ResolveImportPath(importPath string) (string, error) {
231231
return filepath.Join(SourcePath, importPath), nil
232232
}
233233

234-
modPkg, err := build.Import(importPath, "", build.FindOnly)
234+
modPkg, err := build.Import(importPath, RevelPath, build.FindOnly)
235235
if err != nil {
236236
return "", err
237237
}
@@ -269,10 +269,10 @@ func findSrcPaths(importPath string) (revelSourcePath, appSourcePath string) {
269269
RevelLog.Panic("Failed to import "+importPath+" with error:", "error", err)
270270
}
271271

272-
revelPkg, err := build.Import(RevelImportPath, "", build.FindOnly)
272+
revelPkg, err := build.Import(RevelImportPath, appPkg.Dir, build.FindOnly)
273273
if err != nil {
274274
RevelLog.Fatal("Failed to find Revel with error:", "error", err)
275275
}
276276

277-
return revelPkg.SrcRoot, appPkg.SrcRoot
277+
return revelPkg.Dir[:len(revelPkg.Dir)-len(RevelImportPath)], appPkg.SrcRoot
278278
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy