Skip to content

Commit

Permalink
Set the empty digest for empty directories when flattening a tree (#154)
Browse files Browse the repository at this point in the history
Co-authored-by: jpoole <[email protected]>
  • Loading branch information
Tatskaari and Tatskaari authored Jul 9, 2020
1 parent f9b4b0d commit bafedfc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions go/pkg/tree/tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ func flattenTree(root digest.Digest, rootPath string, dirs map[digest.Digest]*re
if len(dir.Files)+len(dir.Directories)+len(dir.Symlinks) == 0 {
flatFiles[flatDir.p] = &Output{
Path: flatDir.p,
Digest: digest.Empty,
IsEmptyDirectory: true,
}
continue
Expand Down
6 changes: 3 additions & 3 deletions go/pkg/tree/tree_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1032,13 +1032,13 @@ func TestFlattenTreeRepeated(t *testing.T) {
}
wantOutputs := map[string]*Output{
"x/baz": &Output{Digest: bazDigest},
"x/a/b/c": &Output{IsEmptyDirectory: true},
"x/a/b/c": &Output{IsEmptyDirectory: true, Digest: digest.Empty},
"x/a/b/foo": &Output{Digest: fooDigest},
"x/a/b/bar": &Output{Digest: barDigest, IsExecutable: true},
"x/b/c": &Output{IsEmptyDirectory: true},
"x/b/c": &Output{IsEmptyDirectory: true, Digest: digest.Empty},
"x/b/foo": &Output{Digest: fooDigest},
"x/b/bar": &Output{Digest: barDigest, IsExecutable: true},
"x/c": &Output{IsEmptyDirectory: true},
"x/c": &Output{IsEmptyDirectory: true, Digest: digest.Empty},
}
if len(outputs) != len(wantOutputs) {
t.Errorf("FlattenTree gave wrong number of outputs: want %d, got %d", len(wantOutputs), len(outputs))
Expand Down

0 comments on commit bafedfc

Please sign in to comment.