bb-flow 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: eaad5df13ac0248603a75a04305949053a789e09
4
- data.tar.gz: d79899d5adf15c52d6a3cef10ebf20fd7c944b18
3
+ metadata.gz: de6098e3affbd14a84dc640b84f8ace81036c612
4
+ data.tar.gz: 196e73e35c7185cbec8c26ecb5b867d423cf82f5
5
5
  SHA512:
6
- metadata.gz: 7865436ce51793e5638fccff9f15d53ad2fd0021e1b3756678a9de20cc7ee0afc6307622b41725575d45a3fc64b937d6fd27d0d542229362379649ff1ccd54f7
7
- data.tar.gz: e83860fa8be8127b8653f8bbec7c5bb6602b25f6acd459e6ab4f7b3c58a992f3f9b6cc326c8d57054efd32c4b08cd3aac808d4139dc892504d0dd843051f7b53
6
+ metadata.gz: 07e940a0826b56369ba4eadca2277e2ffee7b0e31c45268012438de89134c2c9001f839cb5706d0b879afe255d4809b32023c877334547839b4a614c35b5a9b2
7
+ data.tar.gz: 4941088c8fc32eaf3454abb378c0be8fd2109aded0906b88bace84ce93c8768e24faea4b776d2de1e2a94ed34249904ecdd3f96c2f33fe3305ea5b26fda2fc11
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bb-flow (0.1.2)
4
+ bb-flow (0.1.3)
5
5
  ansi-select (~> 0.2.5)
6
6
  colorize (~> 0.7.7)
7
7
  git (~> 1.2.9.1)
data/bin/bb-flow CHANGED
@@ -21,6 +21,11 @@ global = OptionParser.new do |opts|
21
21
  puts opts
22
22
  exit
23
23
  end
24
+
25
+ opts.on_tail("-v", "--version", "Show version") do
26
+ puts BBFlow::VERSION
27
+ exit
28
+ end
24
29
  end
25
30
 
26
31
  subcommands = {
@@ -17,7 +17,7 @@ module BBFlow
17
17
 
18
18
  # @return [Sawyer::Resource]
19
19
  def find_pull_request
20
- octokit.pull_requests(repository_name).detect { |pr| pr.head.ref == branch_name }
20
+ octokit.pull_requests(repository_name).detect { |pr| pr.head.ref == local_branch }
21
21
  end
22
22
 
23
23
  # @param [String] title
@@ -26,7 +26,7 @@ module BBFlow
26
26
  # @return [Sawyer::Resource] the newly created pull request.
27
27
  def create_pull_request(title, body)
28
28
  puts 'Creating a pull request...'
29
- octokit.create_pull_request(repository_name, 'master', branch_name, title, body)
29
+ octokit.create_pull_request(repository_name, 'master', local_branch, title, body)
30
30
  end
31
31
 
32
32
  # @return [Array<Array<String>>] Array<[login, name]>
@@ -35,9 +35,20 @@ module BBFlow
35
35
  octokit.collaborators(repository_name).map(&:login).sort.map(&octokit.method(:user)).map { |user| [user.login, user.name] }
36
36
  end
37
37
 
38
+ # @return [Boolean]
39
+ def has_branch?
40
+ Misc.git.is_remote_branch?(local_branch)
41
+ end
42
+
38
43
  # @return [Boolean]
39
44
  def pushed?
40
- branch_name
45
+ unpushed_commits_number == 0
46
+ end
47
+
48
+ # @return [Integer]
49
+ def unpushed_commits_number
50
+ git_command = "git rev-list --count HEAD ^#{remote_branch}"
51
+ Misc.execute(git_command).strip.to_i
41
52
  end
42
53
 
43
54
  # @return [String]
@@ -45,6 +56,11 @@ module BBFlow
45
56
  remote.name
46
57
  end
47
58
 
59
+ # @return [String]
60
+ def remote_branch
61
+ "#{remote_name}/#{local_branch}"
62
+ end
63
+
48
64
  private
49
65
 
50
66
  # @return [Octokit::Client]
@@ -77,9 +93,8 @@ module BBFlow
77
93
  end
78
94
 
79
95
  # @return [String]
80
- def branch_name
81
- rev = Misc.execute('git rev-parse --abbrev-ref --symbolic-full-name @{u}').strip
82
- %r{(.*?)/(.*)}.match(rev)[2] unless rev.empty?
96
+ def local_branch
97
+ Misc.git.current_branch
83
98
  end
84
99
 
85
100
  # @return [String]
@@ -69,7 +69,7 @@ module BBFlow
69
69
  end
70
70
 
71
71
  def self.location(storage_type)
72
- fail "Unknown store: #{name}" unless DIRS.keys.include?(storage_type)
72
+ fail "Unknown store: #{storage_type}" unless DIRS.keys.include?(storage_type)
73
73
 
74
74
  File.join(DIRS[storage_type], FILE_NAME)
75
75
  end
@@ -11,6 +11,16 @@ module BBFlow
11
11
  gets.strip
12
12
  end
13
13
 
14
+ # @param [String] question
15
+ #
16
+ # @return [Boolean] positive answer
17
+ def simple_question(question)
18
+ yes = 'Yes, please'
19
+ no = 'No, thank you'
20
+
21
+ select_item([yes, no], question, formatter: :to_s.to_proc) == yes
22
+ end
23
+
14
24
  # @param [String] message
15
25
  #
16
26
  # @return [void]
@@ -9,6 +9,7 @@ module BBFlow
9
9
 
10
10
  # @return [void]
11
11
  def create!
12
+ ensure_has_remote!
12
13
  ensure_pushed!
13
14
 
14
15
  existing_pull_request = Github.find_pull_request
@@ -30,24 +31,30 @@ module BBFlow
30
31
  Printer.error(exception.message)
31
32
  end
32
33
 
33
- def ensure_pushed!
34
- unless Github.pushed?
35
- yes = 'Yes, please'
36
-
37
- case Printer.select_item(
38
- [yes, 'No, thank you'],
39
- "The branch isn't pushed yet. Would you like me to push it for you?",
40
- formatter: :to_s.to_proc
41
- )
42
- when yes
34
+ def ensure_has_remote!
35
+ unless Github.has_branch?
36
+ question = "The branch isn't pushed yet. Would you like me to push it for you?"
37
+
38
+ if Printer.simple_question(question)
43
39
  Misc.execute("git push --set-upstream #{Github.remote_name} #{Misc.git.current_branch}")
44
40
  else
41
+ puts "Sorry, you should push your local branch to remote before creating a pull request."
45
42
  puts 'Exiting...'
46
43
  exit
47
44
  end
48
45
  end
49
46
  end
50
47
 
48
+ def ensure_pushed!
49
+ unless Github.pushed?
50
+ question = "Your local branch is ahead of '#{Github.remote_branch}' by #{Github.unpushed_commits_number} commits. Would you like me to push it?"
51
+
52
+ if Printer.simple_question(question)
53
+ Misc.execute("git push --set-upstream #{Github.remote_name} #{Misc.git.current_branch}")
54
+ end
55
+ end
56
+ end
57
+
51
58
  # @return [void]
52
59
  def move_cards_to_done_list
53
60
  puts "Moving cards to the „#{Trello.done_list.name}“ list..."
@@ -58,9 +65,7 @@ module BBFlow
58
65
  def add_link_to_cards(url)
59
66
  puts 'Adding the pull request link to the trello cards...'
60
67
 
61
- cards.each do |card|
62
- next if card.desc.include?(url)
63
-
68
+ cards.reject { |card| card.desc.include?(url) }.each do |card|
64
69
  card.desc = "[Pull Request](#{url})\n\n#{card.desc}"
65
70
  card.save
66
71
  end
@@ -124,7 +129,7 @@ module BBFlow
124
129
 
125
130
  # @return [Array<Git::Object::Commit>]
126
131
  memoize def commits
127
- Misc.git.log.between('master', 'HEAD').to_a
132
+ Misc.git.log.object('--no-merges').between('master', 'HEAD').to_a
128
133
  end
129
134
  end
130
135
  end
@@ -9,7 +9,7 @@ module BBFlow
9
9
 
10
10
  # Current patch level.
11
11
  # @return [String]
12
- PATCH = 2
12
+ PATCH = 3
13
13
 
14
14
  # Full release version.
15
15
  # @return [String]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bb-flow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - gregolsen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-12 00:00:00.000000000 Z
11
+ date: 2015-10-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ansi-select