cp8_cli 9.0.3 → 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
2
  SHA256:
3
- metadata.gz: 686e53130aacec45927fef9460a4394c66d0cac475c3fcda6f4500f84ed9b677
4
- data.tar.gz: 25dedc5d924f20069da2593fb6c11a9ba896aed17d33e67263c24795239c8179
3
+ metadata.gz: 7814c1971d98c081f83039b7532cd09643310307b23563c04a6e4e67dc187861
4
+ data.tar.gz: fcdc9860f33add2f70ce25de66c3b70961516b21377d77cb538266af2a2d02e7
5
5
  SHA512:
6
- metadata.gz: 9bfe765a3eb7e472e5b09c136955afd0fe0c378e3c302e3f897e795db396452e4322e1d3ffad7864acfa21b27965b9930c673cb24e0e266b4fb511104bb61b69
7
- data.tar.gz: 3b36fa3964d2684efbc83b3b33110d0662ca69006b4b8cf00ab5e32fccd7e2d3e0abcc41573ae9abc362534e341c5af147d571b5f3381254b3846ebbd1973fe9
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/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
@@ -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
@@ -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
@@ -45,6 +45,10 @@ module Cp8Cli
45
45
 
46
46
  attr_reader :from, :to, :title, :body, :expand, :html_url
47
47
 
48
+ def default_branch
49
+ client.repo(repo.shorthand).default_branch
50
+ end
51
+
48
52
  def url
49
53
  html_url || new_pr_url
50
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,6 +17,29 @@ 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
@@ -1,5 +1,5 @@
1
1
  module Cp8Cli
2
- VERSION = "9.0.3"
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: 9.0.3
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: 2020-05-20 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
@@ -279,7 +279,7 @@ homepage: https://github.com/balvig/cp8_cli
279
279
  licenses:
280
280
  - MIT
281
281
  metadata: {}
282
- post_install_message:
282
+ post_install_message:
283
283
  rdoc_options: []
284
284
  require_paths:
285
285
  - lib
@@ -295,7 +295,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
295
295
  version: '0'
296
296
  requirements: []
297
297
  rubygems_version: 3.0.3
298
- signing_key:
298
+ signing_key:
299
299
  specification_version: 4
300
300
  summary: Cookpad Global CLI.
301
301
  test_files: []