diff --git a/Gemfile b/Gemfile index 7bb120a..ea78874 100644 --- a/Gemfile +++ b/Gemfile @@ -21,7 +21,7 @@ group :assets do end gem 'jquery-rails' - +gem 'pry' # To use ActiveModel has_secure_password # gem 'bcrypt-ruby', '~> 3.0.0' diff --git a/Gemfile.lock b/Gemfile.lock index bb3b007..21b6a55 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -30,6 +30,7 @@ GEM multi_json (~> 1.0) arel (3.0.3) builder (3.0.4) + coderay (1.1.0) coffee-rails (3.2.2) coffee-script (>= 2.2.0) railties (~> 3.2.0) @@ -49,9 +50,14 @@ GEM mail (2.5.4) mime-types (~> 1.16) treetop (~> 1.4.8) + method_source (0.8.2) mime-types (1.25.1) multi_json (1.10.1) polyglot (0.3.5) + pry (0.9.12.6) + coderay (~> 1.0) + method_source (~> 0.8) + slop (~> 3.4) rack (1.4.5) rack-cache (1.2) rack (>= 0.4) @@ -82,6 +88,7 @@ GEM railties (~> 3.2.0) sass (>= 3.1.10) tilt (~> 1.3) + slop (3.6.0) sprockets (2.2.3) hike (~> 1.2) multi_json (~> 1.0) @@ -104,6 +111,7 @@ PLATFORMS DEPENDENCIES coffee-rails (~> 3.2.1) jquery-rails + pry rails (= 3.2.19) sass-rails (~> 3.2.3) sqlite3 diff --git a/README.md b/README.md new file mode 100644 index 0000000..b7ec413 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ + + + diff --git a/app/models/create_branch.rb b/app/models/create_branch.rb new file mode 100644 index 0000000..c903311 --- /dev/null +++ b/app/models/create_branch.rb @@ -0,0 +1,46 @@ +class CreateBranch + include Runable + attr_accessor :branch_name, :project, :username, :head + + def run + email = `git config --global user.email` + email_info = email.split "@" + @username = email_info[0] + # @project = "jeronpaul/capshare" + @project = "casejamesc/tester" + @head = "Authorization: token 532c22ea1b94c63a73198b73324712246bb0983b" + + create_branch + end + + def create_branch + branch_info = branch_name.split "#" + pr_title = branch_info[0] + issue_number = branch_info[1] + + puts "creating branch and initial commit..." + `git pull origin master; git checkout -b #{branch_name}; echo " " >> README.md; git commit -am "Create PRs [ci skip]"; git push origin HEAD;` + + # # CREATE PULL REQUEST + # puts "creating pr..." + # url = "https://api.github.com/repos/#{project}/pulls" + # data = "{ \"title\": \"Fixes ##{issue_number}: #{pr_title}\", \"body\": \"##{issue_number}\", \"head\": \"#{branch_name}\", \"base\": \"master\" }" + # pr_number = `curl --request POST --header \'#{head}\' --data \'#{data}\' #{url} | jq .number` + + # # ADD ASSIGNEE + # puts "assigning pr..." + # url = "https://api.github.com/repos/#{project}/issues/#{pr_number}" + # data = "{ \"assignee\": \"#{username}\" }" + # `curl --request PATCH --header \'#{head}\' --data \'#{data}\' #{url}` + + # # REMOVE LABELS + # puts "moving issue to in progress..." + # url = "https://api.github.com/repos/#{project}/issues/#{issue_number}/labels" + # `curl --request DELETE --header \'#{head}\' #{url}` + # sleep 1 + + # # ADD LABEL + # `curl --request POST --header \'#{head}\' --data '[ "In Progress" ]' #{url}` + end + +end \ No newline at end of file diff --git a/app/models/runable.rb b/app/models/runable.rb new file mode 100644 index 0000000..7cadaf2 --- /dev/null +++ b/app/models/runable.rb @@ -0,0 +1,14 @@ +module Runable + extend ActiveSupport::Concern + + included do + def self.run(*args) + new(*args).run + end + end + + def initialize(*args) + args.first.each {|k, v| self.send("#{k}=", v)} unless args.empty? || args.first.nil? + end + +end