Skip to content

Commit

Permalink
Merge pull request #439 from Shopify/remove_file_with_same_date
Browse files Browse the repository at this point in the history
Remove was not removing files with the same date
  • Loading branch information
tanema authored Aug 21, 2017
2 parents 6f18131 + d883ae5 commit 30c905e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cmd/file_manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ func (manifest *fileManifest) ShouldUpload(asset kit.Asset, environment string)

func (manifest *fileManifest) ShouldRemove(filename, environment string) bool {
localTime, remoteTime := manifest.diffDates(filename, environment, environment)
return remoteTime.Before(localTime) || localTime.IsZero()
return remoteTime.Before(localTime) || remoteTime.Equal(localTime) || localTime.IsZero()
}

func (manifest *fileManifest) Should(event kit.EventType, asset kit.Asset, environment string) bool {
Expand Down
2 changes: 1 addition & 1 deletion cmd/file_manifest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func TestFileManifest_Should(t *testing.T) {
}

assert.False(t, manifest.Should(kit.Update, asset, env))
assert.False(t, manifest.Should(kit.Remove, asset, env))
assert.True(t, manifest.Should(kit.Remove, asset, env))
assert.False(t, manifest.Should(kit.Retrieve, asset, env))

manifest.local[asset.Key][env] = now
Expand Down
6 changes: 5 additions & 1 deletion cmd/remove_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ func TestRemove(t *testing.T) {
assert.Equal(t, "DELETE", server.Requests[0].Method)
}

arbiter.manifest.Set("templates/layout.liquid", "development", "2011-07-06T02:04:21-11:00", "123sum456")
asset, env, then, now := "templates/layout.liquid", "development", "2011-07-06T02:04:21-11:00", "2012-07-06T02:04:21-11:00"
arbiter.manifest = &fileManifest{
local: map[string]map[string]string{asset: {env: then}},
remote: map[string]map[string]string{asset: {env: now}},
}
arbiter.force = false
err = remove(client, []string{"templates/layout.liquid"})
assert.True(t, strings.Contains(err.Error(), "file was modified remotely"))
Expand Down

0 comments on commit 30c905e

Please sign in to comment.