circleci-bundle-update-pr 1.2.2 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0bd4edd9718877715240838f632167af5ee6c194
4
- data.tar.gz: 3371dc34677ee4db20edffd9aba415c0d443d4a9
3
+ metadata.gz: 7e0b523fa54d4c022d06def3817c1f066b956491
4
+ data.tar.gz: bb96632512394aa32a14e15631290439e660272a
5
5
  SHA512:
6
- metadata.gz: b3947dafe50e1ea7558100300013da90524e985a4fa1d87cd9196cd7d2cb13e9eebe7063e9f73180a10546101fd7955e3158ced60c233b5645776090d65f03f2
7
- data.tar.gz: 077800b88aa7619c23472b07518c9a2abdcc8bce66641cd9e2d4774052b30bb5373bffdf8698f245999c7be6a46f965dba0f89d24612b807d4923c5600fea0cc
6
+ metadata.gz: 0bc037c1762dd54bafff5b7578f1082d1988cf7e844e0ab24d4e7bc13d50effe1b0a92c0215ecf934c417e98fe398b768e8bc17200819e84e8dfe5ba8dc37803
7
+ data.tar.gz: 580eb8bb08d85256a6fd351fb7bc9f9f000d470403ef0de7048492f4c0b082a4ee0552285afe1db62eb551085293e73689c4a550dd8df19a1a15bac0fd5b90d8
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- circleci-bundle-update-pr (1.2.2)
4
+ circleci-bundle-update-pr (1.3.0)
5
5
  compare_linker
6
6
  octokit (~> 3.8)
7
7
 
data/README.md CHANGED
@@ -20,7 +20,11 @@ Or install it yourself as:
20
20
 
21
21
  ## Usage
22
22
 
23
- $ circleci-bundle-update-pr 'Git Usename' 'Git email address'
23
+ $ circleci-bundle-update-pr 'Git username' 'Git email address'
24
+
25
+ By default, it works only on master branch, but you can also explicitly specify any branches rather than only master branch by adding them to the arguments.
26
+
27
+ $ circleci-bundle-update-pr 'Git username' 'Git email address' master develop topic
24
28
 
25
29
  ## Contributing
26
30
 
@@ -2,4 +2,4 @@
2
2
 
3
3
  require "circleci/bundle/update/pr"
4
4
 
5
- Circleci::Bundle::Update::Pr.create_if_needed(git_username: ARGV[0], git_email: ARGV[1])
5
+ Circleci::Bundle::Update::Pr.create_if_needed(git_username: ARGV.shift, git_email: ARGV.shift, git_branches: ARGV.empty? ? ["master"] : ARGV)
@@ -6,21 +6,25 @@ module Circleci
6
6
  module Bundle
7
7
  module Update
8
8
  module Pr
9
- def self.create_if_needed(git_username: nil, git_email: nil)
9
+ def self.create_if_needed(git_username: nil, git_email: nil, git_branches: ["master"])
10
10
  raise "$CIRCLE_PROJECT_USERNAME isn't set" unless ENV['CIRCLE_PROJECT_USERNAME']
11
11
  raise "$CIRCLE_PROJECT_REPONAME isn't set" unless ENV['CIRCLE_PROJECT_REPONAME']
12
12
  raise "$GITHUB_ACCESS_TOKEN isn't set" unless ENV['GITHUB_ACCESS_TOKEN']
13
- return unless need?
13
+ return unless need?(git_branches)
14
14
  repo_full_name = "#{ENV['CIRCLE_PROJECT_USERNAME']}/#{ENV['CIRCLE_PROJECT_REPONAME']}"
15
15
  now = Time.now
16
16
  branch = "bundle-update-#{now.strftime('%Y%m%d%H%M%S')}"
17
+
18
+ git_username ||= client.user.login
19
+ git_email ||= "#{git_username}@users.noreply.github.com"
20
+
17
21
  create_branch(git_username, git_email, branch)
18
22
  pull_request = create_pull_request(repo_full_name, branch, now)
19
23
  add_comment_of_compare_linker(repo_full_name, pull_request[:number])
20
24
  end
21
25
 
22
- def self.need?
23
- return false unless ENV['CIRCLE_BRANCH'] == "master"
26
+ def self.need?(git_branches)
27
+ return false unless git_branches.include?(ENV['CIRCLE_BRANCH'])
24
28
  system("bundle update")
25
29
  `git status -sb 2> /dev/null`.include?("Gemfile.lock")
26
30
  end
@@ -39,8 +43,7 @@ module Circleci
39
43
  def self.create_pull_request(repo_full_name, branch, now)
40
44
  title = "bundle update at #{now.strftime('%Y-%m-%d %H:%M:%S %Z')}"
41
45
  body = "auto generated by [CircleCI of #{ENV['CIRCLE_PROJECT_REPONAME']}](https://circleci.com/gh/#{repo_full_name})"
42
- client = Octokit::Client.new(access_token: ENV["GITHUB_ACCESS_TOKEN"])
43
- client.create_pull_request(repo_full_name, "master", branch, title, body)
46
+ client.create_pull_request(repo_full_name, ENV['CIRCLE_BRANCH'], branch, title, body)
44
47
  end
45
48
  private_class_method :create_pull_request
46
49
 
@@ -58,6 +61,11 @@ Powered by [compare_linker](https://rubygems.org/gems/compare_linker)
58
61
  compare_linker.add_comment(repo_full_name, pr_number, comment)
59
62
  end
60
63
  private_class_method :add_comment_of_compare_linker
64
+
65
+ def self.client
66
+ Octokit::Client.new(access_token: ENV["GITHUB_ACCESS_TOKEN"])
67
+ end
68
+ private_class_method :client
61
69
  end
62
70
  end
63
71
  end
@@ -2,7 +2,7 @@ module Circleci
2
2
  module Bundle
3
3
  module Update
4
4
  module Pr
5
- VERSION = "1.2.2"
5
+ VERSION = "1.3.0"
6
6
  end
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: circleci-bundle-update-pr
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takashi Masuda
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-13 00:00:00.000000000 Z
11
+ date: 2015-11-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: octokit