Skip to content

Commit

Permalink
FIx bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
SpringMT authored and jpr-jenkins committed Feb 17, 2017
1 parent bcd212b commit b4580ba
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
1 change: 1 addition & 0 deletions Gemfile
Expand Up @@ -8,3 +8,4 @@ gem 'rack-lineprof'
gem 'resque'
gem 'rake'
gem 'compare_linker'
gem 'bundler'
1 change: 1 addition & 0 deletions Gemfile.lock
Expand Up @@ -69,6 +69,7 @@ PLATFORMS
ruby

DEPENDENCIES
bundler
compare_linker
foreman
rack
Expand Down
1 change: 1 addition & 0 deletions config.ru
@@ -1,5 +1,6 @@
require './rubocop_application.rb'
require './hello_application.rb'
require './bundle_update_application.rb'
require 'resque'
require 'resque/server'
require 'rack-lineprof'
Expand Down
17 changes: 11 additions & 6 deletions jobs/bundle_update_job.rb
@@ -1,6 +1,7 @@
require 'json'
require 'resque'
require 'compare_linker'
require 'bundler'

Resque.redis = 'redis://127.0.0.1:6379'
Resque.redis.namespace = "resque-hook"
Expand Down Expand Up @@ -47,8 +48,10 @@ def self.execute_bundle_update(organization:, pr_number:, repos_name:, full_repo
`git checkout #{branch_name}`

old_lockfile = Bundler::LockfileParser.new(Bundler.read_file("Gemfile.lock"))
`bundle install --path=vendor/bundle`
`bundle update`
Bundler.with_clean_env do
`bundle install --gemfile Gemfile --path vendor/bundle`
`bundle update`
end
new_lockfile = Bundler::LockfileParser.new(Bundler.read_file("Gemfile.lock"))

octokit ||= Octokit::Client.new(access_token: ENV["BUNDLE_UPDATE_OCTOKIT_ACCESS_TOKEN"])
Expand Down Expand Up @@ -86,18 +89,20 @@ def self.execute_bundle_update(organization:, pr_number:, repos_name:, full_repo
end

commit_result = `git commit -am 'bundle update'`

return [ 200, { 'Content-Type' => 'text/plain' }, ['UNNECESSARY RUBOCOP PERFECT!'] ] if commit_result.match(/nothing to commit \(working directory clean\)/)

p `git checkout -b #{branch_name}_bundle_update`
p `git push origin #{branch_name}_bundle_update`
`git checkout -b #{branch_name}_bundle_update`
`git push origin #{branch_name}_bundle_update`

https = Net::HTTP.new(GITHUB_HOST, '443')
https.use_ssl = true
https.start do |h|
req = Net::HTTP::Post.new("#{GITHUB_API_BASE_PATH}/#{full_repos_name}/pulls")
req["Authorization"] = "token #{TOKEN}"
req.body = {
title: "[Automatic PR] Bundle Update PR from #{full_repos_name}",
body: "@#{sender} bundle update result for #{html_url} \n#{compare_links}",
body: "@#{sender} bundle update result for #{html_url} \n#{compare_links.to_a.join("\n")}",
head: "#{organization}:#{branch_name}_bundle_update",
base: "#{branch_name}"
}.to_json
Expand Down

0 comments on commit b4580ba

Please sign in to comment.