Skip to content

Commit

Permalink
fix special case for ParseVendorModule (#159)
Browse files Browse the repository at this point in the history
  • Loading branch information
vearne authored Jan 3, 2024
1 parent d1193f8 commit 2c1ffe8
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@
coverage.txt
/test/plugins/workspace
/test/plugins/dist/
*.pb.go
*.pb.go
vendor/
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Release Notes.
* Fix users can not use async api in toolkit-trace.
* Fix cannot enhance the vendor management project.
* Fix SW_AGENT_REPORTER_GRPC_MAX_SEND_QUEUE not working on metricsSendCh & logSendCh chans of gRPC reporter.
* Fix ParseVendorModule error for special case in vendor/modules.txt

#### Issues and PR
- All issues are [here](https://github.com/apache/skywalking/milestone/197?closed=1)
Expand Down
4 changes: 4 additions & 0 deletions tools/go-agent/tools/testdata/special-modules.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# github.com/abc/def v0.2.0
## explicit; go 1.18
github.com/abc/def/aa
github.com/abc/def/bb/cc
3 changes: 2 additions & 1 deletion tools/go-agent/tools/vendor.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,10 @@ func ParseVendorModule(path string) (VendorModules, error) {
return nil, fmt.Errorf("module data cannot be analyzed")
}
module = &VendorModule{
Name: moduleInfo[1],
Name: strings.TrimSpace(moduleInfo[1]),
Version: moduleInfo[2],
}
modules[module.Name] = module
continue
} else if strings.HasPrefix(moduleString, "#") {
// go version required, ignore
Expand Down
13 changes: 13 additions & 0 deletions tools/go-agent/tools/vendor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,19 @@ func TestParseVendorModule(t *testing.T) {
return nil
},
},
{
path: "./testdata/special-modules.txt",
hasError: false,
packageCount: 3,
validate: func(modules VendorModules) error {
if m := modules["github.com/abc/def"]; m == nil {
return fmt.Errorf("module missing")
} else if m.Version != "v0.2.0" {
return fmt.Errorf("version not correct")
}
return nil
},
},
}

for _, test := range tests {
Expand Down

0 comments on commit 2c1ffe8

Please sign in to comment.