Skip to content

Commit

Permalink
Merge pull request #6887 from MahtraDR/dependency_tweaks
Browse files Browse the repository at this point in the history
[scripts][dependency] Tweaks to downloading updated/missing files
  • Loading branch information
MahtraDR authored Sep 5, 2024
2 parents aa4247d + 2fe9c22 commit ed615d4
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions dependency.lic
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require 'ostruct'
require 'digest/sha1'
require 'monitor'

$DEPENDENCY_VERSION = '1.7.1'
$DEPENDENCY_VERSION = '1.7.2'
$MIN_RUBY_VERSION = '3.2.2'

no_pause_all
Expand Down Expand Up @@ -395,11 +395,14 @@ class ScriptManager
def setup_profiles
verify_or_make_dir File.join(SCRIPT_DIR, 'profiles')
profile_tree_url = get_status['tree'].find { |element| element['path'] == 'profiles' }['url']
make_request(profile_tree_url)['tree'].each do |setup_file|
echo("downloading #{setup_file}") if @debug
blob = make_request(setup_file['url'])
File.open(File.join(SCRIPT_DIR, "profiles/#{setup_file['path']}"), 'w') { |file| file.print(Base64.decode64(blob['content'])) }
end
make_request(profile_tree_url)['tree']
# Select only base.yaml and base-empty.yaml
.select { |data| /^base(?:-empty)?\.yaml/ =~ data['path'] }
.each do |setup_file|
echo("downloading #{setup_file}") if @debug
blob = make_request(setup_file['url'])
File.open(File.join(SCRIPT_DIR, "profiles/#{setup_file['path']}"), 'w') { |file| file.print(Base64.decode64(blob['content'])) }
end
end

def setup_data
Expand Down Expand Up @@ -434,8 +437,10 @@ class ScriptManager
verify_or_make_dir File.join(SCRIPT_DIR, 'profiles')
profile_tree_url = get_status['tree'].find { |element| element['path'] == 'profiles' }['url']
make_request(profile_tree_url)['tree']
.select { |data| /^base.+yaml/ =~ data['path'] }
.reject { |setup_file| setup_file['sha'] == Settings['base_versions'][setup_file['path']] }
# Select only base.yaml and base-empty.yaml
.select { |data| /^base(?:-empty)?\.yaml/ =~ data['path'] }
# Reject files that exist, and have the same shasum as those on the repo.
.reject { |setup_file| File.exist?("profiles/#{setup_file['path']}") && setup_file['sha'] == Settings['base_versions'][setup_file['path']] }
.each do |setup_file|
echo("downloading #{setup_file}") if @debug
blob = make_request(setup_file['url'])
Expand All @@ -449,7 +454,8 @@ class ScriptManager
profile_tree_url = get_status['tree'].find { |element| element['path'] == 'data' }['url']
make_request(profile_tree_url)['tree']
.select { |data| /^base.+yaml/ =~ data['path'] }
.reject { |setup_file| setup_file['sha'] == Settings['base_versions'][setup_file['path']] }
# Reject files that exist, and have the same shasum as those on the repo.
.reject { |setup_file| File.exist?("data/#{setup_file['path']}") && setup_file['sha'] == Settings['base_versions'][setup_file['path']] }
.each do |setup_file|
echo("downloading #{setup_file}") if @debug
blob = make_request(setup_file['url'])
Expand Down

0 comments on commit ed615d4

Please sign in to comment.