cp8_cli 4.1.3 → 4.2.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
  SHA1:
3
- metadata.gz: 04d95eb51cfbf4608faa4834eb532b56a1b35ffa
4
- data.tar.gz: d6eb47f0fe8281a81d4aa6dfcc797eba6a83af05
3
+ metadata.gz: 256100625c3c7f06417bd59536d4c12d9b89397c
4
+ data.tar.gz: 7998d37f7925632ef5df017d87c96cbed3641b79
5
5
  SHA512:
6
- metadata.gz: b458e7fa660542602f8e3a4a5dc5ba5686be81c96d3fd8777e372024725cc800b65a2b48c35712f66fa76c78dc60cc969a8387b5737f699dfa1710745a92f372
7
- data.tar.gz: 7a4c7cc95f6e56396a05de2555c569e319dc0de5badc5412e25d4455293ae4aad83394a1f409afe76a0254e6641672ef5b0ebde0177e12c3667997588bce0f62
6
+ metadata.gz: f51daaba203995014fe5f2158860c8bc26812d762461eb1f4c161b6ddc9205b61d705d1d9992dc17f0fe9240b634b225c2d96107e1af031a5626ce71c2f3a2e0
7
+ data.tar.gz: 554fe042832d538069b6e21f1bea5121d7328fc58016f4a7e7277a9ca0e74143c6565265813afc174c22f71825f48257570dff7bdbda24ad4f9d5a4543f802b3
data/exe/cp8 CHANGED
@@ -28,6 +28,11 @@ module Cp8Cli
28
28
  main.ci
29
29
  end
30
30
 
31
+ desc "suggest", "Creates a random branch from current commit, pushes it, and resets `master` back to `origin/master`."
32
+ def suggest
33
+ main.suggest
34
+ end
35
+
31
36
  private
32
37
 
33
38
  def main
@@ -27,7 +27,7 @@ module Cp8Cli
27
27
  end
28
28
 
29
29
  def open_pull_request(options = {})
30
- pr = PullRequest.new options.merge(story: current_story, from: name, target: target)
30
+ pr = PullRequest.new options.reverse_merge(story: current_story, from: name, target: target)
31
31
  pr.open
32
32
  end
33
33
 
@@ -47,6 +47,18 @@ module Cp8Cli
47
47
  name_parts[2] || name
48
48
  end
49
49
 
50
+ def reset
51
+ if Command.read("git status --porcelain")
52
+ Command.error "Dirty working directory, not resetting."
53
+ else
54
+ Command.run("git reset --hard origin/#{name}")
55
+ end
56
+ end
57
+
58
+ def to_s
59
+ name
60
+ end
61
+
50
62
  private
51
63
 
52
64
  attr_reader :name
@@ -36,6 +36,16 @@ module Cp8Cli
36
36
  Branch.current.open_ci
37
37
  end
38
38
 
39
+ def suggest
40
+ original_branch = Branch.current
41
+ suggestion_branch = Branch.new("suggestion-#{SecureRandom.hex(8)}")
42
+ suggestion_branch.checkout
43
+ suggestion_branch.push
44
+ suggestion_branch.open_pull_request(target: original_branch, expand: false)
45
+ original_branch.checkout
46
+ original_branch.reset
47
+ end
48
+
39
49
  def cleanup
40
50
  Cleanup.new(Branch.current.target).run
41
51
  end
@@ -2,10 +2,11 @@ require "cp8_cli/repo"
2
2
 
3
3
  module Cp8Cli
4
4
  class PullRequest
5
- def initialize(from:, target:, story: nil, **options)
5
+ def initialize(from:, target:, story: nil, expand: true, **options)
6
6
  @story = story
7
7
  @from = from
8
- @target = target
8
+ @target = target.to_s
9
+ @expand = expand
9
10
  @options = options
10
11
  end
11
12
 
@@ -15,10 +16,16 @@ module Cp8Cli
15
16
 
16
17
  private
17
18
 
18
- attr_reader :story, :from, :target, :options
19
+ attr_reader :story, :from, :target, :expand, :options
19
20
 
20
21
  def url
21
- repo.url + "/compare/#{target}...#{escape from}?expand=1&title=#{escape title_with_prefixes}&body=#{escape body}"
22
+ repo.url + "/compare/#{target}...#{escape from}?title=#{escape title_with_prefixes}&body=#{escape body}#{expand_query}"
23
+ end
24
+
25
+ def expand_query
26
+ if expand
27
+ "&expand=1"
28
+ end
22
29
  end
23
30
 
24
31
  def title
@@ -1,5 +1,5 @@
1
1
  module Cp8Cli
2
- VERSION = "4.1.3"
2
+ VERSION = "4.2.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: 4.1.3
4
+ version: 4.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jens Balvig
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-10-20 00:00:00.000000000 Z
11
+ date: 2017-11-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler