bu_pr 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +23 -7
- data/lib/bu_pr/configuration.rb +36 -12
- data/lib/bu_pr/handlers/github.rb +16 -12
- data/lib/bu_pr/railtie.rb +4 -6
- data/lib/bu_pr/version.rb +3 -1
- data/lib/bu_pr.rb +1 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8d6a26d015d99b0818e94691d0c9ac8f4ec3e024
|
4
|
+
data.tar.gz: 42188f7945e7571011501e85fd78fc597211c5f2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff2ac1be3f65db5a20da3a878686ee416b45a435bf4a66db2bdd48e08582d51a92f43c82a82bfcaa4af6261ef54b1497abea2ddcf36b7ee2cdd2bbb53693e074
|
7
|
+
data.tar.gz: 6c28f0f2a9bc0fcf6849c047bb00a072a3a89f85b139c0802ae4764e384de79a8cc284c06c612cf31c90078d19f3aeb0ef132772272a6b77033fb18d63b13bc7
|
data/README.md
CHANGED
@@ -24,28 +24,44 @@ Or install it yourself as:
|
|
24
24
|
|
25
25
|
Get Github access token from [this page](https://github.com/settings/tokens/new) with `repo` scope.
|
26
26
|
|
27
|
+
|
28
|
+
### Set configuration values as Environment variables.
|
29
|
+
|
30
|
+
```sh
|
31
|
+
# .bash_profile / .profile / .zshrc / etc.
|
32
|
+
|
33
|
+
export BUPR_TOKEN="xxx"
|
34
|
+
export BUPR_REPO="mmyoji/bu_pr"
|
35
|
+
# export BUPR_BRANCH="develop"
|
36
|
+
# export BUPR_TITLE="My bundle update"
|
37
|
+
```
|
38
|
+
|
39
|
+
|
40
|
+
### Set configuration values in config file.
|
41
|
+
|
27
42
|
```rb
|
28
43
|
require 'bu_pr'
|
29
44
|
|
30
45
|
# Setup
|
31
46
|
BuPr.configure do |config|
|
32
|
-
config.
|
33
|
-
config.
|
47
|
+
config.token = "xxx" # Required
|
48
|
+
config.repo = "mmyoji/bu_pr" # Required
|
34
49
|
|
35
|
-
config.
|
36
|
-
config.
|
50
|
+
config.branch = "develop" # Optional :: default is 'master'
|
51
|
+
config.title = "My bundle update" # Optional :: default is like 'Bundle update 2016-11-13'
|
37
52
|
end
|
38
53
|
|
39
54
|
BuPr::Runner.call
|
40
55
|
```
|
41
56
|
|
42
|
-
|
57
|
+
### Rails
|
43
58
|
|
44
59
|
```rb
|
45
60
|
# config/initializers/bu_pr.rb
|
61
|
+
|
46
62
|
BuPr.configure do |config|
|
47
|
-
config.
|
48
|
-
config.
|
63
|
+
config.token = "xxx"
|
64
|
+
config.repo = "mmyoji/bu_pr"
|
49
65
|
end
|
50
66
|
```
|
51
67
|
|
data/lib/bu_pr/configuration.rb
CHANGED
@@ -5,27 +5,51 @@ module BuPr
|
|
5
5
|
class Configuration
|
6
6
|
include Singleton
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
attr_accessor(
|
9
|
+
:branch,
|
10
|
+
:title,
|
11
|
+
:token,
|
12
|
+
:repo,
|
11
13
|
)
|
12
14
|
|
13
|
-
|
15
|
+
# DEPRECATED
|
16
|
+
alias access_token token
|
17
|
+
alias access_token= token=
|
18
|
+
alias base_branch branch
|
19
|
+
alias base_branch= branch=
|
20
|
+
alias pr_title title
|
21
|
+
alias pr_title= title=
|
22
|
+
alias repo_name repo
|
23
|
+
alias repo_name= repo=
|
14
24
|
|
15
25
|
def initialize
|
16
|
-
@
|
17
|
-
@
|
26
|
+
@branch = ENV.fetch("BUPR_BRANCH") { "master" }
|
27
|
+
@title = ENV.fetch("BUPR_TITLE") { "Bundle update #{Time.now.strftime('%F')}" }
|
18
28
|
|
19
|
-
@
|
20
|
-
@
|
29
|
+
@token = ENV["BUPR_TOKEN"]
|
30
|
+
@repo = ENV["BUPR_REPO"]
|
21
31
|
end
|
22
32
|
|
23
33
|
def valid?
|
24
|
-
|
25
|
-
|
34
|
+
token? && branch? && title? && repo?
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def token?
|
40
|
+
token && token != ""
|
41
|
+
end
|
42
|
+
|
43
|
+
def branch?
|
44
|
+
branch && branch != ""
|
45
|
+
end
|
46
|
+
|
47
|
+
def title?
|
48
|
+
title && title != ""
|
49
|
+
end
|
26
50
|
|
27
|
-
|
28
|
-
|
51
|
+
def repo?
|
52
|
+
repo && repo != ""
|
29
53
|
end
|
30
54
|
end
|
31
55
|
end
|
@@ -6,18 +6,22 @@ require "compare_linker"
|
|
6
6
|
module BuPr
|
7
7
|
module Handlers
|
8
8
|
class Github
|
9
|
-
attr_reader :base
|
9
|
+
attr_reader :base
|
10
|
+
attr_reader :current_branch
|
11
|
+
attr_reader :repo
|
12
|
+
attr_reader :title
|
13
|
+
attr_reader :token
|
10
14
|
attr_reader :linker
|
11
15
|
|
12
|
-
def initialize
|
16
|
+
def initialize attrs = {}
|
13
17
|
config = attrs[:config]
|
14
18
|
|
15
19
|
@current_branch = attrs[:current_branch]
|
16
20
|
|
17
|
-
@base = config.
|
18
|
-
@repo = config.
|
19
|
-
@title = config.
|
20
|
-
@token = config.
|
21
|
+
@base = config.branch
|
22
|
+
@repo = config.repo
|
23
|
+
@title = config.title
|
24
|
+
@token = config.token
|
21
25
|
end
|
22
26
|
|
23
27
|
def call
|
@@ -27,15 +31,15 @@ module BuPr
|
|
27
31
|
|
28
32
|
def create_pull_request
|
29
33
|
res = client.create_pull_request \
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
+
repo,
|
35
|
+
base,
|
36
|
+
current_branch,
|
37
|
+
title
|
34
38
|
|
35
39
|
res[:number]
|
36
40
|
end
|
37
41
|
|
38
|
-
def diff_comment
|
42
|
+
def diff_comment pr_number
|
39
43
|
load_linker(pr_number)
|
40
44
|
linker.add_comment repo, pr_number, comment_content
|
41
45
|
end
|
@@ -52,7 +56,7 @@ module BuPr
|
|
52
56
|
"#{linker.make_compare_links.to_a.join("\n")}"
|
53
57
|
end
|
54
58
|
|
55
|
-
def load_linker
|
59
|
+
def load_linker pr_number
|
56
60
|
ENV['OCTOKIT_ACCESS_TOKEN'] = token
|
57
61
|
|
58
62
|
@linker = ::CompareLinker.new repo, pr_number
|
data/lib/bu_pr/railtie.rb
CHANGED
@@ -1,11 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
load "bu_pr/tasks/bu_pr.rake"
|
8
|
-
end
|
3
|
+
module BuPr
|
4
|
+
class Railtie < ::Rails::Railtie
|
5
|
+
rake_tasks do
|
6
|
+
load "bu_pr/tasks/bu_pr.rake"
|
9
7
|
end
|
10
8
|
end
|
11
9
|
end
|
data/lib/bu_pr/version.rb
CHANGED
data/lib/bu_pr.rb
CHANGED
@@ -2,12 +2,9 @@
|
|
2
2
|
require "bu_pr/version"
|
3
3
|
require "bu_pr/configuration"
|
4
4
|
require "bu_pr/git"
|
5
|
-
|
6
5
|
require "bu_pr/handlers/github"
|
7
|
-
|
8
6
|
require "bu_pr/runner"
|
9
|
-
|
10
|
-
require "bu_pr/railtie"
|
7
|
+
require "bu_pr/railtie" if defined?(Rails::Railtie)
|
11
8
|
|
12
9
|
module BuPr
|
13
10
|
def configure
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bu_pr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Masaya Myojin
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-02-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: compare_linker
|