Skip to content

Commit

Permalink
Can use --format=%b for just the body bit
Browse files Browse the repository at this point in the history
  • Loading branch information
richardc committed Mar 14, 2018
1 parent 25c74f6 commit a74a99c
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions lib/omnibus/git_cache.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class GitCache
# will not have the generated content, so these snapshots would be
# incompatible with the current omnibus codebase. Incrementing the serial
# number ensures these old shapshots will not be used in subsequent builds.
SERIAL_NUMBER = 3
SERIAL_NUMBER = 4

REQUIRED_GIT_FILES = %w{
HEAD
Expand Down Expand Up @@ -207,14 +207,13 @@ def find_hardlinks
hardlinks
end

# Restores any hardlinking from the commit message 'metadata'
# Restores any hardlinking from the commit message body. Body is assumed to
# be the JSON encoded return value from #find_hardlinks.
#
# @return true
def restore_hardlinks
log.warn(log_key) { "Restoring hardlinks now" }
message = git_cmd("log --format=%B -n 1").stdout
json = message.sub(%r{Backup of .*?\n\n}, "")
hardlinks = FFI_Yajl::Parser.parse(json)
body = git_cmd("log --format=%b -n 1").stdout
hardlinks = FFI_Yajl::Parser.parse(body)

hardlinks.each do |source, dest|
dest.each do |path|
Expand Down

0 comments on commit a74a99c

Please sign in to comment.