Skip to content

Save sha without original sha when to save in Hashed #109

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions go/porcelain/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,13 @@ func newDeployFiles() *deployFiles {
func (d *deployFiles) Add(p string, f *FileBundle) {
d.Files[p] = f
d.Sums[p] = f.Sum
list, _ := d.Hashed[f.Sum]
d.Hashed[f.Sum] = append(list, f)
// Remove ":original_sha" part when to save in Hashed (asset management)
sum := f.Sum
if strings.Contains(sum, ":") {
sum = strings.Split(sum, ":")[0]
}
list, _ := d.Hashed[sum]
d.Hashed[sum] = append(list, f)
}

func (n *Netlify) overCommitted(d *deployFiles) bool {
Expand Down
27 changes: 27 additions & 0 deletions go/porcelain/deploy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,30 @@ func TestGetAssetManagementSha(t *testing.T) {
}
}
}

func TestAddWithAssetManagement(t *testing.T) {
files := newDeployFiles()
tests := []struct {
rel string
sum string
}{
{"foo.jpg", "sum1"},
{"bar.jpg", "sum2"},
{"baz.jpg", "sum3:originalsha"},
}

for _, test := range tests {
file := &FileBundle{}
file.Sum = test.sum
files.Add(test.rel, file)
}

out := files.Hashed["sum3"]
if len(out) != 1 {
t.Fatalf("expected `%d`, got `%d`", 1, len(out))
}
out2 := files.Sums["baz.jpg"]
if out2 != "sum3:originalsha" {
t.Fatalf("expected `%v`, got `%v`", "sum3:originalsha", out2)
}
}