diff options
author | Gleb Mazovetskiy <glex.spb@gmail.com> | 2015-08-26 05:24:32 +0300 |
---|---|---|
committer | Gleb Mazovetskiy <glex.spb@gmail.com> | 2015-08-26 05:24:32 +0300 |
commit | 032cf751fff0e4b008952dedc6cda961e0035ac1 (patch) | |
tree | 93778dfb6208661798db8e7cf3d21e717e3bb675 /tasks/updater | |
parent | 44fa20c19b28a4207cbaea901b196bec585085f4 (diff) |
Fix updater caching, use upstream version for variables
Diffstat (limited to 'tasks/updater')
-rw-r--r-- | tasks/updater/network.rb | 14 | ||||
-rw-r--r-- | tasks/updater/scss_conversion.rb | 7 |
2 files changed, 11 insertions, 10 deletions
diff --git a/tasks/updater/network.rb b/tasks/updater/network.rb index 1b85b7a..3625ba1 100644 --- a/tasks/updater/network.rb +++ b/tasks/updater/network.rb @@ -11,15 +11,19 @@ class Updater get_tree(get_tree_sha(dir), recursive)['tree'].select { |f| f['type'] == 'blob' }.map { |f| f['path'] } end + def file_url(path) + "https://raw.githubusercontent.com/#@repo/#@branch_sha/#{path}" + end + def read_files(path, files) - full_path = "https://raw.githubusercontent.com/#@repo/#@branch_sha/#{path}" + path_url = file_url path contents = read_cached_files(path, files) - log_http_get_files contents.keys, full_path, true if contents.keys + log_http_get_files contents.keys, path_url, true if contents.keys files -= contents.keys - log_http_get_files files, full_path, false + log_http_get_files files, path_url, false files.map do |name| Thread.start { - contents[name] = open("#{full_path}/#{name}").read + contents[name] = open("#{path_url}/#{name}").read Thread.exclusive { write_cached_files path, name => contents[name] } } end.each(&:join) @@ -65,7 +69,7 @@ class Updater # get sha of the branch (= the latest commit) def get_branch_sha @branch_sha ||= begin - if @branch + "\n" == %x[git rev-parse -- #@branch] + if @branch =~ /\A[0-9a-f]{40,}\z/ @branch else cmd = "git ls-remote #{Shellwords.escape "https://github.com/#@repo"} #@branch" diff --git a/tasks/updater/scss_conversion.rb b/tasks/updater/scss_conversion.rb index d885ff1..ed59324 100644 --- a/tasks/updater/scss_conversion.rb +++ b/tasks/updater/scss_conversion.rb @@ -4,6 +4,7 @@ class Updater log_status 'Updating scss...' save_to = @save_to[:scss] contents = {} + bootstrap_scss_files = get_paths_by_type('scss', /\.scss$/) read_files('scss', bootstrap_scss_files).each do |name, file| contents[name] = file save_file("#{save_to}/#{name}", file) @@ -26,13 +27,9 @@ class Updater log_status 'Generating variable template file' save_file 'templates/project/_bootstrap-variables.sass', - "// Override Bootstrap variables here (defaults from bootstrap-sass v#{Bootstrap::VERSION}):\n\n" + + "// Override Bootstrap variables here (defaults from bootstrap v#{upstream_version}):\n\n" + File.read("#{save_to}/_variables.scss").lines[1..-1].join.gsub(/^(?=\$|\))/, '// ').gsub(/ !default/, '') end end - - def bootstrap_scss_files - @bootstrap_scss_files ||= get_paths_by_type('scss', /\.scss$/) - end end |