circleci-bundle-update-pr 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: af46f482184430cacf6bd66bb298229489fc29af
4
+ data.tar.gz: 9b19b6e84482be00f497cf457c1a50d8513fc611
5
+ SHA512:
6
+ metadata.gz: 5f5ba4200a7c2a6e239b41924deb35bfdb91f826ec88419bc69fb8e168416cffc91bd7b98988cbb1f777b2314229f9e62d538e3e54f7982a027257ece4b37a7b
7
+ data.tar.gz: 42a4848c2c72737c743e7c4152c91f9b7a4090927e893e678025c39dde1a9bb524af1ad70cbea63073a8327f2fe259e2a1f1c2a20bb958279ad6581beea9fee9
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ /.bundle
2
+ /.envrc
3
+ /pkg
4
+ /vendor/bundle
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in circleci-bundle-update-pr.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,32 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ circleci-bundle-update-pr (0.0.1)
5
+ compare_linker
6
+ octokit (~> 3.8)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ addressable (2.3.7)
12
+ compare_linker (1.1.1)
13
+ httpclient
14
+ octokit
15
+ faraday (0.9.1)
16
+ multipart-post (>= 1.2, < 3)
17
+ httpclient (2.6.0.1)
18
+ multipart-post (2.0.0)
19
+ octokit (3.8.0)
20
+ sawyer (~> 0.6.0, >= 0.5.3)
21
+ rake (10.4.2)
22
+ sawyer (0.6.0)
23
+ addressable (~> 2.3.5)
24
+ faraday (~> 0.8, < 0.10)
25
+
26
+ PLATFORMS
27
+ ruby
28
+
29
+ DEPENDENCIES
30
+ bundler (~> 1.7)
31
+ circleci-bundle-update-pr!
32
+ rake (~> 10.0)
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Takashi Masuda
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # Circleci::Bundle::Update::Pr
2
+
3
+ circleci-bundle-update-pr is a script for continues bundle update. Use in CircleCI
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'circleci-bundle-update-pr'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install circleci-bundle-update-pr
20
+
21
+ ## Usage
22
+
23
+ $ circleci-bundle-update-pr 'Git Usename' 'Git email address'
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it ( https://github.com/[my-github-username]/circleci-bundle-update-pr/fork )
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "circleci/bundle/update/pr"
4
+
5
+ Circleci::Bundle::Update::Pr.create_if_needed(git_username: ARGV[0], git_email: ARGV[1])
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'circleci/bundle/update/pr/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "circleci-bundle-update-pr"
8
+ spec.version = Circleci::Bundle::Update::Pr::VERSION
9
+ spec.authors = ["Takashi Masuda"]
10
+ spec.email = ["masutaka.net@gmail.com"]
11
+ spec.summary = %q{Create GitHub PullRequest of bundle update in CircleCI}
12
+ spec.description = %q{circleci-bundle-update-pr is a script for continues bundle update. Use in CircleCI}
13
+ spec.homepage = "https://github.com/masutaka/circleci-bundle-update-pr"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency 'octokit', '~> 3.8'
22
+ spec.add_dependency 'compare_linker'
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.7"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ end
@@ -0,0 +1,63 @@
1
+ require "circleci/bundle/update/pr/version"
2
+ require "octokit"
3
+ require "compare_linker"
4
+
5
+ module Circleci
6
+ module Bundle
7
+ module Update
8
+ module Pr
9
+ def self.create_if_needed(git_username: nil, git_email: nil)
10
+ raise "$CIRCLE_PROJECT_USERNAME isn't set" unless ENV['CIRCLE_PROJECT_USERNAME']
11
+ raise "$CIRCLE_PROJECT_REPONAME isn't set" unless ENV['CIRCLE_PROJECT_REPONAME']
12
+ raise "$GITHUB_ACCESS_TOKEN isn't set" unless ENV['GITHUB_ACCESS_TOKEN']
13
+ return unless need?
14
+ repo_full_name = "#{ENV['CIRCLE_PROJECT_USERNAME']}/#{ENV['CIRCLE_PROJECT_REPONAME']}"
15
+ now = Time.now
16
+ branch = "bundle-update-#{now.strftime('%Y%m%d')}"
17
+ create_branch(git_username, git_email, branch)
18
+ pull_request = create_pull_request(repo_full_name, branch, now)
19
+ add_comment_of_compare_linker(repo_full_name, pull_request[:number])
20
+ end
21
+
22
+ def self.need?
23
+ system("bundle update")
24
+ `git status -sb 2> /dev/null`.include?("Gemfile.lock")
25
+ end
26
+ private_class_method :need?
27
+
28
+ def self.create_branch(git_username, git_email, branch)
29
+ system("git config user.name #{git_username}")
30
+ system("git config user.email #{git_email}")
31
+ system("git add Gemfile.lock")
32
+ system("git commit -m '$ bundle update'")
33
+ system("git branch -M #{branch}")
34
+ system("git push origin #{branch}")
35
+ end
36
+ private_class_method :create_branch
37
+
38
+ def self.create_pull_request(repo_full_name, branch, now)
39
+ title = "bundle update #{now.strftime('%Y-%m-%d')}"
40
+ body = "auto generated by [CircleCI of #{ENV['CIRCLE_PROJECT_REPONAME']}](https://circleci.com/gh/#{repo_full_name})"
41
+ client = Octokit::Client.new(access_token: ENV["GITHUB_ACCESS_TOKEN"])
42
+ client.create_pull_request(repo_full_name, "master", branch, title, body)
43
+ end
44
+ private_class_method :create_pull_request
45
+
46
+ def self.add_comment_of_compare_linker(repo_full_name, pr_number)
47
+ ENV["OCTOKIT_ACCESS_TOKEN"] = ENV["GITHUB_ACCESS_TOKEN"]
48
+ compare_linker = CompareLinker.new(repo_full_name, pr_number)
49
+ compare_linker.formatter = CompareLinker::Formatter::Markdown.new
50
+
51
+ comment = <<-EOC
52
+ #{compare_linker.make_compare_links.to_a.join("\n")}
53
+
54
+ Powered by [compare_linker](https://rubygems.org/gems/compare_linker)
55
+ EOC
56
+
57
+ compare_linker.add_comment(repo_full_name, pr_number, comment)
58
+ end
59
+ private_class_method :add_comment_of_compare_linker
60
+ end
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,9 @@
1
+ module Circleci
2
+ module Bundle
3
+ module Update
4
+ module Pr
5
+ VERSION = "0.0.1"
6
+ end
7
+ end
8
+ end
9
+ end
metadata ADDED
@@ -0,0 +1,112 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: circleci-bundle-update-pr
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Takashi Masuda
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-03-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: octokit
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.8'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.8'
27
+ - !ruby/object:Gem::Dependency
28
+ name: compare_linker
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.7'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.7'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ description: circleci-bundle-update-pr is a script for continues bundle update. Use
70
+ in CircleCI
71
+ email:
72
+ - masutaka.net@gmail.com
73
+ executables:
74
+ - circleci-bundle-update-pr
75
+ extensions: []
76
+ extra_rdoc_files: []
77
+ files:
78
+ - ".gitignore"
79
+ - Gemfile
80
+ - Gemfile.lock
81
+ - LICENSE.txt
82
+ - README.md
83
+ - Rakefile
84
+ - bin/circleci-bundle-update-pr
85
+ - circleci-bundle-update-pr.gemspec
86
+ - lib/circleci/bundle/update/pr.rb
87
+ - lib/circleci/bundle/update/pr/version.rb
88
+ homepage: https://github.com/masutaka/circleci-bundle-update-pr
89
+ licenses:
90
+ - MIT
91
+ metadata: {}
92
+ post_install_message:
93
+ rdoc_options: []
94
+ require_paths:
95
+ - lib
96
+ required_ruby_version: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ required_rubygems_version: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ version: '0'
106
+ requirements: []
107
+ rubyforge_project:
108
+ rubygems_version: 2.4.5
109
+ signing_key:
110
+ specification_version: 4
111
+ summary: Create GitHub PullRequest of bundle update in CircleCI
112
+ test_files: []