fgi 1.1.4 → 1.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/fgi +30 -22
- data/lib/fgi.rb +1 -1
- data/lib/fgi/git_service.rb +28 -25
- 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: d59a2d5cf5f06e8ac7234bd5e997f2979dee1c23
|
4
|
+
data.tar.gz: 87c72213d77138f9f9e2f962763d08c2c75cf310
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 80a6daec4ed632e0ab6a8c73cfeabad5592c3fa7c67cbde92e42557d76c49a32a96632bce0b79ea362483d8f11a7d034fecd64321b7eef41b3485ac8e783888b
|
7
|
+
data.tar.gz: f443b71afe99c46d12b2bd9f305d7aed2c1f806142f3013473df725fe4540f580344354d328dcfcf0063dcfac2d366d126c5b0bdacd8aeb97c5c0a7090a3448d
|
data/bin/fgi
CHANGED
@@ -11,43 +11,40 @@ argv = ARGV
|
|
11
11
|
|
12
12
|
options = {}
|
13
13
|
options_parser = OptionParser.new do |fgi|
|
14
|
-
fgi.banner = 'Usage: fgi COMMAND [
|
15
|
-
|
16
|
-
fgi.separator
|
17
|
-
|
18
|
-
fgi.separator
|
19
|
-
|
20
|
-
fgi.separator
|
21
|
-
fgi.separator ' ... more comming soon ...'
|
22
|
-
fgi.separator ''
|
23
|
-
fgi.separator 'Options'
|
24
|
-
|
25
|
-
fgi.on('-h', '--help', 'Display the FGI manual')
|
26
|
-
|
27
|
-
fgi.on('-v', '--version', 'Display the FGI version') do
|
28
|
-
puts "FGI #{Fgi::VERSION}"
|
29
|
-
exit!
|
30
|
-
end
|
31
|
-
|
14
|
+
fgi.banner = 'Usage: fgi COMMAND [OPTIONS]'
|
15
|
+
# CONFIG
|
16
|
+
fgi.separator "\nfgi config : run the FGI configurator."
|
17
|
+
# TOKEN
|
18
|
+
fgi.separator "\nfgi token [TOKEN] : define the new user token."
|
19
|
+
# NEW
|
20
|
+
fgi.separator "\nfgi new [ISSUE_NAME] [OPTIONS] : create the issue with the given name.\n\n"
|
32
21
|
fgi.on('-e', '--estimate [ESTIMATION]', 'How many time do you think you will spend on this issue ? (example: 1d13h37m05s)') do |estimate|
|
33
22
|
options[:estimate] = estimate
|
34
23
|
end
|
35
|
-
|
36
24
|
fgi.on('-l', '--later', 'Tell FGI that you only want to create an issue but not to create and switch branch.') do
|
37
25
|
options[:later] = true
|
38
26
|
end
|
39
|
-
|
40
27
|
fgi.on('-p', '--prefix [PREFIX]', 'Tell FGI that you want to add a prefix to the branch name.') do |prefix|
|
41
28
|
options[:prefix] = prefix
|
42
29
|
end
|
43
|
-
|
44
30
|
fgi.on('--from-current', 'Tell FGI to create the new issue from a specific branch.') do
|
45
31
|
options[:from_current] = true
|
46
32
|
end
|
47
|
-
|
33
|
+
# FIX
|
34
|
+
fgi.separator "\nfgi fix [OPTIONS] : fix the current issue.\n\n"
|
48
35
|
fgi.on('-m', '--fix-message [MESSAGE]', %q(Add a custom message with the basic 'Fix #ID')) do |message|
|
49
36
|
options[:fix_message] = message
|
50
37
|
end
|
38
|
+
# CURRENT
|
39
|
+
fgi.separator "\nfgi current [OPTIONS] : display the current branch and issue."
|
40
|
+
fgi.separator "\n -e, --estimate [ESTIMATION] Add/rewrite the estimation time on the current issue. See 'fgi new' options."
|
41
|
+
# COMMON OPTIONS
|
42
|
+
fgi.separator "\nCommon options :\n\n"
|
43
|
+
fgi.on('-h', '--help', 'Display the FGI manual')
|
44
|
+
fgi.on('-v', '--version', 'Display the FGI version') do
|
45
|
+
puts "FGI #{Fgi::VERSION}"
|
46
|
+
exit!
|
47
|
+
end
|
51
48
|
end
|
52
49
|
options_parser.parse!
|
53
50
|
|
@@ -77,6 +74,17 @@ when 'token'
|
|
77
74
|
Fgi::Tokens.add_token(argv[1])
|
78
75
|
when 'fix'
|
79
76
|
Fgi::GitService.fix_issue(options)
|
77
|
+
when 'current'
|
78
|
+
current_branch = Fgi::GitService.current_branch
|
79
|
+
puts "Current branch : #{current_branch}"
|
80
|
+
if (defined? Fgi::ISSUES) && !options[:estimate].nil?
|
81
|
+
Fgi::GitService.set_issue_estimation(issue_id: Fgi::ISSUES[current_branch][:id], estimation: options[:estimate], git_service: Fgi::CONFIG[:git_service_class].new)
|
82
|
+
exit!
|
83
|
+
elsif Fgi::ISSUES
|
84
|
+
puts "Current issue : #{Fgi::ISSUES[current_branch][:title]}" || 'This branch do not match any FGI issue.'
|
85
|
+
else
|
86
|
+
puts 'This is not an FGI branch. There is no FGI issue for this one.'
|
87
|
+
end
|
80
88
|
else
|
81
89
|
puts options_parser
|
82
90
|
end
|
data/lib/fgi.rb
CHANGED
@@ -14,7 +14,7 @@ module Fgi
|
|
14
14
|
require_relative 'fgi/configuration'
|
15
15
|
require_relative 'fgi/git_service'
|
16
16
|
|
17
|
-
VERSION = '1.1.
|
17
|
+
VERSION = '1.1.5'.freeze
|
18
18
|
|
19
19
|
# Add FGI user's current issues to the gitignore
|
20
20
|
if `cat .gitignore | grep '.current_issues.fgi.yml'`.empty?
|
data/lib/fgi/git_service.rb
CHANGED
@@ -32,7 +32,7 @@ module Fgi
|
|
32
32
|
elsif !response['iid'].nil?
|
33
33
|
branch_name = snakify(title)
|
34
34
|
branch_name = "#{options[:prefix]}/#{branch_name}" unless options[:prefix].nil?
|
35
|
-
save_issue(branch: branch_name, id: response['iid'], title: response['title'].tr("'", ' '))
|
35
|
+
save_issue(branch: branch_name, id: response['iid'], title: response['title'].tr("'", ' ').tr('_', ' '))
|
36
36
|
create_branch(name: branch_name, from_current: options[:from_current]) unless options[:later]
|
37
37
|
set_issue_estimation(
|
38
38
|
issue_id: response['iid'],
|
@@ -48,7 +48,6 @@ module Fgi
|
|
48
48
|
# => Return to the default project branch
|
49
49
|
# @param options [Hash] the options given by the user in the command line
|
50
50
|
def fix_issue(options)
|
51
|
-
current_branch = `git branch | grep '*'`.gsub('* ', '').chomp
|
52
51
|
if ISSUES[current_branch].nil?
|
53
52
|
puts "We could not find any issues to fix on your current branch (#{current_branch})."
|
54
53
|
exit!
|
@@ -74,6 +73,31 @@ module Fgi
|
|
74
73
|
end
|
75
74
|
end
|
76
75
|
|
76
|
+
def current_branch
|
77
|
+
`git branch | grep '*'`.gsub('* ', '').chomp
|
78
|
+
end
|
79
|
+
|
80
|
+
# TODO, Make sure it works for all git services
|
81
|
+
# The method to set the estimation time to resolve the issue
|
82
|
+
# @param issue_id [Integer] the issue id to set its estimation time
|
83
|
+
# @param estimation [String] the estimation time given by the user
|
84
|
+
# @param git_service [Class] the git service class to use for this project
|
85
|
+
def set_issue_estimation(issue_id:, estimation:, git_service:)
|
86
|
+
return if estimation.nil?
|
87
|
+
# Since GitLab version isn't up to date, we should be able
|
88
|
+
# to add estimations in issues comments (/estimate)
|
89
|
+
url_with_querystring = "#{git_service.routes[:issues]}/#{issue_id}/time_estimate?duration=#{estimation}"
|
90
|
+
headers = { git_service.token_header => TOKEN, 'Content-Type' => 'application/json' }
|
91
|
+
response = post(url: url_with_querystring, headers: headers)
|
92
|
+
# GitLab sucks sometimes... This API is an example
|
93
|
+
begin
|
94
|
+
response_body = JSON.parse(response[:body])
|
95
|
+
rescue Exception
|
96
|
+
response_body = response[:body]
|
97
|
+
end
|
98
|
+
post_estimation_display(response_body['human_time_estimate'], estimation)
|
99
|
+
end
|
100
|
+
|
77
101
|
private
|
78
102
|
|
79
103
|
def ask_for_remote
|
@@ -128,26 +152,6 @@ module Fgi
|
|
128
152
|
File.open('.current_issues.fgi.yml', 'w') { |f| f.write(issues.to_yaml) }
|
129
153
|
end
|
130
154
|
|
131
|
-
# TODO, Make sure it works for all git services
|
132
|
-
# The method to set the estimation time to resolve the issue
|
133
|
-
# @param issue_id [Integer] the issue id to set its estimation time
|
134
|
-
# @param estimation [String] the estimation time given by the user
|
135
|
-
# @param git_service [Class] the git service class to use for this project
|
136
|
-
def set_issue_estimation(issue_id:, estimation:, git_service:)
|
137
|
-
return if estimation.nil?
|
138
|
-
# Since GitLab version isn't up to date, we should be able
|
139
|
-
# to add estimations in issues comments (/estimate)
|
140
|
-
url_with_querystring = "#{git_service.routes[:issues]}/#{issue_id}/time_estimate?duration=#{estimation}"
|
141
|
-
response = post(url: url_with_querystring, headers: headers)
|
142
|
-
# GitLab sucks sometimes... This API is an example
|
143
|
-
begin
|
144
|
-
response_body = JSON.parse(response[:body])
|
145
|
-
rescue Exception
|
146
|
-
response_body = response[:body]
|
147
|
-
end
|
148
|
-
post_estimation_display(response_body['human_time_estimate'], estimation)
|
149
|
-
end
|
150
|
-
|
151
155
|
# TODO, Make sure it works for all git services
|
152
156
|
# The method used to create issues
|
153
157
|
# @param title [String] the issue title
|
@@ -170,7 +174,7 @@ module Fgi
|
|
170
174
|
# @param name [String] the branch name
|
171
175
|
def create_branch(name:, from_current:)
|
172
176
|
from = if from_current
|
173
|
-
|
177
|
+
current_branch
|
174
178
|
else
|
175
179
|
CONFIG[:default_branch]
|
176
180
|
end
|
@@ -179,8 +183,7 @@ module Fgi
|
|
179
183
|
`git checkout #{from}` # Be sure to be on the default or specified branch.
|
180
184
|
`git pull #{git_remote} HEAD` # Be sure to get the remote changes locally.
|
181
185
|
`git checkout -b #{name}` # Create the new branch.
|
182
|
-
|
183
|
-
puts "\nYou are now working on branch #{to} created from #{from} !"
|
186
|
+
puts "\nYou are now working on branch #{current_branch} created from #{from} !"
|
184
187
|
end
|
185
188
|
|
186
189
|
# The method used to get the issue description
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fgi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Julien Philibin
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-10-
|
12
|
+
date: 2017-10-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|