pr_comet 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/bin/release +6 -4
- data/lib/pr_comet/version.rb +1 -1
- data/lib/pr_comet.rb +44 -21
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 85cd89906ec3936b19baf0285df362c1c85e174b3e629b3561606ce2603da969
|
4
|
+
data.tar.gz: 315b3d930e793c616a3e141acf8c1cbf21212b4ac18f22515588b4e3a00e8457
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a6ec85517c9fae4c6fd3bef6bdfeeae6616d8e9737eef41e1901f7e483e1f92572dff967c2f8202d58df4c99a648a6291cd5d104c532762d80e48b67590060ab
|
7
|
+
data.tar.gz: 625ac832cb54b16f2d868c47c3453c7e0fd826c056cf8912259f5ffadb1fdcf1daaa39f3487434e4a963cc62131678776cc6b96bf38fd8b0cd47c2878c713569
|
data/Gemfile.lock
CHANGED
data/bin/release
CHANGED
@@ -8,14 +8,15 @@ require 'pr_comet'
|
|
8
8
|
|
9
9
|
VERSION_FORMAT = /\A\d+\.\d+\.\d+(\.(pre|beta|rc)\d?)?\z/.freeze
|
10
10
|
version = ARGV[0]
|
11
|
-
|
11
|
+
update_pr = PrComet.new(base: 'master', branch: "update/v#{version}")
|
12
|
+
release_pr = PrComet.new(base: 'production', branch: 'master')
|
12
13
|
|
13
14
|
# Verifying
|
14
15
|
abort 'usage: bin/release VERSION' if version.nil?
|
15
16
|
abort 'A version must be like a `1.2.3`' unless version =~ VERSION_FORMAT
|
16
17
|
|
17
18
|
# Modify a version file
|
18
|
-
|
19
|
+
update_pr.commit ':comet: Update version' do
|
19
20
|
File.write('lib/pr_comet/version.rb', <<~VERSION)
|
20
21
|
# frozen_string_literal: true
|
21
22
|
|
@@ -26,9 +27,10 @@ pr_comet.commit ':comet: Update version' do
|
|
26
27
|
end
|
27
28
|
|
28
29
|
# Bundle Update
|
29
|
-
|
30
|
+
update_pr.commit ':comet: Run $ bundle update' do
|
30
31
|
`bundle update`
|
31
32
|
end
|
32
33
|
|
33
34
|
# Create a pull request
|
34
|
-
|
35
|
+
update_pr.create!(title: "Update v#{version}", body: '')
|
36
|
+
release_pr.create!(title: "Release v#{version}", body: '', validate: false)
|
data/lib/pr_comet/version.rb
CHANGED
data/lib/pr_comet.rb
CHANGED
@@ -42,44 +42,67 @@ class PrComet
|
|
42
42
|
result
|
43
43
|
end
|
44
44
|
|
45
|
-
# Create a pull request
|
46
|
-
#
|
45
|
+
# Create a pull request. You should call #commit before calling this method.
|
46
|
+
# If you want to create a blank PR, you can do it with `validate: false`
|
47
|
+
# option.
|
47
48
|
#
|
48
|
-
# @param
|
49
|
-
#
|
50
|
-
# @
|
49
|
+
# @param options [Hash]
|
50
|
+
# Options for the PR creation.
|
51
|
+
# @option title [String]
|
52
|
+
# The title for the pull request
|
53
|
+
# @option body [String]
|
54
|
+
# The body for the pull request
|
55
|
+
# @option labels [Array<String>]
|
51
56
|
# List of labels. It is a optional parameter. You can add labels to the
|
52
57
|
# created PR.
|
53
|
-
# @
|
58
|
+
# @option project_column_name [String]
|
54
59
|
# A project column name. It is a optional parameter. You can add the created
|
55
60
|
# PR to the GitHub project.
|
56
|
-
# @
|
61
|
+
# @option project_id [Integer]
|
57
62
|
# A target project ID. It is a optional parameter. If does not supplied,
|
58
63
|
# this method will find a project which associated the repository.
|
59
|
-
# When the repository
|
60
|
-
#
|
61
|
-
#
|
62
|
-
|
63
|
-
|
64
|
+
# When the repository is associated with multiple projects, you should
|
65
|
+
# supply this.
|
66
|
+
# @option validate [Boolean]
|
67
|
+
# Verifies the branch has commits and checkout to the topic branch. If you
|
68
|
+
# want to create a blank PR, set "false" to this option. default: true.
|
69
|
+
# @return [Boolean]
|
70
|
+
# Return true if it is successed.
|
71
|
+
# rubocop:disable Metrics/AbcSize
|
72
|
+
def create!(**options)
|
73
|
+
options[:validate] = true if options[:validate].nil?
|
74
|
+
return false if options[:validate] && !git_condition_valid?
|
64
75
|
|
65
76
|
git.push(github_token_url, topic_branch)
|
66
|
-
pr_number = github.create_pull_request(
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
unless project_column_name.nil?
|
71
|
-
github.add_to_project(
|
72
|
-
pr_number, column_name: project_column_name, project_id: project_id
|
73
|
-
)
|
77
|
+
pr_number = github.create_pull_request(generate_create_pr_options(options))
|
78
|
+
github.add_labels(pr_number, *options[:labels]) unless options[:labels].nil?
|
79
|
+
unless options[:project_column_name].nil?
|
80
|
+
github.add_to_project(pr_number, generate_add_to_project_options(options))
|
74
81
|
end
|
75
82
|
true
|
76
83
|
end
|
77
|
-
# rubocop:enable Metrics/AbcSize
|
84
|
+
# rubocop:enable Metrics/AbcSize
|
78
85
|
|
79
86
|
private
|
80
87
|
|
81
88
|
attr_reader :git, :github, :base_branch, :topic_branch, :initial_sha1
|
82
89
|
|
90
|
+
def generate_create_pr_options(**options)
|
91
|
+
{
|
92
|
+
base: base_branch,
|
93
|
+
head: topic_branch,
|
94
|
+
title: options[:title],
|
95
|
+
body: options[:body]
|
96
|
+
}
|
97
|
+
end
|
98
|
+
|
99
|
+
def generate_add_to_project_options(**options)
|
100
|
+
{
|
101
|
+
column_name: options[:project_column_name],
|
102
|
+
project_id: options[:project_id]
|
103
|
+
}
|
104
|
+
end
|
105
|
+
|
83
106
|
def git_condition_valid?
|
84
107
|
!git.current_sha1?(initial_sha1) && git.current_branch?(topic_branch)
|
85
108
|
end
|