diff --git a/.template/ISSUE_TEMPLATE.md b/.template/ISSUE_TEMPLATE.md new file mode 100644 index 0000000..d482e71 --- /dev/null +++ b/.template/ISSUE_TEMPLATE.md @@ -0,0 +1,8 @@ +# 概要 + +# 関連するissue + +# 発生条件 + +# 備考 + diff --git a/.template/PULL_REQUEST_TEMPLATE.md b/.template/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..265cba3 --- /dev/null +++ b/.template/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,10 @@ +# Issue番号 + +# 概要 + +# 変更点 + +# 備考 + +# 確認事項 +[] Done testing diff --git a/script/create_repo.rb b/script/create_repo.rb new file mode 100644 index 0000000..5e9cbe4 --- /dev/null +++ b/script/create_repo.rb @@ -0,0 +1,92 @@ +# +require 'json' + +##### Set parameters +argc = ARGV.size +script_exec_name = $0 +user = ARGV[0] +org = ARGV[1] +reponame = ARGV[2] +clone_dir = ARGV[3] +script_dir = File.dirname(File.expand_path(script_exec_name)) +script_name = File.basename(script_exec_name) +ext_name = File.extname(File.basename(script_exec_name, ".rb")) +mode = ext_name[1, ext_name.size - 1] +description = "Repository_for_#{reponame}" + +##### +if (mode == "gitbucket") then + target = "GitBucket" + template_dir = ".gitbucket" + protocol = "http" + host_name = "192.168.100.70:8086/gitbucket" + git_location = "git/" + repo_hash = { + "\"name\"" => "\"#{reponame}\"", + "\"fullname\"" => "\"#{reponame}\"", + "\"description\"" => "\"#{description}\"", + "\"private\"" => false + } +else + target = "GitHub" + template_dir = ".github" + protocol = "https" + host_name = "github.com" + git_location = "" + repo_hash = { + "\"name\"" => "\"#{reponame}\"", + "\"description\"" => "\"#{description}\"", + "\"homepage\"" => "\"\"", + "\"private\"" => false, + "\"has_issues\"" => true, + "\"has_projects\"" => true, + "\"has_wiki\"" => true + } +end + +##### +repo_param = JSON.dump(repo_hash) +api_end_point = "#{protocol}://#{host_name}/api/v3" +git_base_url = "#{protocol}://#{host_name}" + +##### +if (argc != 4) then + puts "Create empty repository on #{target}" + puts "Usage : #{script_exec_name} " + exit 1 +end + +##### Organization setting +if ( org == "-" ) or ( org == user ) then + org = user + access_url = "#{api_end_point}/user/repos" +else + access_url = "#{api_end_point}/orgs/#{org}/repos" +end +git_url = "#{git_base_url}/#{git_location}#{org}/#{reponame}.git" + +##### +str="curl -u #{user} -i #{access_url} -d \"#{repo_param}\" --trace-ascii trace.curl.log" +system(str) + +puts "Debug : #{repo_param}" + +##### +cur_dir=`pwd` +if File.exist?(reponame) then + system("cd #{cur_dir}") + puts "Error : Exist #[clone_dir]" + exit 1 +end + +##### +puts "URI = #{git_url}" +puts "account = #{user}" +puts "orgnization = #{org}" +puts "repo = #{reponame}" + +##### +str="cd #{clone_dir} && mkdir #{reponame} && cd #{reponame} && cp -p -R #{script_dir}/../.template ./#{template_dir}/ && cp -p -R #{script_dir}/../.gitattributes ./ && cp -p -R #{script_dir}/../.gitignore ./ && echo \"#{reponame}\n===============\n\" > ./README.md && git init && git add #{template_dir}/ISSUE_TEMPLATE.md #{template_dir}/PULL_REQUEST_TEMPLATE.md .gitattributes .gitignore README.md && git commit -m \"First commit\" && git remote add origin #{git_url} && git push -u origin master && git checkout -b develop && git push -u origin develop" +system(str) + +system("cd #{cur_dir}")