Add basic progress output to GitHub import

parent f184cb43
...@@ -38,24 +38,33 @@ module Github ...@@ -38,24 +38,33 @@ module Github
self.reset_callbacks :validate self.reset_callbacks :validate
end end
attr_reader :project, :repository, :repo, :options, :errors, :cached attr_reader :project, :repository, :repo, :options, :errors, :cached, :verbose
def initialize(project, options) def initialize(project, options)
@project = project @project = project
@repository = project.repository @repository = project.repository
@repo = project.import_source @repo = project.import_source
@options = options @options = options
@verbose = options.fetch(:verbose, false)
@cached = Hash.new { |hash, key| hash[key] = Hash.new } @cached = Hash.new { |hash, key| hash[key] = Hash.new }
@errors = [] @errors = []
end end
# rubocop: disable Rails/Output
def execute def execute
puts 'Fetching repository...'.color(:aqua) if verbose
fetch_repository fetch_repository
puts 'Fetching labels...'.color(:aqua) if verbose
fetch_labels fetch_labels
puts 'Fetching milestones...'.color(:aqua) if verbose
fetch_milestones fetch_milestones
puts 'Fetching pull requests...'.color(:aqua) if verbose
fetch_pull_requests fetch_pull_requests
puts 'Fetching issues...'.color(:aqua) if verbose
fetch_issues fetch_issues
puts 'Cloning wiki repository...'.color(:aqua) if verbose
fetch_wiki_repository fetch_wiki_repository
puts 'Expiring repository cache...'.color(:aqua) if verbose
expire_repository_cache expire_repository_cache
true true
......
...@@ -7,7 +7,7 @@ class GithubImport ...@@ -7,7 +7,7 @@ class GithubImport
end end
def initialize(token, gitlab_username, project_path, extras) 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 @project_path = project_path
@current_user = User.find_by_username(gitlab_username) @current_user = User.find_by_username(gitlab_username)
@github_repo = extras.empty? ? nil : extras.first @github_repo = extras.empty? ? nil : extras.first
...@@ -28,7 +28,7 @@ class GithubImport ...@@ -28,7 +28,7 @@ class GithubImport
private private
def show_warning! 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) puts "Permission checks are ignored. Press any key to continue.".color(:red)
STDIN.getch STDIN.getch
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment