Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down
8 changes: 8 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -104,6 +111,7 @@ PLATFORMS
DEPENDENCIES
coffee-rails (~> 3.2.1)
jquery-rails
pry
rails (= 3.2.19)
sass-rails (~> 3.2.3)
sqlite3
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@



46 changes: 46 additions & 0 deletions app/models/create_branch.rb
Original file line number Diff line number Diff line change
@@ -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
14 changes: 14 additions & 0 deletions app/models/runable.rb
Original file line number Diff line number Diff line change
@@ -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