Skip to content
This repository has been archived by the owner on Nov 19, 2024. It is now read-only.

Commit

Permalink
Facilitate rake update tasks (#7841)
Browse files Browse the repository at this point in the history
Do not pull updates for submodules at subrepos
Read directories with subrepos from Docfile instead of hardcoded
Instantiate content map only once and reuse in tasks
  • Loading branch information
dshevtsov authored Sep 8, 2020
1 parent 5459b76 commit cadef64
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
3 changes: 3 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ require 'colorator'
# Require helper methods from the 'lib' directory
Dir.glob('lib/**/*.rb') { |file| require_relative(file) }

# Instantiate Docfile data for usage in tasks
@content_map = DocConfig.new.content_map

desc "Same as 'rake', 'rake preview'"
task default: %w[preview]

Expand Down
6 changes: 2 additions & 4 deletions rakelib/multirepo.rake
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,15 @@ namespace :multirepo do
desc 'Create a file tree for devdocs website and get all required content'
task :init do
protocol = ENV['token'] ? "https://#{ENV['token']}@github.com/" : 'git@github.com:'
content_map = DocConfig.new.content_map
content_map.each do |subrepo|
@content_map.each do |subrepo|
repo_url = protocol + subrepo['repository'] + '.git'
add_subrepo(subrepo['directory'], repo_url , subrepo['branch'], subrepo['filter'])
end
end

desc 'Reinitialize subrepositories. CAUTION: This will remove directories and associated git repositories listed in Docfile'
task reinit: %w[clean] do
content_map = DocConfig.new.content_map
content_map.each do |subrepo|
@content_map.each do |subrepo|
if subrepo['directory']
puts "Removing #{subrepo['directory']}".yellow
sh 'rm', '-rf', subrepo['directory']
Expand Down
11 changes: 9 additions & 2 deletions rakelib/update.rake
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,21 @@ namespace :update do
task all: %w[devdocs subrepos]

desc 'Update subrepositories only'
task subrepos: %w[mbi pb pbm mftf]
task :subrepos do
@content_map.each do |subrepo|
update_dir subrepo['directory']
end
end
end

def update_dir(dir)
abort "Cannot find the #{dir} directory. You can run 'rake init' to create it and rerun 'rake update:all' again.".red unless Dir.exist? dir
Dir.chdir dir do
puts "Updating #{dir}:".magenta

next warn "No branch to update" if `git status -sb`.include? 'no branch'
sh 'git remote -v'
sh 'git pull'
sh 'git pull --no-recurse-submodules'
sh 'git status -sb'
end
end

0 comments on commit cadef64

Please sign in to comment.