fgi 0.2.6.1
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 +7 -0
- data/.gitignore +13 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/Gemfile +4 -0
- data/README.md +34 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/exe/fgi +40 -0
- data/fgi.gemspec +26 -0
- data/lib/fgi.rb +18 -0
- data/lib/fgi/config.rb +33 -0
- data/lib/fgi/configurator.rb +84 -0
- data/lib/fgi/executor.rb +11 -0
- data/lib/fgi/generate_file.rb +19 -0
- data/lib/fgi/helper.rb +28 -0
- data/lib/fgi/html_request.rb +30 -0
- data/lib/fgi/version.rb +3 -0
- data/temp.txt +1 -0
- metadata +105 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 65a7cdcdcf40644ac53a898f36f270d2f8197cf7
|
4
|
+
data.tar.gz: 9b55a84bc72637ab6154951679e4e3f99c300bc9
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f8cb0086b860e2d575f36bfeb916d05cbdcc16a880378c79fc45a12315c869b6dd0108eadd9c6b25f0b9a680525771afc6d7d42959a7ce3d18f796c89629172b
|
7
|
+
data.tar.gz: 1cc8bde27b9221f7c782fdc785fb30bf6dbfdbbace9174974b765c163a4ca191bb285a9e239632d65057c0347cf6989b48c6785bdc49a9bb2072a821de70b680
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# Fgi
|
2
|
+
|
3
|
+
## Welcome to Fast Gitlab Issues!
|
4
|
+
|
5
|
+
Fast Gitlab Issues, aka Fgi, is a command line issue creation tool for Gitlab.
|
6
|
+
|
7
|
+
To install, add the following to your project's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'fgi', git: 'git@source.modulotech.fr:modulotech/fgi.git'
|
11
|
+
```
|
12
|
+
|
13
|
+
And run `bundle install`.
|
14
|
+
|
15
|
+
After it finishes, run `$ fgi --config` if the gem is new to the project, or run `$ fgi --token <token>` if you are new to the project and fgi was previously installed.
|
16
|
+
|
17
|
+
From then on, create your issues from the console:
|
18
|
+
|
19
|
+
```sh
|
20
|
+
$ fgi My awesome title goes here
|
21
|
+
```
|
22
|
+
|
23
|
+
This will open our default text editor (currently hardcoded to Vim) so you can provide a description, and when you close, it will create an issue on Gitlab. A link to the new issue will be provided if you want to check it out.
|
24
|
+
|
25
|
+
The following commands are currently supported:
|
26
|
+
|
27
|
+
$ fgi \<title\> \# initiates the process to create a gitlab issue
|
28
|
+
$ fgi --help \# opens this help menu
|
29
|
+
$ fgi --config \# starts the configuration wizard
|
30
|
+
$ fgi --token \<token\> \# saves the private gitlab token to a file and adds it to .gitignore
|
31
|
+
|
32
|
+
The config will ask you for your gitlab access token (you can get it from AF2) and the project URL from gitlab.
|
33
|
+
|
34
|
+
Any bugs/requests please open an issue, feel free to use fgi to do so!
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "fgi"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/exe/fgi
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'open3'
|
4
|
+
require "fgi"
|
5
|
+
|
6
|
+
# extract core logic from here into the gem bin
|
7
|
+
module Fgi
|
8
|
+
class Command
|
9
|
+
def initialize(content)
|
10
|
+
# convert title into a string we can use in a curl request
|
11
|
+
content = content.join(' ')
|
12
|
+
case
|
13
|
+
when content.empty?
|
14
|
+
Fgi::Helper.run
|
15
|
+
when content.match(/--help/)
|
16
|
+
Fgi::Helper.run
|
17
|
+
when content.match(/--config/)
|
18
|
+
Fgi::Configurator.run
|
19
|
+
when content.match(/--token/)
|
20
|
+
Fgi::Configurator.save_gitlab_token(content.strip.split(' ').last)
|
21
|
+
else
|
22
|
+
title = content
|
23
|
+
description = []
|
24
|
+
success = system("vim temp.txt")
|
25
|
+
if success
|
26
|
+
File.open("temp.txt", "r") do |f|
|
27
|
+
f.each_line do |line|
|
28
|
+
description << line
|
29
|
+
end
|
30
|
+
end
|
31
|
+
# convert the description of the issue into a string we can use in a curl request
|
32
|
+
description = description.join
|
33
|
+
end
|
34
|
+
Fgi::Executor.new.process_data(title, description)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
Fgi::Command.new(ARGV)
|
data/fgi.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'fgi/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "fgi"
|
8
|
+
spec.version = Fgi::VERSION
|
9
|
+
spec.authors = ["Julien PHILIBIN, ""Pedro Coutinho"]
|
10
|
+
spec.email = ["philib_j@modulotech.fr"]
|
11
|
+
|
12
|
+
spec.summary = %q{CLI for gitlab.}
|
13
|
+
spec.description = %q{Fast Gitlab Issues.}
|
14
|
+
spec.homepage = "https://www.modulotech.fr"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
17
|
+
f.match(%r{^(test|spec|features)/})
|
18
|
+
end
|
19
|
+
spec.bindir = "exe"
|
20
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
|
+
spec.require_paths = ["lib"]
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.13"
|
24
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
25
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
26
|
+
end
|
data/lib/fgi.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'yaml'
|
4
|
+
require 'json'
|
5
|
+
|
6
|
+
module Fgi
|
7
|
+
class << self
|
8
|
+
end
|
9
|
+
autoload :Config, 'fgi/config'
|
10
|
+
autoload :Version, 'fgi/version'
|
11
|
+
autoload :Executor, 'fgi/executor'
|
12
|
+
autoload :HTMLRequest, 'fgi/html_request'
|
13
|
+
autoload :Helper, 'fgi/helper'
|
14
|
+
autoload :Configurator, 'fgi/configurator'
|
15
|
+
autoload :GenerateFile, 'fgi/generate_file'
|
16
|
+
|
17
|
+
CONFIG_FILE = '.fast_gitlab_issues.yml'
|
18
|
+
end
|
data/lib/fgi/config.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
module Fgi
|
2
|
+
class Config
|
3
|
+
class << self
|
4
|
+
def load(source)
|
5
|
+
@config = { :url => nil, :project_gitlab_id => nil, :project_namespaced => nil }
|
6
|
+
|
7
|
+
Fgi::GenerateFile.new(@config) if !File.exist?(source)
|
8
|
+
Fgi::GenerateFile.token if !File.exist?('.gitlab_access_token')
|
9
|
+
|
10
|
+
config = YAML.load_file(source)
|
11
|
+
token = File.open(".gitlab_access_token", "rb").read
|
12
|
+
@config.merge! config if config
|
13
|
+
@config[:token] = token
|
14
|
+
end
|
15
|
+
|
16
|
+
def include?(key)
|
17
|
+
@config.include?(key)
|
18
|
+
end
|
19
|
+
|
20
|
+
def [](key)
|
21
|
+
@config[key]
|
22
|
+
end
|
23
|
+
|
24
|
+
def to_yaml
|
25
|
+
@config.to_yaml
|
26
|
+
end
|
27
|
+
|
28
|
+
def current
|
29
|
+
@config ||= { :url => nil, :project_gitlab_id => nil, :project_namespaced => nil }
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
module Fgi
|
2
|
+
class Configurator
|
3
|
+
class << self
|
4
|
+
def run
|
5
|
+
@config = Fgi::Config.current
|
6
|
+
not_git_directory = !File.exist?(File.expand_path('.gitignore'))
|
7
|
+
puts "This doesn't seem to be the root of a git repository, browse to the root of your project and try again." if not_git_directory
|
8
|
+
return if not_git_directory
|
9
|
+
puts ''
|
10
|
+
puts '####################################################################'
|
11
|
+
puts ' Welcome to Fast Gitlab Issues configuration '
|
12
|
+
puts '####################################################################'
|
13
|
+
puts ''
|
14
|
+
puts "Please enter your Gitlab access token:"
|
15
|
+
validate_and_save_gitlab_token
|
16
|
+
puts "Please paste the project url:"
|
17
|
+
get_id_from_gitlab
|
18
|
+
File.open('.fast_gitlab_issues.yml', 'w') {|f| f.write @config.to_yaml }
|
19
|
+
puts "You are now set to work on #{@config[:project_namespaced]}."
|
20
|
+
puts "Your configuration has been saved to .fast_gitlab_issues.yml, enjoy!"
|
21
|
+
puts ''
|
22
|
+
puts '####################################################################'
|
23
|
+
end
|
24
|
+
|
25
|
+
def get_id_from_gitlab
|
26
|
+
puts 'example: http://YOUR_GITLAB_URL/modulotech/fast-gitlab-issues'
|
27
|
+
@uri = URI.parse(STDIN.gets.chomp)
|
28
|
+
@config[:url] = "#{@uri.scheme}://#{@uri.host}"
|
29
|
+
uri = URI.parse("#{@config[:url]}/api/v4/projects?search=#{@uri.path.split('/').last}")
|
30
|
+
Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
|
31
|
+
req = Net::HTTP::Get.new uri
|
32
|
+
req['Authorization'] = "Bearer #{@token}"
|
33
|
+
@response = JSON.parse(http.request(req).body)
|
34
|
+
end
|
35
|
+
if !@response[0].nil?
|
36
|
+
puts "Found #{@response.count} match(es):"
|
37
|
+
@response.each_with_index do |response, i|
|
38
|
+
puts "#{i+1} - #{response['name']}"
|
39
|
+
end
|
40
|
+
puts "Please insert the number of the current project:"
|
41
|
+
@option = STDIN.gets.chomp.to_i
|
42
|
+
validate_option
|
43
|
+
else
|
44
|
+
puts "We couldn't find a project called #{@uri.path.split('/').last}, can you please double check that url?"
|
45
|
+
get_id_from_gitlab
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def validate_option
|
50
|
+
if (1..@response.length+1).include?(@option)
|
51
|
+
@config[:project_gitlab_id] = @response[@option - 1]["id"]
|
52
|
+
@config[:project_namespaced] = @response[@option - 1]["path_with_namespace"]
|
53
|
+
else
|
54
|
+
puts "Sorry, the option is out of range, try again:"
|
55
|
+
@option = STDIN.gets.chomp.to_i
|
56
|
+
validate_option
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def validate_and_save_gitlab_token
|
61
|
+
@token = STDIN.gets.chomp
|
62
|
+
if @token.length > 30
|
63
|
+
save_gitlab_token(@token)
|
64
|
+
else
|
65
|
+
puts "That doesn't seem to be a valid token, can you please check again?"
|
66
|
+
validate_and_save_gitlab_token
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def save_gitlab_token(token)
|
71
|
+
@token = token
|
72
|
+
File.open('.gitlab_access_token', 'w') {|f| f.write @token }
|
73
|
+
if File.open('.gitignore').grep(/.gitlab_access_token/).empty?
|
74
|
+
open('.gitignore', 'a') do |f|
|
75
|
+
f.puts ''
|
76
|
+
f.puts "# Gfi secret token for gitlab"
|
77
|
+
f.puts ".gitlab_access_token"
|
78
|
+
end
|
79
|
+
end
|
80
|
+
puts "Gitlab secret token successfully saved to file and added to .gitignore."
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
data/lib/fgi/executor.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
module Fgi
|
2
|
+
class GenerateFile
|
3
|
+
def initialize(config)
|
4
|
+
puts "Config file not found. Do you want to create a config file here? (Y/n)"
|
5
|
+
if STDIN.gets.chomp != 'Y'
|
6
|
+
puts "Closing...."
|
7
|
+
raise "Failed to find a configuration file."
|
8
|
+
else
|
9
|
+
Fgi::Configurator.run
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.token
|
14
|
+
puts 'Please provide a Gitlab access token before continuing:'
|
15
|
+
Fgi::Configurator.validate_and_save_gitlab_token
|
16
|
+
puts 'Thank you very much, we will now proceed.'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/fgi/helper.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
module Fgi
|
2
|
+
class Helper
|
3
|
+
class << self
|
4
|
+
def run
|
5
|
+
puts "
|
6
|
+
Welcome to Fast Gitlab Issues!
|
7
|
+
|
8
|
+
The following commands are currently supported:
|
9
|
+
|
10
|
+
fgi <title> # initiates the process to create a gitlab issue
|
11
|
+
fgi --help # opens this help menu
|
12
|
+
fgi --config # starts the configuration wizard
|
13
|
+
fgi --token <token> # saves the private gitlab token to a file and adds it to .gitignore
|
14
|
+
|
15
|
+
The config will ask you for your gitlab access token (you can get it from AF2) and the project URL from gitlab.
|
16
|
+
|
17
|
+
To create a gitlab issue just type:
|
18
|
+
|
19
|
+
$ fgi My awesome title goes here
|
20
|
+
|
21
|
+
Vim will open so you can write a description, and upon closing, it will be pushed to gitlab.
|
22
|
+
A success message should then appear.
|
23
|
+
|
24
|
+
"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Fgi
|
2
|
+
class HTMLRequest
|
3
|
+
def initialize(title, description)
|
4
|
+
@title = title
|
5
|
+
@description = description
|
6
|
+
end
|
7
|
+
def push
|
8
|
+
uri = URI.parse(generate_link)
|
9
|
+
Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
|
10
|
+
req = Net::HTTP::Post.new uri
|
11
|
+
req['Authorization'] = "Bearer #{Fgi::Config[:token]}"
|
12
|
+
@response = JSON.parse(http.request(req).body)
|
13
|
+
end
|
14
|
+
if !@response["iid"].nil?
|
15
|
+
puts "Your issue has been sucessfully created."
|
16
|
+
puts "To view it, please follow the link bellow:"
|
17
|
+
puts ""
|
18
|
+
puts " #{Fgi::Config[:url]}/#{Fgi::Config[:project_namespaced]}/issues/#{@response["iid"].to_s}"
|
19
|
+
puts ""
|
20
|
+
puts "Thank you for using Fast Gitlab Issues!"
|
21
|
+
else
|
22
|
+
puts "I'm not really sure what happened, but I believe something went wrong."
|
23
|
+
puts "CALL HELP!!!"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
def generate_link
|
27
|
+
Fgi::Config[:url] + "/api/v4/projects/" + Fgi::Config[:project_gitlab_id].to_s + "/issues?title=" + URI.encode(@title) + '&description=' + URI.encode(@description)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/fgi/version.rb
ADDED
data/temp.txt
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
Some description.
|
metadata
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fgi
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.6.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Julien PHILIBIN, Pedro Coutinho
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-04-13 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.13'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.13'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
description: Fast Gitlab Issues.
|
56
|
+
email:
|
57
|
+
- philib_j@modulotech.fr
|
58
|
+
executables:
|
59
|
+
- fgi
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- ".gitignore"
|
64
|
+
- ".rspec"
|
65
|
+
- ".travis.yml"
|
66
|
+
- Gemfile
|
67
|
+
- README.md
|
68
|
+
- Rakefile
|
69
|
+
- bin/console
|
70
|
+
- bin/setup
|
71
|
+
- exe/fgi
|
72
|
+
- fgi.gemspec
|
73
|
+
- lib/fgi.rb
|
74
|
+
- lib/fgi/config.rb
|
75
|
+
- lib/fgi/configurator.rb
|
76
|
+
- lib/fgi/executor.rb
|
77
|
+
- lib/fgi/generate_file.rb
|
78
|
+
- lib/fgi/helper.rb
|
79
|
+
- lib/fgi/html_request.rb
|
80
|
+
- lib/fgi/version.rb
|
81
|
+
- temp.txt
|
82
|
+
homepage: https://www.modulotech.fr
|
83
|
+
licenses: []
|
84
|
+
metadata: {}
|
85
|
+
post_install_message:
|
86
|
+
rdoc_options: []
|
87
|
+
require_paths:
|
88
|
+
- lib
|
89
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - ">="
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - ">="
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
requirements: []
|
100
|
+
rubyforge_project:
|
101
|
+
rubygems_version: 2.5.1
|
102
|
+
signing_key:
|
103
|
+
specification_version: 4
|
104
|
+
summary: CLI for gitlab.
|
105
|
+
test_files: []
|