Skip to content

Commit

Permalink
manifest mtime reproducibility
Browse files Browse the repository at this point in the history
When building Rails assets with Nix, I found they are almost
completely reproducible. This commit fixes one of the issues. For more
information about why it is good for a build to be reproducible see:

https://reproducible-builds.org/

This stops encoding the asset compilation time (something that is not
reproducible) into the manifest.
  • Loading branch information
ryantm committed Sep 20, 2022
1 parent 1276b43 commit 12d9ea0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Get upgrade notes from Sprockets 3.x to 4.x at https://github.com/rails/sprockets/blob/master/UPGRADING.md

- Add support for Rack 3.0. Headers set by sprockets will now be lower case. [#758](https://github.com/rails/sprockets/pull/758)
- Stop encoding compiled asset modifcation time into sprockets-manifest for reproducibility [#763](https://github.com/rails/sprockets/pull/763)
- Make `Sprockets::Utils.module_include` thread safe on JRuby. [#759](https://github.com/rails/sprockets/pull/759)

## 4.1.0
Expand Down
6 changes: 3 additions & 3 deletions lib/sprockets/manifest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,12 @@ def assets
#
# Fingerprint path (String):
# logical_path: Logical path (String)
# mtime: ISO8601 mtime (String)
# mtime: ISO8601 mtime (String) always "1970-01-01T00:00:01+00:00"
# digest: Base64 hex digest (String)
#
# { "application-2e8e9a7c6b0aafa0c9bdeec90ea30213.js" =>
# { 'logical_path' => "application.js",
# 'mtime' => "2011-12-13T21:47:08-06:00",
# 'mtime' => "1970-01-01T00:00:01+00:00",
# 'digest' => "2e8e9a7c6b0aafa0c9bdeec90ea30213" } }
#
def files
Expand Down Expand Up @@ -172,7 +172,7 @@ def compile(*args)
end

assets_to_export.each do |asset|
mtime = Time.now.iso8601
mtime = Time.at(1).utc.to_datetime.iso8601 # for reproducibility
files[asset.digest_path] = {
'logical_path' => asset.logical_path,
'mtime' => mtime,
Expand Down

0 comments on commit 12d9ea0

Please sign in to comment.