Permalink
Browse files

Changed permission part of fingerprint generation

Git is not really tracking permissions, just defaults to
either 0644 or 0755 (depending on executable bit). Made
CLI mimic that behavior.

Change-Id: I3cb999c5169a4d7c3fd5cd2e666ed41d4304e9b9
  • Loading branch information...
1 parent 9a0e8e0 commit 98aea013157b0b97c34e38fc1197c142a911d497 @olegshaldybin olegshaldybin committed Feb 9, 2012
Showing with 23 additions and 5 deletions.
  1. +1 −1 cli/Gemfile.lock
  2. +1 −1 cli/lib/cli/job_builder.rb
  3. +3 −1 cli/lib/cli/package_builder.rb
  4. +17 −1 cli/lib/cli/packaging_helper.rb
  5. +1 −1 cli/lib/cli/version.rb
View
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
- bosh_cli (0.13.5)
+ bosh_cli (0.13.6)
blobstore_client (= 0.3.9)
highline (~> 1.6.2)
httpclient (= 2.2.4)
@@ -179,7 +179,7 @@ def make_fingerprint
files << File.join(job_dir, "spec")
files.each do |filename|
- contents << "%s%s%s" % [ File.basename(filename), File.read(filename), File.stat(filename).mode.to_s(8) ]
+ contents << "%s%s%s" % [ File.basename(filename), File.read(filename), tracked_permissions(filename) ]
end
Digest::SHA1.hexdigest(contents)
@@ -164,7 +164,9 @@ def make_fingerprint
signatures = files.map do |file|
path = get_file_path(file)
- "%s%s%s" % [ file, File.directory?(path) ? nil : File.read(path), File.stat(path).mode.to_s(8) ]
+
+ # TODO change fingerprint to use file checksum, not the raw contents
+ "%s%s%s" % [ file, File.directory?(path) ? nil : File.read(path), tracked_permissions(path) ]
end
contents << signatures.join("")
@@ -95,7 +95,8 @@ def use_final_version
if Digest::SHA1.hexdigest(payload) == item["sha1"]
@tarball_path = @final_index.add_version(fingerprint, item, payload)
else
- err("`#{name}' (#{version}) is corrupted in blobstore (id=#{blobstore_id}), please remove it manually and re-generate the final release")
+ err("`#{name}' (#{version}) is corrupted in blobstore (id=#{blobstore_id}), " +
+ "please remove it manually and re-generate the final release")
end
end
@@ -220,6 +221,21 @@ def checksum
end
end
+ # Git doesn't really track file permissions, it just looks at executable
+ # bit and uses 0755 if it's set or 0644 if not. We have to mimic that
+ # behavior in the fingerprint calculation to avoid the situation where
+ # seemingly clean working copy would trigger new fingreprints for
+ # artifacts with changed permissions. Also we don't want current
+ # fingerprints to change, hence the exact values below.
+ def tracked_permissions(path)
+ if File.directory?(path)
+ "40755"
+ elsif File.executable?(path)
+ "100755"
+ else
+ "100644"
+ end
+ end
end
end
end
View
@@ -1,5 +1,5 @@
module Bosh
module Cli
- VERSION = "0.13.5"
+ VERSION = "0.13.6"
end
end

0 comments on commit 98aea01

Please sign in to comment.