vc60er / deptree

show golang dependence like tree
76 stars 9 forks source link

Fix/hang or recursion #12

Closed gen2thomas closed 1 year ago

gen2thomas commented 1 year ago

in addition:

gen2thomas commented 1 year ago

Hi @vc60er , the fix is now ready to review.

vc60er commented 1 year ago

Hi @gen2thomas , thank you for your contribution.

I had make a simple test for base features, and found the corner("├") is not corrent when use -t parameter, can you update it to "└".

➜  deptree git:(fix/hang_or_recursion) ✗ go mod graph | output/deptree -t 
call 'go list -u -m -json all', be patient...
dependency tree with depth 3 for package: github.com/vc60er/deptree, least 6 trimmed item(s)
* only upgradable items with parents are shown (-a not set)
* duplicate children not shown (-a not set)

github.com/vc60er/deptree (go1.15)
 └── github.com/stretchr/testify@v1.8.2 (go1.13)
      ├── github.com/stretchr/objx@v0.5.0 (go1.12)
      │    └── github.com/stretchr/testify@v1.8.0 => [v1.8.2] (go1.13)
      │         ├── ...
      └── gopkg.in/yaml.v3@v3.0.1
           └── gopkg.in/check.v1@v0.0.0-20161208181325-20d25e280405 => [v1.0.0-20150610233030-8d49746f13e4]

May be, need add condition check in createRoutes for trimmed child

@@ -432,7 +432,7 @@ func createRoutes(line *routeTreeLine, route string) {
        childPath = strings.Replace(childPath, "─", " ", -1)
        for i, child := range line.children {
            var corner string
-           if i == childLen-1 {
+           if i == childLen-1 || child.additionalContent == depthMarker {
                corner = childPath + " └── "
            } else {
                corner = childPath + " ├── "
gen2thomas commented 1 year ago

Hi @vc60er , thanks for the finding. I thought the ├ instead of └ could be a sign for more than one children, but found another nice solution for visualization of this here: https://github.com/semihbkgr/deptree/blob/master/README.md

What do you think about?

vc60er commented 1 year ago

it's really a nice solution

gen2thomas commented 1 year ago

Hi @vc60er , fixed and linter settings added and findings fixed.