ellen-github 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c3b81594571f777fd7b3ec92edd882a1cf9c452c
4
- data.tar.gz: a7646dc959bc767b270023ed4cae94af3175ee60
3
+ metadata.gz: acc3355f699b0715fe2bbd77cb56120ca7b30dfb
4
+ data.tar.gz: 2d12f467990c9540efd11f3b7bf319023dd456cb
5
5
  SHA512:
6
- metadata.gz: 91e782c4c2214b22958ffe89d9905ccc49a80ea65545d8ae2a3426349f7f8b2f58c7d69da9d7c6aabcf64f733dc6f659065adec9aa9baf64be9d20395e7827a0
7
- data.tar.gz: 52834342144e33db97ce85eaf335b9adcc195a229d15f8bddc6df32acbf8f8a572589dc71a70f0eee30c0e65a89644ba0c7da7a55f769249da18516818c7f813
6
+ metadata.gz: b05fcd753f224264804dcf5bf45e883ad344980a2986f4bbd84996f220a2281ddd88fa20e542234c478714ea2b71b33935a3dd18edf70b3287d992267e0eaf7f
7
+ data.tar.gz: c30249315c4064329e08216f053d96903b06e227dfd5d03a272570e7cedd9e37e3a7936d11b9577d54be4c86011c5201add2c79257611f36dabdecda196ab439
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 0.0.6
2
+ * Add Create & Merge Pull Request commands
3
+
1
4
  ## 0.0.5
2
5
  * Description support
3
6
 
data/README.md CHANGED
@@ -9,8 +9,8 @@ gem "ellen-github"
9
9
 
10
10
  ## Usage
11
11
  ```
12
- @ellen close issue <username>/<repository>#<number> - Close an Issue
13
- @ellen create issue "<title>" on <username>/<repository> - Create a new Issue
12
+ @ellen close issue <repo>#<number> - Close an Issue
13
+ @ellen create issue "<title>" on <repo>[\n<description>] - Create a new Issue
14
14
  @ellen remember my github token <token> - Remember sender's GitHub access token
15
15
  ```
16
16
 
Binary file
@@ -1,5 +1,3 @@
1
- require "octokit"
2
-
3
1
  module Ellen
4
2
  module Github
5
3
  module Actions
@@ -1,5 +1,3 @@
1
- require "octokit"
2
-
3
1
  module Ellen
4
2
  module Github
5
3
  module Actions
@@ -0,0 +1,74 @@
1
+ module Ellen
2
+ module Github
3
+ module Actions
4
+ class CreatePullRequest < Base
5
+ def call
6
+ if has_access_token?
7
+ create
8
+ else
9
+ require_access_token
10
+ end
11
+ end
12
+
13
+ private
14
+
15
+ def create
16
+ message.reply("Created #{pull_request.html_url}")
17
+ rescue Octokit::Unauthorized
18
+ message.reply("Failed in authentication (401)")
19
+ rescue Octokit::NotFound
20
+ message.reply("Could not find that repository")
21
+ rescue => exception
22
+ message.reply("Failed by #{exception.class} #{exception}")
23
+ end
24
+
25
+ def pull_request
26
+ client.create_pull_request(repository, base, head, title, description)
27
+ end
28
+
29
+ def title
30
+ message[:title]
31
+ end
32
+
33
+ def description
34
+ message[:description]
35
+ end
36
+
37
+ # e.g. alice/foo:test
38
+ def from
39
+ message[:from]
40
+ end
41
+
42
+ # e.g. alice
43
+ def from_user
44
+ from.split("/").first
45
+ end
46
+
47
+ # e.g. test
48
+ def from_branch
49
+ from.split(":").last
50
+ end
51
+
52
+ # e.g. bob/foo:master
53
+ def to
54
+ message[:to]
55
+ end
56
+
57
+ # e.g. bob/foo
58
+ def repository
59
+ to.split(":").first
60
+ end
61
+
62
+ # e.g. alice:test
63
+ def head
64
+ "#{from_user}:#{from_branch}"
65
+ end
66
+
67
+ # e.g. master
68
+ def base
69
+ to.split(":").last
70
+ end
71
+ end
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,18 @@
1
+ module Ellen
2
+ module Github
3
+ module Actions
4
+ class MergePullRequest < CloseIssue
5
+ private
6
+
7
+ def close
8
+ request
9
+ message.reply("Merged #{issue.html_url}")
10
+ end
11
+
12
+ def request
13
+ client.merge_pull_request(repository, issue_number)
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -1,5 +1,5 @@
1
1
  module Ellen
2
2
  module Github
3
- VERSION = "0.0.5"
3
+ VERSION = "0.0.6"
4
4
  end
5
5
  end
data/lib/ellen/github.rb CHANGED
@@ -5,6 +5,8 @@ require "ellen"
5
5
  require "ellen/github/actions/base"
6
6
  require "ellen/github/actions/close_issue"
7
7
  require "ellen/github/actions/create_issue"
8
+ require "ellen/github/actions/create_pull_request"
9
+ require "ellen/github/actions/merge_pull_request"
8
10
  require "ellen/github/actions/remember"
9
11
  require "ellen/github/version"
10
12
  require "ellen/handlers/github"
@@ -19,6 +19,18 @@ module Ellen
19
19
  description: "Close an issue",
20
20
  )
21
21
 
22
+ on(
23
+ /pull request "(?<title>.+)" from (?<from>.+) to (?<to>.+)(?:\n(?<description>[\s\S]+))?\z/,
24
+ name: "create_pull_request",
25
+ description: "Create a pull request",
26
+ )
27
+
28
+ on(
29
+ /merge pull request (?<repo>.+)#(?<number>\d+)\z/,
30
+ name: "merge_pull_request",
31
+ description: "Merge pull request",
32
+ )
33
+
22
34
  def create_issue(message)
23
35
  Ellen::Github::Actions::CreateIssue.new(message).call
24
36
  end
@@ -30,6 +42,14 @@ module Ellen
30
42
  def remember(message)
31
43
  Ellen::Github::Actions::Remember.new(message).call
32
44
  end
45
+
46
+ def create_pull_request(message)
47
+ Ellen::Github::Actions::CreatePullRequest.new(message).call
48
+ end
49
+
50
+ def merge_pull_request(message)
51
+ Ellen::Github::Actions::MergePullRequest.new(message).call
52
+ end
33
53
  end
34
54
  end
35
55
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ellen-github
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryo Nakamura
@@ -141,6 +141,8 @@ files:
141
141
  - lib/ellen/github/actions/base.rb
142
142
  - lib/ellen/github/actions/close_issue.rb
143
143
  - lib/ellen/github/actions/create_issue.rb
144
+ - lib/ellen/github/actions/create_pull_request.rb
145
+ - lib/ellen/github/actions/merge_pull_request.rb
144
146
  - lib/ellen/github/actions/remember.rb
145
147
  - lib/ellen/github/version.rb
146
148
  - lib/ellen/handlers/github.rb