bb-flow 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/bin/bb-flow +5 -0
- data/lib/bb_flow/github.rb +21 -6
- data/lib/bb_flow/persistent.rb +1 -1
- data/lib/bb_flow/printer.rb +10 -0
- data/lib/bb_flow/pull_requester.rb +19 -14
- data/lib/bb_flow/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: de6098e3affbd14a84dc640b84f8ace81036c612
|
4
|
+
data.tar.gz: 196e73e35c7185cbec8c26ecb5b867d423cf82f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 07e940a0826b56369ba4eadca2277e2ffee7b0e31c45268012438de89134c2c9001f839cb5706d0b879afe255d4809b32023c877334547839b4a614c35b5a9b2
|
7
|
+
data.tar.gz: 4941088c8fc32eaf3454abb378c0be8fd2109aded0906b88bace84ce93c8768e24faea4b776d2de1e2a94ed34249904ecdd3f96c2f33fe3305ea5b26fda2fc11
|
data/Gemfile.lock
CHANGED
data/bin/bb-flow
CHANGED
data/lib/bb_flow/github.rb
CHANGED
@@ -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 ==
|
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',
|
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
|
-
|
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
|
81
|
-
|
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]
|
data/lib/bb_flow/persistent.rb
CHANGED
@@ -69,7 +69,7 @@ module BBFlow
|
|
69
69
|
end
|
70
70
|
|
71
71
|
def self.location(storage_type)
|
72
|
-
fail "Unknown store: #{
|
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
|
data/lib/bb_flow/printer.rb
CHANGED
@@ -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
|
34
|
-
unless Github.
|
35
|
-
|
36
|
-
|
37
|
-
|
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
|
data/lib/bb_flow/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2015-10-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ansi-select
|