intello-shipit-cli 0.6.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 44dd9830edd5ed4fc56bb507e655a2a29a3e63d8d494b379f6f2008cf204f2a0
4
+ data.tar.gz: 19ffcde87be2aaa98b6dc51f448b360b945a818494c64058b34dc9dd5ef386e2
5
+ SHA512:
6
+ metadata.gz: 271391edd56d02cd68a9081c24f8f328dcd793c89c9e1444ff971958b6c78dd96eac678361a5c6b2f20b33bec27b637f02f6a2a1f16e03e955963a800594b167
7
+ data.tar.gz: c573f7fc35fc001271316163e5704fb01262802d682b3c7156d14b5fbebcc3cf2ee394748eacd485bc8124a58dba914dc3d5e35c99590c8ece81253454cf9c41
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ .DS_Store
2
+ /.bundle/
3
+ /.yardoc
4
+ /Gemfile.lock
5
+ /_yardoc/
6
+ /coverage/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ gems.tags
11
+ tags
data/.rbenv-vars ADDED
@@ -0,0 +1,2 @@
1
+ SHIPIT_TOKEN=e9dcf63ac25554df23fb27b8a1e3c2f43495b8a4cda1f7842ffdf05bf20d4b98c20cbf5195f5744ad0ca856b8d1f2a7ead6c214794ff9cd59f4e3e60e45910ec
2
+ GEMFURY_TOKEN=wQUZrGXsyxMh5KMQx3W4
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.rubocop.yml ADDED
@@ -0,0 +1 @@
1
+ inherit_from: .ruby-style.yml
data/.ruby-style.yml ADDED
@@ -0,0 +1,249 @@
1
+ AllCops:
2
+ Exclude:
3
+ - "bin/**/*"
4
+ - "config/environments/**/*"
5
+ - "config/initializers/**/*"
6
+ - "db/migrate/**/*"
7
+ - "db/schema.rb"
8
+ - "lib/tasks/**/*"
9
+ - "vendor/**/*"
10
+ UseCache: false
11
+ Style/CollectionMethods:
12
+ Description: Preferred collection methods.
13
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#map-find-select-reduce-size
14
+ Enabled: true
15
+ PreferredMethods:
16
+ collect: map
17
+ collect!: map!
18
+ find: detect
19
+ find_all: select
20
+ reduce: inject
21
+ Style/DotPosition:
22
+ Description: Checks the position of the dot in multi-line method calls.
23
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#consistent-multi-line-chains
24
+ Enabled: true
25
+ EnforcedStyle: trailing
26
+ SupportedStyles:
27
+ - leading
28
+ - trailing
29
+ Style/FileName:
30
+ Description: Use snake_case for source file names.
31
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#snake-case-files
32
+ Enabled: false
33
+ Exclude: []
34
+ Style/GuardClause:
35
+ Description: Check for conditionals that can be replaced with guard clauses
36
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-nested-conditionals
37
+ Enabled: false
38
+ MinBodyLength: 1
39
+ Style/IfUnlessModifier:
40
+ Description: Favor modifier if/unless usage when you have a single-line body.
41
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#if-as-a-modifier
42
+ Enabled: false
43
+ MaxLineLength: 100
44
+ Style/OptionHash:
45
+ Description: Don't use option hashes when you can use keyword arguments.
46
+ Enabled: false
47
+ Style/PercentLiteralDelimiters:
48
+ Description: Use `%`-literal delimiters consistently
49
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#percent-literal-braces
50
+ Enabled: false
51
+ PreferredDelimiters:
52
+ "%": "()"
53
+ "%i": "()"
54
+ "%q": "()"
55
+ "%Q": "()"
56
+ "%r": "{}"
57
+ "%s": "()"
58
+ "%w": "()"
59
+ "%W": "()"
60
+ "%x": "()"
61
+ Style/PredicateName:
62
+ Description: Check the names of predicate methods.
63
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#bool-methods-qmark
64
+ Enabled: true
65
+ NamePrefix:
66
+ - is_
67
+ - has_
68
+ - have_
69
+ NamePrefixBlacklist:
70
+ - is_
71
+ Exclude:
72
+ - spec/**/*
73
+ Style/RaiseArgs:
74
+ Description: Checks the arguments passed to raise/fail.
75
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#exception-class-messages
76
+ Enabled: false
77
+ EnforcedStyle: exploded
78
+ SupportedStyles:
79
+ - compact
80
+ - exploded
81
+ Style/SignalException:
82
+ Description: Checks for proper usage of fail and raise.
83
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#fail-method
84
+ Enabled: false
85
+ EnforcedStyle: semantic
86
+ SupportedStyles:
87
+ - only_raise
88
+ - only_fail
89
+ - semantic
90
+ Style/SingleLineBlockParams:
91
+ Description: Enforces the names of some block params.
92
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#reduce-blocks
93
+ Enabled: false
94
+ Methods:
95
+ - reduce:
96
+ - a
97
+ - e
98
+ - inject:
99
+ - a
100
+ - e
101
+ Style/SingleLineMethods:
102
+ Description: Avoid single-line methods.
103
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-single-line-methods
104
+ Enabled: false
105
+ AllowIfMethodIsEmpty: true
106
+ Style/StringLiterals:
107
+ Description: Checks if uses of quotes match the configured preference.
108
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#consistent-string-literals
109
+ Enabled: true
110
+ EnforcedStyle: double_quotes
111
+ SupportedStyles:
112
+ - single_quotes
113
+ - double_quotes
114
+ Style/StringLiteralsInInterpolation:
115
+ Description: Checks if uses of quotes inside expressions in interpolated strings
116
+ match the configured preference.
117
+ Enabled: true
118
+ EnforcedStyle: single_quotes
119
+ SupportedStyles:
120
+ - single_quotes
121
+ - double_quotes
122
+ Style/TrailingComma:
123
+ Description: Checks for trailing comma in parameter lists and literals.
124
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas
125
+ Enabled: false
126
+ EnforcedStyleForMultiline: no_comma
127
+ SupportedStyles:
128
+ - comma
129
+ - no_comma
130
+ Metrics/AbcSize:
131
+ Description: A calculated magnitude based on number of assignments, branches, and
132
+ conditions.
133
+ Enabled: false
134
+ Max: 15
135
+ Metrics/ClassLength:
136
+ Description: Avoid classes longer than 100 lines of code.
137
+ Enabled: false
138
+ CountComments: false
139
+ Max: 100
140
+ Metrics/ModuleLength:
141
+ CountComments: false
142
+ Max: 100
143
+ Description: Avoid modules longer than 100 lines of code.
144
+ Enabled: false
145
+ Metrics/CyclomaticComplexity:
146
+ Description: A complexity metric that is strongly correlated to the number of test
147
+ cases needed to validate a method.
148
+ Enabled: false
149
+ Max: 6
150
+ Metrics/LineLength:
151
+ Description: Limit lines to 120 characters.
152
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#80-character-limits
153
+ Enabled: true
154
+ Max: 120
155
+ AllowURI: true
156
+ URISchemes:
157
+ - http
158
+ - https
159
+ Metrics/MethodLength:
160
+ Description: Avoid methods longer than 10 lines of code.
161
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#short-methods
162
+ Enabled: false
163
+ CountComments: false
164
+ Max: 10
165
+ Metrics/ParameterLists:
166
+ Description: Avoid parameter lists longer than three or four parameters.
167
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#too-many-params
168
+ Enabled: false
169
+ Max: 5
170
+ CountKeywordArgs: true
171
+ Metrics/PerceivedComplexity:
172
+ Description: A complexity metric geared towards measuring complexity for a human
173
+ reader.
174
+ Enabled: false
175
+ Max: 7
176
+ Lint/AssignmentInCondition:
177
+ Description: Don't use assignment in conditions.
178
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#safe-assignment-in-condition
179
+ Enabled: false
180
+ AllowSafeAssignment: true
181
+ Style/InlineComment:
182
+ Description: Avoid inline comments.
183
+ Enabled: false
184
+ Style/AccessorMethodName:
185
+ Description: Check the naming of accessor methods for get_/set_.
186
+ Enabled: false
187
+ Style/Alias:
188
+ Description: Use alias_method instead of alias.
189
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#alias-method
190
+ Enabled: false
191
+ Style/Documentation:
192
+ Description: Document classes and non-namespace modules.
193
+ Enabled: false
194
+ Style/DoubleNegation:
195
+ Description: Checks for uses of double negation (!!).
196
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-bang-bang
197
+ Enabled: false
198
+ Style/EachWithObject:
199
+ Description: Prefer `each_with_object` over `inject` or `reduce`.
200
+ Enabled: false
201
+ Style/EmptyLiteral:
202
+ Description: Prefer literals to Array.new/Hash.new/String.new.
203
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#literal-array-hash
204
+ Enabled: false
205
+ Style/ModuleFunction:
206
+ Description: Checks for usage of `extend self` in modules.
207
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#module-function
208
+ Enabled: false
209
+ Style/OneLineConditional:
210
+ Description: Favor the ternary operator(?:) over if/then/else/end constructs.
211
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#ternary-operator
212
+ Enabled: false
213
+ Style/PerlBackrefs:
214
+ Description: Avoid Perl-style regex back references.
215
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-perl-regexp-last-matchers
216
+ Enabled: false
217
+ Style/Send:
218
+ Description: Prefer `Object#__send__` or `Object#public_send` to `send`, as `send`
219
+ may overlap with existing methods.
220
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#prefer-public-send
221
+ Enabled: false
222
+ Style/SpecialGlobalVars:
223
+ Description: Avoid Perl-style global variables.
224
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-cryptic-perlisms
225
+ Enabled: false
226
+ Style/VariableInterpolation:
227
+ Description: Don't interpolate global, instance and class variables directly in
228
+ strings.
229
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#curlies-interpolate
230
+ Enabled: false
231
+ Style/WhenThen:
232
+ Description: Use when x then ... for one-line cases.
233
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#one-line-cases
234
+ Enabled: false
235
+ Lint/EachWithObjectArgument:
236
+ Description: Check for immutable argument given to each_with_object.
237
+ Enabled: true
238
+ Lint/HandleExceptions:
239
+ Description: Don't suppress exception.
240
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#dont-hide-exceptions
241
+ Enabled: false
242
+ Lint/LiteralInCondition:
243
+ Description: Checks of literals used in conditions.
244
+ Enabled: false
245
+ Lint/LiteralInInterpolation:
246
+ Description: Checks for literals used in interpolation.
247
+ Enabled: false
248
+ Style/GlobalVars:
249
+ AllowedVariables: [ "$redis" ]
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.5.0
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in shipit-cli.gemspec
4
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,27 @@
1
+ guard :rspec, cmd: "bundle exec rspec" do
2
+ require "guard/rspec/dsl"
3
+ dsl = Guard::RSpec::Dsl.new(self)
4
+
5
+ # Feel free to open issues for suggestions and improvements
6
+
7
+ # RSpec files
8
+ rspec = dsl.rspec
9
+ watch(rspec.spec_helper) { rspec.spec_dir }
10
+ watch(rspec.spec_support) { rspec.spec_dir }
11
+ watch(rspec.spec_files)
12
+
13
+ # Ruby files
14
+ ruby = dsl.ruby
15
+ dsl.watch_spec_files_for(ruby.lib_files)
16
+ end
17
+
18
+ guard "ctags-bundler", src_path: ["lib", "spec/support"] do
19
+ watch(%r{(lib|spec\/support)\/.*\.rb$/})
20
+ watch("Gemfile.lock")
21
+ end
22
+
23
+ guard :rubocop do
24
+ watch(%r{exe/*})
25
+ watch(/.+\.rb$/)
26
+ watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
27
+ end
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright Intello Technologies Inc, 2016-2019.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,154 @@
1
+ # intello-shipit-cli
2
+
3
+ ## Description
4
+
5
+ Shipit CLI is a gem created by Intello's development team.
6
+
7
+ Designed to simplify collaboration with Git and Gitlab, its main purpose is to kickstart working on an issue. Here's what it does :
8
+
9
+ 1. Create a new branch (local & remote) using a standardized name.
10
+ 2. Add & push a first empty commit to that branch.
11
+ 3. Create a new merge request on Gitlab, with all the issue details.
12
+
13
+ ## Requirements
14
+
15
+ - Ruby 2.5+
16
+ - RubyGems 1.9+
17
+ - A `gitlab` personal access token (`https://{{ YOUR_GITLAB_HOST }}/profile/personal_access_tokens`)
18
+ - Issues must have a label and a milestone
19
+
20
+ `intello-shipit-cli` works as well on gitlab.com as on a privately hosted instance of Gitlab
21
+
22
+ ## Install/Update
23
+
24
+ ```bash
25
+ gem install intello-shipit-cli
26
+ ```
27
+
28
+ > NOTE: If you use a ruby manager, the gem has to be installed each time you want to use it in a new ruby context.
29
+
30
+ ### PROTIP
31
+
32
+ If you use rbenv as your ruby manager, and want to easily install/update `intello-shipit-cli` across all your rubies:
33
+
34
+ 1. Install [rbenv-each](https://github.com/rbenv/rbenv-each)
35
+ 1. Run `rbenv each gem install intello-shipit-cli`
36
+
37
+ ## Setup
38
+
39
+ You must first setup `intello-shipit-cli` by running:
40
+
41
+ ```bash
42
+ shipit setup
43
+ ```
44
+
45
+ This will interactivly ask you for:
46
+
47
+ - Your Gitlab server instance API endpoint. If your using gitlab.com this endpoint is `https://gitlab.com/api/v4`
48
+ - Your Gitlab personal API token
49
+
50
+ The setup will create a file in your user root folder called `.shipit.yml` with this information.
51
+
52
+ ### PROTIP
53
+
54
+ If you have multiple Gitlab servers or account you can manually create configuration YAML files and use the `-c` option of `intello-shipit-cli` to select the proper configuration.
55
+
56
+ For example you can have a configuration file ` ~/.shipit_personal.yml` for your peronal account an to use that you would invoke `intello-shipit-cli` with: `shipit -c ~/.shipit_personal.yml work 22`.
57
+
58
+ ### Check your configuration
59
+
60
+ ```bash
61
+ $ shipit settings
62
+ ```
63
+
64
+ ### Usage
65
+
66
+ The most often used command is `work` this is the command that will create a branch and merge request based on a ticket in the project you are currently working.
67
+
68
+ Let's take an example. We have the project 'test_shipit' already checked-out and we have issue #1 (Major bug with UI) that we want to start working on.
69
+
70
+ Without `intello-shipit-cli` you would either go in the Gitlab Web UI and create a branch and then open a merge request on that branch or do the same with a bunch of git CLI commands. The resulting merge request and branch names would vary from one developer to the other and would be a pain to do things like changelogs later on.
71
+
72
+ With `intello-shipit-cli` you simply run `shipit work 1` and it will do it all for you:
73
+
74
+ ```
75
+ {21:40}[2.5.0]~/Documents/Intello/source/test_shipit:master ✓ ➭ shipit -c work 1
76
+ remote:
77
+ remote: To create a merge request for bug-ac-1-major-bug-with-ui, visit:
78
+ remote: https://gitlab.com/IndianaTux/test_shipit/merge_requests/new?merge_request%5Bsource_branch%5D=bug-ac-1-major-bug-with-ui
79
+ remote:
80
+ remote:
81
+ remote: To create a merge request for bug-ac-1-major-bug-with-ui, visit:
82
+ remote: https://gitlab.com/IndianaTux/test_shipit/merge_requests/new?merge_request%5Bsource_branch%5D=bug-ac-1-major-bug-with-ui
83
+ remote:
84
+
85
+ ****************************************
86
+ * IT'S HIP TO SHIP *
87
+ * *
88
+ * | | | *
89
+ * )_) )_) )_) *
90
+ * )___))___))___)\ *
91
+ * )____)____)_____)\ *
92
+ * _____|____|____|____\__ *
93
+ *--------\ /---------*
94
+ * ^^^^^^^^^^^^^^^^^^^^^^ *
95
+ ****************************************
96
+ {21:41}[2.5.0]~/Documents/Intello/source/test_shipit:bug-ac-1-major-bug-with-ui ✓ ➭
97
+ ```
98
+
99
+ As you can see it created the branch `bug-ac-1-major-bug-with-ui` which corresponds to the issue label (first one selected if multiple are selected), the initials of the developper working on the issue and part of the issue title.
100
+
101
+ It will also have created a matching merge request:
102
+
103
+ ![alt text](doc/mr.png)
104
+
105
+ All you have to do is start coding.
106
+
107
+ ## Contributing
108
+
109
+ - Create a ticket
110
+ - Request developper access
111
+ - Use `intello-shipit-cli` to start coding
112
+ - When your ready, submit your merge request to one of the maintainers
113
+
114
+ ## Development Setup
115
+
116
+ ### Dependencies
117
+
118
+ * rbenv or rvm
119
+ * Ruby 2.5+
120
+ * RubyGems 1.9+ (`gem update --system `)
121
+ * Bundler 1.10+
122
+ * [ctags](http://ctags.sourceforge.net/)
123
+
124
+ ### Setup
125
+
126
+ To install or update your development environment, run `script/bootstrap`.
127
+
128
+ ### Install
129
+
130
+ 1. Clone the git repository.
131
+ 1. Run `script/bootstrap` to install the required gems.
132
+ 1. Run `script/test` to ensure your development setup is sane.
133
+ 1. Run `bundle exec guard`
134
+ 1. You can run a REPL: `script/console`
135
+ 1. Use the CLI: `bundle exec exe/shipit`
136
+
137
+ ### Testing
138
+
139
+ You can write tests using `rspec v3+` syntax in the `spec` folder. To run the tests, run `script/test`.
140
+
141
+ ## License
142
+
143
+ Copyright Intello Technologies Inc, 2016-2019. Licensed under the [MIT license](/LICENSE?raw=true).
144
+
145
+ ## About Intello Technologies Inc.
146
+
147
+ Intello is sponsering this project as we believe in open-source and the open-source community.
148
+
149
+ Intello Technologies was founded by experts from hotel & IT industry backgrounds in 2003. Based in Montreal, Canada, we're more than just a services company or a simple VAR: we develop our own in-house software which we integrate with existing industry-leading hardware and then support for years to come.
150
+
151
+ Our team has in-depth knowledge of software development combined with years of sales and field management experience in the hospitality and lodging industries. Our solutions have been deployed throughout the United States, Canada, Mexico, the Caribbean and even in Africa, and our helpdesk ensures our customers are supported around the clock. Recognized as industry leaders in our fields of expertise, our company goal is to provide great solutions and support.
152
+
153
+ Find out more ou our web site at <https://www.intello.com>
154
+
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
data/doc/mr.png ADDED
Binary file
data/exe/shipit ADDED
@@ -0,0 +1,129 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ begin
4
+ require "gli"
5
+ require "json"
6
+ require "gitlab"
7
+ require "shipit/cli"
8
+ rescue LoadError => e
9
+ puts "/!\\ Error while trying to load a dependency."
10
+ puts " Try to run `gem update shipit-cli` to update your dependency version requirements"
11
+ puts " Exception message: #{e.message}"
12
+ exit
13
+ end
14
+
15
+ include GLI::App
16
+
17
+ program_desc "The best way to shipit with Gitlab"
18
+
19
+ version Shipit::Cli::VERSION
20
+ subcommand_option_handling :normal
21
+ sort_help :manually
22
+
23
+ # Flags
24
+ flag [:c, :config], default_value: File.join(ENV["HOME"], ".shipit.yml"), desc: "Set the saved configuration path"
25
+ flag [:e, :endpoint], desc: "Set the shipit API endpoint"
26
+ flag [:p, :private_token], desc: "Set your private token to access the shipit API"
27
+
28
+ # Switches
29
+ switch :dry_run, default_value: false, desc: "Dry Run mode, no git or POST/PUT commands are run"
30
+
31
+ pre do |global_options, command, _options, _args|
32
+ unless command.name.to_s == "setup"
33
+ config_file = Shipit::Cli::ConfigurationFile.new(global_options["config"])
34
+ if config_file.exist?
35
+ config_options = config_file.to_hash
36
+ else
37
+ config_options = {}
38
+ end
39
+
40
+ config_options.merge! global_options.delete_if { |_k, v| v.nil? || v == "" }
41
+ Shipit::Cli.configure(config_options)
42
+ end
43
+ true
44
+ end
45
+
46
+ desc "Shows current configuration settings"
47
+ command :settings do |c|
48
+ c.action do |_global_options, _options, _args|
49
+ puts "---------------------"
50
+ Shipit::Cli.config.to_stdout
51
+ puts "---------------------"
52
+ end
53
+ end
54
+
55
+ desc "ASCII art FTW"
56
+ command :ascii do |c|
57
+ c.action do |global_options, _options, args|
58
+ Shipit::Cli.ascii
59
+ end
60
+ end
61
+
62
+ desc "Start working on a ticket"
63
+ command :work do |c|
64
+ c.action do |global_options, _options, args|
65
+ help_now!("Issue ID is required") if args.empty?
66
+ issue_id = args.shift.to_i
67
+ target_branch = Shipit::Cli::Git.get_current_branch
68
+ client = Gitlab.client(endpoint: Shipit::Cli.config.endpoint, private_token: Shipit::Cli.config.private_token)
69
+ opts = global_options.merge(client: client)
70
+
71
+ if global_options["dry_run"] == true
72
+ puts "*************************************************************************************"
73
+ puts "*** DRY RUN, no creation commands will be executed (local git or remote POST/PUT) ***"
74
+ puts "*************************************************************************************"
75
+ puts ""
76
+ end
77
+
78
+ Shipit::Cli::Work.new(issue_id, opts).perform(target_branch)
79
+ end
80
+ end
81
+
82
+ desc "Saves your shipit settings for later"
83
+ command :setup do |c|
84
+ c.action do |global_options, _options, _args|
85
+ data = {}
86
+
87
+ puts "** What is your shipit endpoint? (Leave blank for default: https://gitlab.com/api/v4)"
88
+ choice = STDIN.gets.chomp
89
+ endpoint = choice == "" ? "https://gitlab.com/api/v4" : choice
90
+ data["endpoint"] = endpoint
91
+
92
+ puts "** What is your shipit private_token?"
93
+ choice = STDIN.gets.chomp
94
+ raise("You need to type a private token.") if choice == ""
95
+ data["private_token"] = choice
96
+
97
+ config_file = Shipit::Cli::ConfigurationFile.new(global_options["config"], data)
98
+ config_file.persist
99
+ puts ""
100
+ puts "* Your configuration data has been saved at #{global_options[:config]}"
101
+ end
102
+ end
103
+
104
+ desc "Clean up merged branches"
105
+ command :prune do |c|
106
+ c.action do |global_options, _options, _args|
107
+ puts "************************"
108
+ puts "*** DEPRECATED ***"
109
+ puts "************************"
110
+ puts "You can try to set an alias for the following commands :"
111
+ puts "* To prune the remote branches :"
112
+ puts " $ git remote prune origin"
113
+ puts "* To prune the local branches :"
114
+ puts " $ git fetch origin && git branch --merged master | grep -v \"\* master\" | xargs -n 1 git branch -d"
115
+ end
116
+ end
117
+
118
+ on_error do |exception|
119
+ data = {}
120
+ data[:class_name] = exception.class.name
121
+ data[:exception] = exception.message
122
+ data[:backtrace] = exception.message
123
+ puts data.inspect
124
+ # Error logic here
125
+ # return false to skip default error handling
126
+ true
127
+ end
128
+
129
+ exit run(ARGV)