bb-flow 0.1.3 → 0.1.4

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: de6098e3affbd14a84dc640b84f8ace81036c612
4
- data.tar.gz: 196e73e35c7185cbec8c26ecb5b867d423cf82f5
3
+ metadata.gz: 1a0d4d74ad7aa4c5f5145d51260ef78a9ffaf99f
4
+ data.tar.gz: 7f88dfb42644f2a4707ea43b93ef264739f2291e
5
5
  SHA512:
6
- metadata.gz: 07e940a0826b56369ba4eadca2277e2ffee7b0e31c45268012438de89134c2c9001f839cb5706d0b879afe255d4809b32023c877334547839b4a614c35b5a9b2
7
- data.tar.gz: 4941088c8fc32eaf3454abb378c0be8fd2109aded0906b88bace84ce93c8768e24faea4b776d2de1e2a94ed34249904ecdd3f96c2f33fe3305ea5b26fda2fc11
6
+ metadata.gz: c6e5ff479bc5a71682766b425d63bd5646a2f727078a2dd85a8d7d3d79b39cb7eeab6af60251fa21bddda1bc74e0d59b193a66ba0933a19e9905fc69e4ea1b9e
7
+ data.tar.gz: 9ff36f8a05a65b275c6662e84def0acb9945cab21a940fb8db6ffbd5166650a920e723037a6aaa0d4b94ea7c7f8e0525c899c5f9f5c1d4555990a102fc1c97ce
data/CHANGELOG.md ADDED
@@ -0,0 +1,6 @@
1
+ #### 0.1.4
2
+
3
+ * Check for updates on start.
4
+ * PR: always join commit messages in the Changes section with a new line.
5
+ * PR: CC people who committed to this branch.
6
+ * Updated `ansi-select` from [0.2.5 to 0.3.4](https://github.com/shockone/ansi-select/blob/master/CHANGELOG.md)
data/Gemfile.lock CHANGED
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bb-flow (0.1.3)
5
- ansi-select (~> 0.2.5)
4
+ bb-flow (0.1.4)
5
+ ansi-select (= 0.3.4)
6
6
  colorize (~> 0.7.7)
7
7
  git (~> 1.2.9.1)
8
8
  memoist (~> 0.12.0)
@@ -22,7 +22,7 @@ GEM
22
22
  thread_safe (~> 0.3, >= 0.3.4)
23
23
  tzinfo (~> 1.1)
24
24
  addressable (2.3.8)
25
- ansi-select (0.2.5)
25
+ ansi-select (0.3.4)
26
26
  ast (2.1.0)
27
27
  astrolabe (1.3.1)
28
28
  parser (~> 2.2)
data/bb-flow.gemspec CHANGED
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
17
17
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
18
  spec.require_paths = ['lib']
19
19
 
20
- spec.add_dependency 'ansi-select', '~> 0.2.5'
20
+ spec.add_dependency 'ansi-select', '0.3.4'
21
21
  spec.add_dependency 'git', '~> 1.2.9.1'
22
22
  spec.add_dependency 'memoist', '~> 0.12.0'
23
23
  spec.add_dependency 'ruby-trello', '~> 1.3.0'
data/bin/bb-flow CHANGED
@@ -1,7 +1,9 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require_relative '../lib/bb-flow'
4
3
  require 'optparse'
4
+ require_relative '../lib/bb-flow'
5
+
6
+ BBFlow::Updater.ensure_up_to_date!
5
7
 
6
8
  subtext = <<HELP
7
9
  Commands are:
@@ -4,6 +4,7 @@ module BBFlow
4
4
  class Github
5
5
  class << self
6
6
  extend BBFlow::Persistent
7
+ extend Memoist
7
8
 
8
9
  # @return [String]
9
10
  def http_url
@@ -15,6 +16,18 @@ module BBFlow
15
16
  remote.url
16
17
  end
17
18
 
19
+ # @return [Array<Sawyer::Resource>]
20
+ memoize def commits_info
21
+ octokit.compare(repository_name, 'master', local_branch).commits
22
+ end
23
+
24
+ # People who worked with you on this branch.
25
+ #
26
+ # @return [Array<String]
27
+ memoize def other_branch_committers
28
+ (commits_info.map(&:author) + commits_info.map(&:committer)).map(&:login).uniq - [octokit.user.login]
29
+ end
30
+
18
31
  # @return [Sawyer::Resource]
19
32
  def find_pull_request
20
33
  octokit.pull_requests(repository_name).detect { |pr| pr.head.ref == local_branch }
@@ -64,8 +77,8 @@ module BBFlow
64
77
  private
65
78
 
66
79
  # @return [Octokit::Client]
67
- def octokit
68
- @octokit ||= Octokit::Client.new(access_token: token)
80
+ memoize def octokit
81
+ Octokit::Client.new(access_token: token)
69
82
  end
70
83
 
71
84
  # @return [String]
@@ -75,7 +88,7 @@ module BBFlow
75
88
  end
76
89
 
77
90
  # @return [Git::Remote]
78
- def remote
91
+ memoize def remote
79
92
  remotes = Misc.git.remotes.select { |remote| remote.url.include?('github') }
80
93
 
81
94
  case remotes.size
@@ -64,7 +64,7 @@ module BBFlow
64
64
  def select_item(items, title, formatter: :name.to_proc)
65
65
  puts
66
66
  note(title)
67
- auxiliary('Move: arrows or j/k Finish: return')
67
+ auxiliary('Move: arrows, j/k, or Ctrl-N/P Finish: return')
68
68
  Ansi::Selector.select(items, formatter: formatter)
69
69
  end
70
70
 
@@ -5,7 +5,7 @@ module BBFlow
5
5
  class << self
6
6
  extend Memoist
7
7
 
8
- AD = "\n\n<sub>This pull request has been created using [bb-flow](https://github.com/brightbytes/bb-flow).</sub>"
8
+ ADVERTISEMENT = "\n\n<sub>This pull request has been created using [bb-flow](https://github.com/brightbytes/bb-flow).</sub>"
9
9
 
10
10
  # @return [void]
11
11
  def create!
@@ -17,7 +17,7 @@ module BBFlow
17
17
  if existing_pull_request
18
18
  Printer.success("A pull request for this branch already exists.\n#{existing_pull_request.html_url}")
19
19
  else
20
- response = Github.create_pull_request(title, Misc.edit(body_template) + AD)
20
+ response = Github.create_pull_request(title, Misc.edit(body_template) + ADVERTISEMENT)
21
21
 
22
22
  unless cards.empty?
23
23
  add_link_to_cards(response.html_url)
@@ -96,7 +96,12 @@ module BBFlow
96
96
  end
97
97
 
98
98
  body_parts << '###### Changes'
99
- body_parts << commits.map(&:message).map(&:lines).map(&:first).map { |message| " * #{message}" }.join
99
+ body_parts << commit_messages.map { |message| " * #{message.lines.first.strip}" }.join("\n")
100
+
101
+ unless Github.other_branch_committers.empty?
102
+ logins = Github.other_branch_committers.map { |login| "@#{login}" }.join(", ")
103
+ body_parts << "CC: #{logins}"
104
+ end
100
105
 
101
106
  body_parts.join("\n\n")
102
107
  end
@@ -123,13 +128,13 @@ module BBFlow
123
128
  Trello.cards,
124
129
  'Which cards does it implement?',
125
130
  formatter: ->(card) { [card.name, card.short_url] },
126
- preselected: Trello.cards.map { |card| commits.any? { |commit| commit.message.include?(card.short_url) } }
131
+ preselected: Trello.cards.map { |card| commit_messages.any? { |message| message.include?(card.short_url) } }
127
132
  )
128
133
  end
129
134
 
130
- # @return [Array<Git::Object::Commit>]
131
- memoize def commits
132
- Misc.git.log.object('--no-merges').between('master', 'HEAD').to_a
135
+ # @return [Array<String>]
136
+ memoize def commit_messages
137
+ Github.commits_info.reject { |info| info.parents.size > 1 }.map { |info| info.commit.message }
133
138
  end
134
139
  end
135
140
  end
@@ -0,0 +1,69 @@
1
+ module BBFlow
2
+ class Updater
3
+ class << self
4
+ extend BBFlow::Persistent
5
+
6
+ CHECK_INTERVAL = 60 * 60 * 24 * 7
7
+
8
+ # @return [void]
9
+ def ensure_up_to_date!
10
+ return if recently_checked? || !update_available?
11
+
12
+ if Printer.simple_question("An update from #{current_version} to #{latest_version} is available. Should I install it?")
13
+ command = "gem install bb-flow -v '#{latest_version}'"
14
+ puts "Executing `#{command}`..."
15
+ `#{command}`
16
+
17
+ exit Printer.success("Hooray, the new version has been installed! You can find the changes here: https://github.com/brightbytes/bb-flow/blob/master/CHANGELOG.md")
18
+ end
19
+ rescue StandardError => exception
20
+ Printer.error("An error occurred while trying to self-update the gem: #{exception.message}")
21
+ ensure
22
+ update_last_check_unixtime!
23
+ end
24
+
25
+ private
26
+
27
+ # @return [Boolean]
28
+ def update_available?
29
+ puts "Looking for updates..."
30
+ latest_version > current_version
31
+ end
32
+
33
+ # @return [Gem::Version]
34
+ def latest_version
35
+ fetcher.search_for_dependency(dependency).first.map { |n, _| n.version }.first || Gem::Version.new('0')
36
+ end
37
+
38
+ # @return [Gem::Version]
39
+ def current_version
40
+ Gem::Version.new(BBFlow::VERSION)
41
+ end
42
+
43
+ # @return [Gem::SpecFetcher]
44
+ def fetcher
45
+ Gem::SpecFetcher.new(Gem::SourceList.from(['https://rubygems.org/']))
46
+ end
47
+
48
+ # @return [Gem::Dependency]
49
+ def dependency
50
+ Gem::Dependency.new('bb-flow')
51
+ end
52
+
53
+ # @return [Boolean]
54
+ def recently_checked?
55
+ last_check_unixtime + CHECK_INTERVAL > Time.now.to_i
56
+ end
57
+
58
+ # @return [Fixnum]
59
+ persistent global def last_check_unixtime
60
+ 0
61
+ end
62
+
63
+ # @return [void]
64
+ def update_last_check_unixtime!
65
+ Persistent::Store.get(:global).transaction { |store| store['updater']['last_check_unixtime'] = Time.now.to_i }
66
+ end
67
+ end
68
+ end
69
+ end
@@ -9,7 +9,7 @@ module BBFlow
9
9
 
10
10
  # Current patch level.
11
11
  # @return [String]
12
- PATCH = 3
12
+ PATCH = 4
13
13
 
14
14
  # Full release version.
15
15
  # @return [String]
data/lib/bb_flow.rb CHANGED
@@ -19,6 +19,7 @@ require_relative 'bb_flow/misc'
19
19
  require_relative 'bb_flow/pull_requester'
20
20
  require_relative 'bb_flow/trello'
21
21
  require_relative 'bb_flow/github'
22
+ require_relative 'bb_flow/updater'
22
23
 
23
24
  module BBFlow
24
25
  class Application
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bb-flow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
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-21 00:00:00.000000000 Z
11
+ date: 2015-10-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ansi-select
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 0.2.5
19
+ version: 0.3.4
20
20
  type: :runtime
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: 0.2.5
26
+ version: 0.3.4
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: git
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -162,6 +162,7 @@ files:
162
162
  - ".gitignore"
163
163
  - ".rubocop.yml"
164
164
  - ".rubocop_todo.yml"
165
+ - CHANGELOG.md
165
166
  - Gemfile
166
167
  - Gemfile.lock
167
168
  - README.md
@@ -177,6 +178,7 @@ files:
177
178
  - lib/bb_flow/printer.rb
178
179
  - lib/bb_flow/pull_requester.rb
179
180
  - lib/bb_flow/trello.rb
181
+ - lib/bb_flow/updater.rb
180
182
  - lib/bb_flow/version.rb
181
183
  homepage: ''
182
184
  licenses: