Skip to content

Instantly share code, notes, and snippets.

@jasonkarns
Created April 2, 2026 15:04
Show Gist options
  • Select an option

  • Save jasonkarns/95aa2cb4c11f8f8cf355802dbf8fa86f to your computer and use it in GitHub Desktop.

Select an option

Save jasonkarns/95aa2cb4c11f8f8cf355802dbf8fa86f to your computer and use it in GitHub Desktop.
desc "Compare frontend asset builds between branches"
task :diffassets, [:branch] do |t, args|
sh "git diff-index --quiet HEAD --" do |ok, res|
abort "Working directory not clean. Stash or commit first." unless ok
end
args.with_defaults(branch: "-") # git's magic for "last branch"
# start in main, do clean asset build, and temporarily force-add to git
sh "git switch main"
sh "rake assets:clobber assets:precompile"
sh "git add -f app/assets public"
# switch (back) to feature branch, rebuild, and diff
sh "git switch #{args[:branch]}"
sh "rake assets:clobber assets:precompile"
sh "git diff --stat"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment