cp8_cli 8.2.1 → 9.1.0

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
- SHA1:
3
- metadata.gz: 1ff138421479066ef738c308282e9b57baab5e3e
4
- data.tar.gz: cbc59c229cd35cb4bdf9f1c416b05b0fa768b820
2
+ SHA256:
3
+ metadata.gz: 7814c1971d98c081f83039b7532cd09643310307b23563c04a6e4e67dc187861
4
+ data.tar.gz: fcdc9860f33add2f70ce25de66c3b70961516b21377d77cb538266af2a2d02e7
5
5
  SHA512:
6
- metadata.gz: 570b56fd867b5c0c9230819b63c181674d014ba190e9170bc0147bc7c20102d9780b0b21f70c7f532dcf7013ea673ac72c46ae4b5da35755bcadd2dc3392f38f
7
- data.tar.gz: 367fb70df2e7813794dbcd82de10d6eeeb7d39f252c00a4dd3c564aed362a141c1139ba1bea8d6bfcb2f1ea88124543dea24ed580903710e5c31fa0e79d4f3ce
6
+ metadata.gz: b57fc650a6714b0b27c297eee936a9ae62911586625e6ce340dc0a231170d973ee43d4b8da2895e30c1f1dd47773ee1102bb39cc5e4c401f23e7accb59c894d2
7
+ data.tar.gz: f8005a679e7740ed961ab48230a294af0ac78ba9c584515d36d0ad8d723c9b725a74ff4243b7f05d63f1f3ae2eaa7f7442c8fd4cd13b065a87355ab2193afba0
data/README.md CHANGED
@@ -1,4 +1,7 @@
1
- # CP-8 Cli
1
+ # CP8 Cli
2
+ CP8 is a command line tool which aids in interacting with Github.
3
+
4
+ CP8 helps you open draft pull requests, suggests branch names and opens your CI for a branch.
2
5
 
3
6
  ## Installation
4
7
 
data/cp8_cli.gemspec CHANGED
@@ -19,8 +19,8 @@ Gem::Specification.new do |spec|
19
19
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
20
  spec.require_paths = ["lib"]
21
21
 
22
- spec.add_development_dependency "bundler", "~> 1.11"
23
- spec.add_development_dependency "rake", "~> 10.0"
22
+ spec.add_development_dependency "bundler", "~> 2.0"
23
+ spec.add_development_dependency "rake", ">= 12.3.3"
24
24
  spec.add_development_dependency "minitest", "~> 5.0"
25
25
  spec.add_development_dependency "minitest-line"
26
26
  spec.add_development_dependency "minitest-reporters"
@@ -32,8 +32,8 @@ Gem::Specification.new do |spec|
32
32
  spec.add_dependency "colored"
33
33
  spec.add_dependency "highline"
34
34
  spec.add_dependency "launchy"
35
- spec.add_dependency "octokit"
35
+ spec.add_dependency "octokit", "~> 4.18"
36
36
  spec.add_dependency "thor"
37
- spec.add_dependency "trollop"
38
37
  spec.add_dependency "tty-prompt"
38
+ spec.add_dependency "os"
39
39
  end
data/exe/cp8 CHANGED
@@ -27,7 +27,7 @@ module Cp8Cli
27
27
  main.ci
28
28
  end
29
29
 
30
- desc "suggest", "Creates a suggestion branch from new commits, pushes it, opens URL and resets `master` back to `origin/master`."
30
+ desc "suggest", "Creates a suggestion branch from new commits, pushes it, opens URL, and resets the base branch."
31
31
  def suggest
32
32
  main.suggest
33
33
  end
@@ -2,6 +2,7 @@ require "colored"
2
2
  require "active_support/core_ext/module/delegation"
3
3
  require "highline"
4
4
  require "tty-prompt"
5
+ require "os"
5
6
 
6
7
  module Cp8Cli
7
8
  class Command
@@ -14,7 +15,7 @@ module Cp8Cli
14
15
 
15
16
  def open_url(url)
16
17
  return title(url) if ENV['BROWSER'] == 'echo'
17
- `open \"#{url}\"`
18
+ `#{OS.open_file_command} \"#{url}\"`
18
19
  end
19
20
 
20
21
  def title(message)
@@ -10,9 +10,18 @@ module Cp8Cli
10
10
  data[key]
11
11
  end
12
12
 
13
+ def exist?
14
+ File.exist?(path)
15
+ end
16
+
17
+ def move_to(new_path)
18
+ File.rename(path, new_path)
19
+ @path = new_path
20
+ end
21
+
13
22
  def save(key, value)
14
23
  data[key] = value
15
- File.new(path, "w") unless File.exists?(path)
24
+ File.new(path, "w") unless exist?
16
25
  File.open(path, "w") { |f| f.write(data.to_yaml) }
17
26
  value
18
27
  end
@@ -5,6 +5,7 @@ module Cp8Cli
5
5
  include Github::Api::Client
6
6
 
7
7
  def initials
8
+ Command.error("Please configure your git user.name using git config user.name Jane Doe") unless git_user_name
8
9
  git_user_name.parameterize(separator: " ").split.map(&:first).join
9
10
  end
10
11
 
@@ -16,7 +16,7 @@ module Cp8Cli
16
16
  def self.find_by_url(url)
17
17
  url = ParsedUrl.new(url)
18
18
  issue = client.issue(url.repo, url.number).to_h
19
- new issue.merge(number: url.number, repo: url.repo)
19
+ new(**issue.merge(number: url.number, repo: url.repo))
20
20
  end
21
21
 
22
22
  def title
@@ -7,18 +7,18 @@ module Cp8Cli
7
7
  include Api::Client
8
8
 
9
9
  def self.create(attributes = {})
10
- new(attributes).save
10
+ new(**attributes).save
11
11
  end
12
12
 
13
13
  def self.find_by(repo:, branch:)
14
14
  client.pull_requests(repo.shorthand, head: "#{repo.user}:#{branch}").map do |data|
15
- new(data)
15
+ new(**data)
16
16
  end.first
17
17
  end
18
18
 
19
- def initialize(from: nil, to: "master", title: nil, body: nil, expand: 1, html_url: nil, **attributes)
19
+ def initialize(from: nil, to: nil, title: nil, body: nil, expand: 1, html_url: nil, **attributes)
20
20
  @from = from
21
- @to = to
21
+ @to = to || default_branch
22
22
  @title = title
23
23
  @body = body
24
24
  @expand = expand
@@ -35,7 +35,9 @@ module Cp8Cli
35
35
  to,
36
36
  from,
37
37
  title,
38
- body
38
+ body,
39
+ draft: true,
40
+ accept: "application/vnd.github.shadow-cat-preview" # waiting for https://github.com/octokit/octokit.rb/pull/1114
39
41
  )
40
42
  end
41
43
 
@@ -43,6 +45,10 @@ module Cp8Cli
43
45
 
44
46
  attr_reader :from, :to, :title, :body, :expand, :html_url
45
47
 
48
+ def default_branch
49
+ client.repo(repo.shorthand).default_branch
50
+ end
51
+
46
52
  def url
47
53
  html_url || new_pr_url
48
54
  end
@@ -2,10 +2,11 @@ require "cp8_cli/config_store"
2
2
 
3
3
  module Cp8Cli
4
4
  class GlobalConfig
5
- PATH = ENV["HOME"] + "/.trello_flow"
5
+ LEGACY_PATH = ENV["HOME"] + "/.trello_flow"
6
+ PATH = ENV["HOME"] + "/.cp8_cli"
6
7
 
7
8
  def initialize(store = nil)
8
- @store = store || ConfigStore.new(PATH)
9
+ @store = store || initialize_store
9
10
  end
10
11
 
11
12
  def github_token
@@ -16,12 +17,38 @@ module Cp8Cli
16
17
 
17
18
  attr_reader :store
18
19
 
20
+ def initialize_store
21
+ migrate_legacy_store if uses_legacy_store?
22
+
23
+ default_store
24
+ end
25
+
26
+ def uses_legacy_store?
27
+ legacy_store.exist?
28
+ end
29
+
30
+ def migrate_legacy_store
31
+ Command.say("#{LEGACY_PATH} was deprecated, moving to #{PATH}")
32
+ legacy_store.move_to(PATH)
33
+ end
34
+
35
+ def default_store
36
+ @_default_store ||= ConfigStore.new(PATH)
37
+ end
38
+
39
+ def legacy_store
40
+ @_legacy_store ||= ConfigStore.new(LEGACY_PATH)
41
+ end
42
+
19
43
  def env_github_token
20
44
  ENV["OCTOKIT_ACCESS_TOKEN"]
21
45
  end
22
46
 
23
47
  def configure_github_token
24
- store.save :github_token, Command.ask("Input GitHub token")
48
+ store.save(
49
+ :github_token,
50
+ Command.ask("Input GitHub access token with repo access scope (https://github.com/settings/tokens):")
51
+ )
25
52
  end
26
53
  end
27
54
  end
@@ -2,7 +2,7 @@ module Cp8Cli
2
2
  class PullRequestTitle
3
3
  def initialize(title, prefixes: [])
4
4
  @title = title
5
- @prefixes = Array(*prefixes)
5
+ @prefixes = Array(prefixes)
6
6
  end
7
7
 
8
8
  def run
data/lib/cp8_cli/story.rb CHANGED
@@ -6,9 +6,9 @@ module Cp8Cli
6
6
  checkout_branch
7
7
  create_empty_commit
8
8
  push_branch
9
- create_wip_pull_request
9
+ create_draft_pull_request
10
10
  assign
11
- Command.title "Created WIP PR, run `cp8 open` to view."
11
+ Command.title "Created draft PR, run `cp8 open` to view."
12
12
  end
13
13
 
14
14
  private
@@ -33,10 +33,10 @@ module Cp8Cli
33
33
  branch.push
34
34
  end
35
35
 
36
- def create_wip_pull_request
36
+ def create_draft_pull_request
37
37
  Github::PullRequest.create(
38
38
  from: branch.name,
39
- title: PullRequestTitle.new(title, prefixes: :wip).run,
39
+ title: PullRequestTitle.new(title).run,
40
40
  body: PullRequestBody.new(self).run
41
41
  )
42
42
  end
@@ -1,5 +1,5 @@
1
1
  module Cp8Cli
2
- VERSION = "8.2.1"
2
+ VERSION = "9.1.0"
3
3
 
4
4
  class Version
5
5
  def self.latest?
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cp8_cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.2.1
4
+ version: 9.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jens Balvig
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-06-04 00:00:00.000000000 Z
11
+ date: 2021-02-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.11'
19
+ version: '2.0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.11'
26
+ version: '2.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '10.0'
33
+ version: 12.3.3
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '10.0'
40
+ version: 12.3.3
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: minitest
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -182,16 +182,16 @@ dependencies:
182
182
  name: octokit
183
183
  requirement: !ruby/object:Gem::Requirement
184
184
  requirements:
185
- - - ">="
185
+ - - "~>"
186
186
  - !ruby/object:Gem::Version
187
- version: '0'
187
+ version: '4.18'
188
188
  type: :runtime
189
189
  prerelease: false
190
190
  version_requirements: !ruby/object:Gem::Requirement
191
191
  requirements:
192
- - - ">="
192
+ - - "~>"
193
193
  - !ruby/object:Gem::Version
194
- version: '0'
194
+ version: '4.18'
195
195
  - !ruby/object:Gem::Dependency
196
196
  name: thor
197
197
  requirement: !ruby/object:Gem::Requirement
@@ -207,7 +207,7 @@ dependencies:
207
207
  - !ruby/object:Gem::Version
208
208
  version: '0'
209
209
  - !ruby/object:Gem::Dependency
210
- name: trollop
210
+ name: tty-prompt
211
211
  requirement: !ruby/object:Gem::Requirement
212
212
  requirements:
213
213
  - - ">="
@@ -221,7 +221,7 @@ dependencies:
221
221
  - !ruby/object:Gem::Version
222
222
  version: '0'
223
223
  - !ruby/object:Gem::Dependency
224
- name: tty-prompt
224
+ name: os
225
225
  requirement: !ruby/object:Gem::Requirement
226
226
  requirements:
227
227
  - - ">="
@@ -239,10 +239,6 @@ email:
239
239
  - jens@balvig.com
240
240
  executables:
241
241
  - cp8
242
- - git-cleanup
243
- - git-finish
244
- - git-open
245
- - git-start
246
242
  extensions: []
247
243
  extra_rdoc_files: []
248
244
  files:
@@ -255,10 +251,6 @@ files:
255
251
  - Rakefile
256
252
  - cp8_cli.gemspec
257
253
  - exe/cp8
258
- - exe/git-cleanup
259
- - exe/git-finish
260
- - exe/git-open
261
- - exe/git-start
262
254
  - lib/cp8_cli.rb
263
255
  - lib/cp8_cli/adhoc_story.rb
264
256
  - lib/cp8_cli/branch.rb
@@ -287,7 +279,7 @@ homepage: https://github.com/balvig/cp8_cli
287
279
  licenses:
288
280
  - MIT
289
281
  metadata: {}
290
- post_install_message:
282
+ post_install_message:
291
283
  rdoc_options: []
292
284
  require_paths:
293
285
  - lib
@@ -302,9 +294,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
302
294
  - !ruby/object:Gem::Version
303
295
  version: '0'
304
296
  requirements: []
305
- rubyforge_project:
306
- rubygems_version: 2.6.14.1
307
- signing_key:
297
+ rubygems_version: 3.0.3
298
+ signing_key:
308
299
  specification_version: 4
309
300
  summary: Cookpad Global CLI.
310
301
  test_files: []
data/exe/git-cleanup DELETED
@@ -1,7 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
4
-
5
- require "cp8_cli"
6
-
7
- Cp8Cli::Command.error "cleanup command has been removed, consider using https://github.com/Seinh/git-prune instead?"
data/exe/git-finish DELETED
@@ -1,20 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
4
-
5
- require "cp8_cli"
6
- require "trollop"
7
-
8
-
9
- options = Trollop::options do
10
- banner <<-EOS
11
- Pushes branch to GitHub and opens a PR
12
-
13
- Usage:
14
- git finish
15
- EOS
16
- opt :wip, "Open [WIP] PR"
17
- end
18
-
19
- puts "git finish is DEPRECATED, please use cp8 submit".red
20
- Cp8Cli::Main.new.submit(options)
data/exe/git-open DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
4
-
5
- require "cp8_cli"
6
-
7
- puts "git open is DEPRECATED, please use cp8 open".red
8
- Cp8Cli::Main.new.open
data/exe/git-start DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
4
-
5
- require "cp8_cli"
6
-
7
- puts "git start is DEPRECATED, please use cp8 start".red
8
- Cp8Cli::Main.new.start(ARGV.first)