gl 0.3.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop_todo.yml +9 -4
- data/Gemfile.lock +7 -1
- data/README.md +82 -21
- data/gl.gemspec +2 -0
- data/lib/gl.rb +2 -0
- data/lib/gl/cli/issues.rb +46 -13
- data/lib/gl/cli/merge_requests.rb +90 -15
- data/lib/gl/cli/registry.rb +0 -1
- data/lib/gl/version.rb +1 -1
- metadata +30 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dd4f959f120be84fffe69fcab73589c752645bcf380e5d489bbdeee74f979fa1
|
4
|
+
data.tar.gz: 8d627f1d6bd8bda3645f57ccefea0c2de35d275deaeb9317ee300bcb6df798ed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e7d77af2ee3236e7db33a49ac1808d7c32e93dbcb1715e24329ec6300faab1670c4a5e1dbbfc720ac26166a4018ada46b80b59f74053952dae7634a43c359fe0
|
7
|
+
data.tar.gz: 56e18bab0459050cf6fa4258fb1850ee9f1f0665fae1c87cd448d38ed6891ee5d3881592a482c4223607202439fbfa7f79a0e67d5ebc70c39760052ca3916862
|
data/.rubocop_todo.yml
CHANGED
@@ -1,21 +1,26 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on 2019-08-
|
3
|
+
# on 2019-08-21 14:37:45 +0200 using RuboCop version 0.74.0.
|
4
4
|
# The point is for the user to remove these configuration records
|
5
5
|
# one by one as the offenses are removed from the code base.
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
7
7
|
# versions of RuboCop, may require this file to be generated again.
|
8
8
|
|
9
|
-
# Offense count:
|
9
|
+
# Offense count: 2
|
10
10
|
Lint/ShadowingOuterLocalVariable:
|
11
11
|
Exclude:
|
12
12
|
- 'lib/gl/cli/registry.rb'
|
13
13
|
|
14
|
-
# Offense count:
|
14
|
+
# Offense count: 5
|
15
15
|
Metrics/AbcSize:
|
16
16
|
Max: 48
|
17
17
|
|
18
|
-
# Offense count:
|
18
|
+
# Offense count: 1
|
19
|
+
# Configuration parameters: CountComments.
|
20
|
+
Metrics/ClassLength:
|
21
|
+
Max: 113
|
22
|
+
|
23
|
+
# Offense count: 7
|
19
24
|
# Configuration parameters: CountComments, ExcludedMethods.
|
20
25
|
Metrics/MethodLength:
|
21
26
|
Max: 35
|
data/Gemfile.lock
CHANGED
@@ -1,11 +1,13 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
gl (0.
|
4
|
+
gl (0.3.1)
|
5
5
|
gitlab (~> 4.12)
|
6
6
|
thor (~> 0.20.3)
|
7
|
+
tty-box
|
7
8
|
tty-progressbar (~> 0.17.0)
|
8
9
|
tty-prompt (~> 0.19.0)
|
10
|
+
tty-screen
|
9
11
|
tty-spinner (~> 0.9.1)
|
10
12
|
tty-table (~> 0.11.0)
|
11
13
|
|
@@ -50,6 +52,10 @@ GEM
|
|
50
52
|
terminal-table (1.8.0)
|
51
53
|
unicode-display_width (~> 1.1, >= 1.1.1)
|
52
54
|
thor (0.20.3)
|
55
|
+
tty-box (0.4.0)
|
56
|
+
pastel (~> 0.7.2)
|
57
|
+
strings (~> 0.1.5)
|
58
|
+
tty-cursor (~> 0.7)
|
53
59
|
tty-color (0.5.0)
|
54
60
|
tty-cursor (0.7.0)
|
55
61
|
tty-progressbar (0.17.0)
|
data/README.md
CHANGED
@@ -1,5 +1,22 @@
|
|
1
1
|
# Gl
|
2
2
|
|
3
|
+
- [Gl](#gl)
|
4
|
+
* [Installation](#installation)
|
5
|
+
* [Usage](#usage)
|
6
|
+
+ [Issues](#issues)
|
7
|
+
- [List](#list)
|
8
|
+
- [Open](#open)
|
9
|
+
+ [Merge Requests](#merge-requests)
|
10
|
+
- [Interactive](#interactive)
|
11
|
+
- [List](#list-1)
|
12
|
+
- [Open](#open-1)
|
13
|
+
- [Approve](#approve)
|
14
|
+
- [Merge](#merge)
|
15
|
+
+ [Registry](#registry)
|
16
|
+
* [Development](#development)
|
17
|
+
* [Contributing](#contributing)
|
18
|
+
* [License](#license)
|
19
|
+
|
3
20
|
Gl is a small CLI that hooks into your Git config and GitLab API to easily access information based
|
4
21
|
on the project your are currently in.
|
5
22
|
|
@@ -22,6 +39,8 @@ Commands:
|
|
22
39
|
gl registry # handle registry of the project
|
23
40
|
```
|
24
41
|
|
42
|
+
### Issues
|
43
|
+
#### List
|
25
44
|
```bash
|
26
45
|
$ gl issues list
|
27
46
|
|
@@ -34,23 +53,7 @@ $ gl issues list
|
|
34
53
|
| 33 | XXXXXXXXXXXXXX | XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX |
|
35
54
|
+-----+----------------+-------------------------------------------------------------------------------+
|
36
55
|
```
|
37
|
-
|
38
|
-
```bash
|
39
|
-
$ gl mr list
|
40
|
-
|
41
|
-
+-----+--------------+-------------------------------------------------------------------------------+
|
42
|
-
| IID | Author | Title |
|
43
|
-
+-----+--------------+-------------------------------------------------------------------------------+
|
44
|
-
| 268 | XXXXXXXXXXXX | XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX |
|
45
|
-
| 264 | XXXXXXXXXXXX | XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX |
|
46
|
-
| 217 | XXXXXXXXXXXX | XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX |
|
47
|
-
| 213 | XXXXXXXXXXXX | XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX |
|
48
|
-
| 188 | XXXXXXXXXXXX | XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX |
|
49
|
-
+-----+--------------+-------------------------------------------------------------------------------+
|
50
|
-
```
|
51
|
-
|
52
|
-
Both commands offer a interactive switch which opens the selected merge request/issue after selecting:
|
53
|
-
|
56
|
+
With interactive switch
|
54
57
|
```bash
|
55
58
|
$ gl issues list -i
|
56
59
|
|
@@ -62,15 +65,73 @@ Open a issue (Use ↑/↓ and ←/→ arrow keys, press Enter to select)
|
|
62
65
|
405 - XXXXXXXXXXXX - XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
|
63
66
|
404 - XXXXXXXXXXXX - XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
|
64
67
|
```
|
68
|
+
#### Open
|
69
|
+
Open a issue directly with the IID or viathe interactive list
|
70
|
+
```bash
|
71
|
+
$ gl issue open 409
|
72
|
+
```
|
65
73
|
|
66
|
-
|
74
|
+
### Merge Requests
|
75
|
+
#### Interactive
|
76
|
+
```bash
|
77
|
+
$ gl mr list -i
|
67
78
|
|
79
|
+
Select a merge request (Use ↑/↓ arrow keys, press Enter to select, and letter keys to filter)
|
80
|
+
‣ 2 - robert.mueller - WIP: Update README.md
|
81
|
+
```
|
82
|
+
|
83
|
+
In interactive mode you can also perform all the other actions
|
68
84
|
```bash
|
69
|
-
$ gl
|
70
|
-
|
71
|
-
|
85
|
+
$ gl mr list -i
|
86
|
+
|
87
|
+
Select a merge request 2 - robert.mueller - WIP: Update README.md
|
88
|
+
┌────────────────────────────────────────WIP: Update README.md─────────────────────────────────────────┐
|
89
|
+
│ │
|
90
|
+
│ # Nec verum procul trahuntur velle │
|
91
|
+
│ │
|
92
|
+
│ ## Foedantem blandis malorum mox │
|
93
|
+
│ │
|
94
|
+
│ chipsetMyspace.perlUltra.font_document(iscsiStandbyPermalink( │
|
95
|
+
│ computing_mac_modem, streamingSli)); │
|
96
|
+
│ address_operating = 40 + binComputingTransistor + rw * minimize; │
|
97
|
+
│ wired(-1, qbe_export); │
|
98
|
+
│ │
|
99
|
+
└State: opened────────────────────────────────────────────────────────────────────────by robert.mueller┘
|
100
|
+
What to do next? (Use ↑/↓ arrow keys, press Enter to select)
|
101
|
+
‣ open
|
102
|
+
merge
|
103
|
+
approve
|
104
|
+
exit
|
105
|
+
|
106
|
+
```
|
107
|
+
|
108
|
+
#### List
|
109
|
+
```bash
|
110
|
+
$ gl mr list
|
111
|
+
|
112
|
+
+-----+----------------+-----------------------+
|
113
|
+
| IID | Author | Title |
|
114
|
+
+-----+----------------+-----------------------+
|
115
|
+
| 2 | robert.mueller | WIP: Update README.md |
|
116
|
+
+-----+----------------+-----------------------+
|
117
|
+
```
|
118
|
+
|
119
|
+
#### Open
|
120
|
+
```bash
|
121
|
+
$ gl mr open 2
|
122
|
+
```
|
123
|
+
|
124
|
+
#### Approve
|
125
|
+
```bash
|
126
|
+
$ gl mr approve 2
|
127
|
+
```
|
128
|
+
|
129
|
+
#### Merge
|
130
|
+
```bash
|
131
|
+
$ gl mr merge 2
|
72
132
|
```
|
73
133
|
|
134
|
+
### Registry
|
74
135
|
With the registry subcommand you can get a overview about the registry usage.
|
75
136
|
|
76
137
|
```bash
|
data/gl.gemspec
CHANGED
@@ -30,8 +30,10 @@ Gem::Specification.new do |spec|
|
|
30
30
|
|
31
31
|
spec.add_dependency 'gitlab', '~> 4.12'
|
32
32
|
spec.add_dependency 'thor', '~> 0.20.3'
|
33
|
+
spec.add_dependency 'tty-box'
|
33
34
|
spec.add_dependency 'tty-progressbar', '~> 0.17.0'
|
34
35
|
spec.add_dependency 'tty-prompt', '~> 0.19.0'
|
36
|
+
spec.add_dependency 'tty-screen'
|
35
37
|
spec.add_dependency 'tty-spinner', '~> 0.9.1'
|
36
38
|
spec.add_dependency 'tty-table', '~> 0.11.0'
|
37
39
|
|
data/lib/gl.rb
CHANGED
data/lib/gl/cli/issues.rb
CHANGED
@@ -5,20 +5,9 @@ module Gl
|
|
5
5
|
desc 'list', 'list open issues'
|
6
6
|
option :i
|
7
7
|
def list(project = nil)
|
8
|
-
issues = Gitlab.issues(Gl.current_project(project), state: :opened).auto_paginate
|
9
|
-
|
10
|
-
issues_list = issues.map do |issue|
|
11
|
-
[issue.iid, issue.author.name, issue.title]
|
12
|
-
end
|
13
|
-
|
14
8
|
if options[:i]
|
15
|
-
|
16
|
-
|
17
|
-
issues_list.each do |issue|
|
18
|
-
menu.choice issue.join(' - '), issue[0]
|
19
|
-
end
|
20
|
-
end
|
21
|
-
Gl.open_in_browser("#{Gl.current_project}/issues/#{choice}")
|
9
|
+
id = issue_dialogue(project)
|
10
|
+
Gl.open_in_browser("#{Gl.current_project}/issues/#{id}")
|
22
11
|
else
|
23
12
|
table = TTY::Table.new(%w[IID Author Title],
|
24
13
|
issues_list)
|
@@ -30,5 +19,49 @@ module Gl
|
|
30
19
|
def open(id = nil)
|
31
20
|
Gl.open_in_browser("#{Gl.current_project}/issues/#{id}")
|
32
21
|
end
|
22
|
+
|
23
|
+
desc 'label', 'add a label to an issue'
|
24
|
+
def label(label)
|
25
|
+
label_action(label)
|
26
|
+
end
|
27
|
+
|
28
|
+
desc 'unlabel', 'remove a label from an issue'
|
29
|
+
def unlabel(label)
|
30
|
+
label_action(label)
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def label_action(label)
|
36
|
+
id = issue_dialogue
|
37
|
+
action = caller_locations(1, 1)[0].label
|
38
|
+
|
39
|
+
begin
|
40
|
+
Gitlab.create_issue_note(Gl.current_project,
|
41
|
+
id,
|
42
|
+
"/#{action} ~\"#{label}\"")
|
43
|
+
rescue Gitlab::Error::BadRequest
|
44
|
+
true
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def issue_dialogue(project = nil)
|
49
|
+
prompt = TTY::Prompt.new(interrupt: :exit)
|
50
|
+
prompt.select('Open a issue', filter: true) do |menu|
|
51
|
+
issues_list(project).each do |issue|
|
52
|
+
menu.choice issue.join(' - '), issue[0]
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def issues_list(project)
|
58
|
+
@issues_list ||= begin
|
59
|
+
issues = Gitlab.issues(Gl.current_project(project), state: :opened).auto_paginate
|
60
|
+
|
61
|
+
issues.map do |issue|
|
62
|
+
[issue.iid, issue.author.name, issue.title]
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
33
66
|
end
|
34
67
|
end
|
@@ -7,7 +7,32 @@ module Gl
|
|
7
7
|
def list(project = nil)
|
8
8
|
if options[:i]
|
9
9
|
id = merge_request_dialogue(project)
|
10
|
-
|
10
|
+
mr = merge_requests.select { |merge_request| merge_request.iid == id.to_i }.first
|
11
|
+
box = TTY::Box.frame(
|
12
|
+
width: TTY::Screen.width,
|
13
|
+
height: mr.description.lines.count + 4,
|
14
|
+
padding: 1,
|
15
|
+
title: { top_center: mr.title[0..TTY::Screen.width - 3],
|
16
|
+
bottom_left: "State: #{mr.state}",
|
17
|
+
bottom_right: "by #{mr.author.name}" }
|
18
|
+
) do
|
19
|
+
mr.description
|
20
|
+
end
|
21
|
+
puts box
|
22
|
+
|
23
|
+
choice = TTY::Prompt.new(interrupt: :exit).select('What to do next?') do |menu|
|
24
|
+
menu.choice :open
|
25
|
+
menu.choice :merge
|
26
|
+
menu.choice :approve
|
27
|
+
menu.choice :exit
|
28
|
+
end
|
29
|
+
|
30
|
+
case choice.to_sym
|
31
|
+
when :open then open_mr_in_browser(mr.iid)
|
32
|
+
when :merge then merge(mr.iid)
|
33
|
+
when :approve then approve(mr.iid)
|
34
|
+
when :exit then exit
|
35
|
+
end
|
11
36
|
else
|
12
37
|
table = TTY::Table.new(%w[IID Author Title],
|
13
38
|
merge_requests_list(project))
|
@@ -15,44 +40,94 @@ module Gl
|
|
15
40
|
end
|
16
41
|
end
|
17
42
|
|
43
|
+
desc 'approve', 'approves a merge request'
|
44
|
+
def approve(iid = nil)
|
45
|
+
iid ||= merge_request_dialogue
|
46
|
+
begin
|
47
|
+
Gitlab.approve_merge_request(Gl.current_project, iid)
|
48
|
+
rescue Gitlab::Error::Unauthorized
|
49
|
+
TTY::Prompt.new.error('Unable to approve merge request')
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
18
53
|
desc 'open', 'opens the merge request overview in your browser'
|
19
|
-
def open(
|
20
|
-
|
54
|
+
def open(iid = nil)
|
55
|
+
open_mr_in_browser(iid)
|
56
|
+
end
|
57
|
+
|
58
|
+
desc 'label', 'add a label to a merge request'
|
59
|
+
def label(label)
|
60
|
+
label_action(label)
|
61
|
+
end
|
62
|
+
|
63
|
+
desc 'unlabel', 'remove a label from a merge request'
|
64
|
+
def unlabel(label)
|
65
|
+
label_action(label)
|
21
66
|
end
|
22
67
|
|
23
|
-
desc '
|
24
|
-
|
25
|
-
|
68
|
+
desc 'merge', 'accept a merge request'
|
69
|
+
method_option 'delete-branch', type: :boolean, default: true, desc: 'Delete branch after merge'
|
70
|
+
method_option 'squash', type: :boolean, default: false, desc: 'Squash commits'
|
71
|
+
def merge(iid = nil)
|
72
|
+
iid ||= merge_request_dialogue.split(' - ')[0]
|
73
|
+
Gitlab.accept_merge_request(Gl.current_project,
|
74
|
+
iid,
|
75
|
+
squash: options['squash'],
|
76
|
+
should_remove_source_branch: options['delete-branch'])
|
77
|
+
rescue Gitlab::Error::MethodNotAllowed => e
|
78
|
+
TTY::Prompt.new.error(
|
79
|
+
case e.response_status
|
80
|
+
when 405
|
81
|
+
'Unable to accept merge request ' \
|
82
|
+
'(ie: Work in Progress, Closed, Pipeline Pending Completion, ' \
|
83
|
+
'or Failed while requiring Success)'
|
84
|
+
else
|
85
|
+
"Could not merge due to unknown error: #{e.response_status}"
|
86
|
+
end
|
87
|
+
)
|
88
|
+
end
|
89
|
+
|
90
|
+
private
|
91
|
+
|
92
|
+
def open_mr_in_browser(iid)
|
93
|
+
Gl.open_in_browser("#{Gl.current_project}/merge_requests/#{iid}")
|
94
|
+
end
|
95
|
+
|
96
|
+
def label_action(label)
|
97
|
+
id = merge_request_dialogue
|
98
|
+
action = caller_locations(1, 1)[0].label
|
26
99
|
|
27
100
|
begin
|
28
101
|
Gitlab.create_merge_request_note(Gl.current_project,
|
29
102
|
id,
|
30
|
-
|
103
|
+
"/#{action} ~\"#{label}\"")
|
31
104
|
rescue Gitlab::Error::BadRequest
|
32
105
|
true
|
33
106
|
end
|
34
107
|
end
|
35
108
|
|
36
|
-
private
|
37
|
-
|
38
109
|
def merge_request_dialogue(project = nil)
|
39
110
|
prompt = TTY::Prompt.new(interrupt: :exit)
|
40
|
-
prompt.select('Select a merge request') do |menu|
|
111
|
+
prompt.select('Select a merge request', filter: true) do |menu|
|
41
112
|
merge_requests_list(project).each do |merge_request|
|
42
113
|
menu.choice merge_request.join(' - '), merge_request[0]
|
43
114
|
end
|
44
115
|
end
|
45
116
|
end
|
46
117
|
|
47
|
-
def merge_requests_list(project)
|
118
|
+
def merge_requests_list(project = nil)
|
48
119
|
@merge_requests_list ||= begin
|
49
|
-
merge_requests
|
50
|
-
state: :opened).auto_paginate
|
51
|
-
|
52
|
-
merge_requests.map do |mr|
|
120
|
+
merge_requests(project).map do |mr|
|
53
121
|
[mr.iid, mr.author.name, mr.title]
|
54
122
|
end
|
55
123
|
end
|
56
124
|
end
|
125
|
+
|
126
|
+
def merge_requests(project = nil)
|
127
|
+
@merge_requests ||= begin
|
128
|
+
Gitlab.merge_requests(Gl.current_project(project),
|
129
|
+
state: :opened).auto_paginate
|
130
|
+
end
|
131
|
+
end
|
57
132
|
end
|
58
133
|
end
|
data/lib/gl/cli/registry.rb
CHANGED
data/lib/gl/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Flipez
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-08-
|
11
|
+
date: 2019-08-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gitlab
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 0.20.3
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: tty-box
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: tty-progressbar
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,6 +80,20 @@ dependencies:
|
|
66
80
|
- - "~>"
|
67
81
|
- !ruby/object:Gem::Version
|
68
82
|
version: 0.19.0
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: tty-screen
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
69
97
|
- !ruby/object:Gem::Dependency
|
70
98
|
name: tty-spinner
|
71
99
|
requirement: !ruby/object:Gem::Requirement
|