Add basic progress output to GitHub import

This commit is contained in:
Douglas Barbosa Alexandre 2017-04-25 23:47:49 -03:00
parent f184cb433b
commit d082b78998
2 changed files with 12 additions and 3 deletions

View File

@ -38,24 +38,33 @@ module Github
self.reset_callbacks :validate
end
attr_reader :project, :repository, :repo, :options, :errors, :cached
attr_reader :project, :repository, :repo, :options, :errors, :cached, :verbose
def initialize(project, options)
@project = project
@repository = project.repository
@repo = project.import_source
@options = options
@verbose = options.fetch(:verbose, false)
@cached = Hash.new { |hash, key| hash[key] = Hash.new }
@errors = []
end
# rubocop: disable Rails/Output
def execute
puts 'Fetching repository...'.color(:aqua) if verbose
fetch_repository
puts 'Fetching labels...'.color(:aqua) if verbose
fetch_labels
puts 'Fetching milestones...'.color(:aqua) if verbose
fetch_milestones
puts 'Fetching pull requests...'.color(:aqua) if verbose
fetch_pull_requests
puts 'Fetching issues...'.color(:aqua) if verbose
fetch_issues
puts 'Cloning wiki repository...'.color(:aqua) if verbose
fetch_wiki_repository
puts 'Expiring repository cache...'.color(:aqua) if verbose
expire_repository_cache
true

View File

@ -7,7 +7,7 @@ class GithubImport
end
def initialize(token, gitlab_username, project_path, extras)
@options = { url: 'https://api.github.com', token: token }
@options = { url: 'https://api.github.com', token: token, verbose: true }
@project_path = project_path
@current_user = User.find_by_username(gitlab_username)
@github_repo = extras.empty? ? nil : extras.first
@ -28,7 +28,7 @@ class GithubImport
private
def show_warning!
puts "This will import GH #{@repo['full_name'].bright} into GL #{@project_path.bright} as #{@current_user.name}"
puts "This will import GitHub #{@repo['full_name'].bright} into GitLab #{@project_path.bright} as #{@current_user.name}"
puts "Permission checks are ignored. Press any key to continue.".color(:red)
STDIN.getch