Skip to content

Conversation

ddddddO
Copy link
Contributor

@ddddddO ddddddO commented Sep 30, 2023

@owlinux1000

すみません、バグを埋め込んでしまってたので修正PRです🙇

事象

~/github.com/ddddddO/gtree
02:21:25 > gcstree tf-state-work1111
tf-state-work1111
├── skillset-visualizer
│   └── terraform
│       └── state
│           └── default.tfstate
└── standard
    └── module
        └── structure
            └── default.tfstate

2 directories, 2 files

↑のようなバケット構成で試したのですが、サマリで 2 directories になってしまってました...(本来は、6 directories が意図する結果)

gcstree.go内で、以下のようにprint debugすると、

	it := bkt.Objects(ctx, query)
	for {
		attrs, err := it.Next()
		if err == iterator.Done {
			break
		}
		if err != nil {
			return nil, err
		}

		log.Println("Debug:")           <- 追加
		fmt.Println(attrs.Name)       <- 追加

		g.counter.count(attrs.Name)
		names = append(names, attrs.Name)
	}

以下の結果でした

2023/10/01 02:55:50 Debug:
skillset-visualizer/terraform/state/default.tfstate
2023/10/01 02:55:50 Debug:
standard/module/structure/default.tfstate

バグ修正前のcounterの実装ですと、

  • skillset-visualizer/terraform/state/
  • standard/module/structure/

の2ディレクトリのみをディレクトリとしてカウントするため、それ以外のディレクトリもカウントするようにしました!

申し訳ないのですが、もう一度取り込んでいただけると...🔥🙇🔥

Comment on lines +13 to +28
{
name: "pattern1",
paths: []string{
"empty_directory/",
"a.txt",
"a.tgz",
"source/a.tgz",
"source/b.tgz",
"source/c.tgz",
"tmp_directory/",
"tmp_directory/a.png",
"tmp_directory/empty_directory/",
"tmp_directory/source/a.tgz",
},
want: "5 directories, 7 files",
},
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

既存のテストケースです!

Comment on lines +29 to +36
{
name: "pattern2",
paths: []string{
"skillset-visualizer/terraform/state/default.tfstate",
"standard/module/structure/default.tfstate",
},
want: "6 directories, 2 files",
},
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

こちらが今回バグ発見時のパターンのケースです🙇

@ddddddO ddddddO marked this pull request as ready for review September 30, 2023 18:21
@owlinux1000
Copy link
Owner

@ddddddO ありがとうございます!助かります!

Copy link
Owner

@owlinux1000 owlinux1000 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ありがとうございます!

@owlinux1000 owlinux1000 merged commit e36f1bf into owlinux1000:main Sep 30, 2023
@ddddddO ddddddO deleted the fix_counter branch October 1, 2023 02:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants