class KnifeGithubRepoFork::GithubRepoFork
Public Instance Methods
run()
click to toggle source
# File lib/chef/knife/github_repo_fork.rb, line 41 def run # validate base options from base module. validate_base_options # Display information if debug mode is on. display_debug_info # Get the name_args from the command line name = name_args[0] name_args[1].nil? ? owner = locate_config_value('github_organizations').first : owner = name_args[1] target = name_args[2] unless name_args[2].nil? if owner.nil? || name.nil? || owner.empty? || name.empty? Chef::Log.error("Please specify a repository name like: name ") exit 1 end # Set params for the rest request params = {} params[:url] = @github_url + "/api/" + @github_api_version + "/repos/#{owner}/#{name}/forks" params[:body] = get_body_json(target) unless target.nil? params[:token] = get_github_token() #params[:response_code] = 202 params[:action] = "POST" # Execute the rest request username = ENV['USER'] connection.request(params) if target puts "Fork of #{name} is created in #{target}" else puts "Fork of #{name} is created in #{username}" end end