41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
# File 'lib/chef/knife/github_repo_fork.rb', line 41
def run
validate_base_options
display_debug_info
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
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[:action] = "POST"
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
|