bitbar_gitlab 0.1.1 → 0.1.2
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 +4 -4
- data/README.md +22 -9
- data/exe/gitlab-bitbar-plugin.rb +8 -180
- data/lib/bitbar_gitlab/gitlab_bitbar_lib_config.rb +72 -0
- data/lib/bitbar_gitlab/gitlab_bitbar_lib_install.rb +89 -0
- data/lib/bitbar_gitlab/gitlab_bitbar_lib_main.rb +73 -0
- data/lib/bitbar_gitlab/gitlab_bitbar_lib_menu_utils.rb +18 -11
- data/lib/bitbar_gitlab/gitlab_bitbar_lib_notify.rb +5 -0
- data/lib/bitbar_gitlab/version.rb +1 -1
- data/lib/bitbar_gitlab.rb +4 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f5cef9525f39ce9bc6313fee1dd095756ae43c0
|
4
|
+
data.tar.gz: 9f55f2a1e70b237f2c8c80f011b917e8a2e572c8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 52a85779e7775d76528fea1e7fd27422b9dc4dc2b7bc42a2d332b869d1b84e6a417871f9985ed9c4f9eafd1349d87f05bb9d15a4f975a9a8d17b6549b5233574
|
7
|
+
data.tar.gz: a4d05b8736384036635562e88abb0131d05d0643f44445904b395bf14a1c82461f62a984052e636ae1a53a81ffe894905e16febe7c0382ae10f115f7270657bf
|
data/README.md
CHANGED
@@ -10,10 +10,17 @@ BitBar GitLab Plugin, giving access to issues and pipelines.
|
|
10
10
|
|
11
11
|
## Installation
|
12
12
|
|
13
|
+
If you have rvm make sure to first use the system ruby version, as BitBar is
|
14
|
+
using this ruby.
|
15
|
+
|
16
|
+
```
|
17
|
+
rvm use system
|
18
|
+
```
|
19
|
+
|
13
20
|
First install gem globally.
|
14
21
|
|
15
22
|
```
|
16
|
-
sudo gem install
|
23
|
+
sudo gem install bitbar_gitlab
|
17
24
|
```
|
18
25
|
|
19
26
|
Then run:
|
@@ -28,22 +35,28 @@ When finished without problems start BitBar or refresh plugins.
|
|
28
35
|
|
29
36
|
The menu's should be self explaining
|
30
37
|
|
38
|
+
## macOS notifications for GitLab CI jobs
|
31
39
|
|
40
|
+
If you like to have macOS notifications you must install terminal-notifier with brew.
|
32
41
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
42
|
+
```
|
43
|
+
brew install terminal-notifier
|
44
|
+
```
|
38
45
|
|
39
46
|
## Contributing
|
40
47
|
|
41
|
-
Bug reports and pull requests are welcome on GitHub at
|
48
|
+
Bug reports and pull requests are welcome on GitHub at
|
49
|
+
https://github.com/mipmip/bitbar_gitlab. This project is intended to be a safe,
|
50
|
+
welcoming space for collaboration, and contributors are expected to adhere to
|
51
|
+
the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
42
52
|
|
43
53
|
## License
|
44
54
|
|
45
|
-
The gem is available as open source under the terms of the [MIT
|
55
|
+
The gem is available as open source under the terms of the [MIT
|
56
|
+
License](https://opensource.org/licenses/MIT).
|
46
57
|
|
47
58
|
## Code of Conduct
|
48
59
|
|
49
|
-
Everyone interacting in the Bitbar::Gitlab project’s codebases, issue trackers,
|
60
|
+
Everyone interacting in the Bitbar::Gitlab project’s codebases, issue trackers,
|
61
|
+
chat rooms and mailing lists is expected to follow the [code of
|
62
|
+
conduct](https://github.com/[USERNAME]/bitbar-gitlab/blob/master/CODE_OF_CONDUCT.md).
|
data/exe/gitlab-bitbar-plugin.rb
CHANGED
@@ -2,195 +2,23 @@
|
|
2
2
|
|
3
3
|
require "bundler/setup"
|
4
4
|
require "bitbar_gitlab"
|
5
|
-
|
6
5
|
require 'yaml'
|
7
6
|
require 'gitlab'
|
8
7
|
|
9
|
-
|
10
|
-
puts "GitLab"
|
11
|
-
puts "---"
|
12
|
-
|
13
|
-
puts "Refresh | refresh=true"
|
14
|
-
|
15
|
-
if CONFIG['PROJECT_FOCUS'] and CONFIG['PROJECT_FOCUS']!=0
|
16
|
-
puts "---"
|
17
|
-
|
18
|
-
focus_project = $gitlab.project(CONFIG['PROJECT_FOCUS'])
|
19
|
-
|
20
|
-
puts "PROJECT: #{focus_project.to_hash['name']} | href=#{focus_project.to_hash['web_url']}"
|
21
|
-
puts "Issues"
|
22
|
-
project_menu focus_project, 1, true
|
23
|
-
puts "---"
|
24
|
-
end
|
25
|
-
|
26
|
-
if CONFIG['PIPELINE_FOCUS'] and CONFIG['PIPELINE_FOCUS']!=0
|
27
|
-
puts "---"
|
28
|
-
|
29
|
-
focus_pipeline = $gitlab.project(CONFIG['PIPELINE_FOCUS'])
|
30
|
-
|
31
|
-
puts "PIPELINE: #{focus_project.to_hash['name']} | href=#{focus_project.to_hash['web_url']}"
|
32
|
-
pipeline_focus_menu focus_pipeline, 0
|
33
|
-
|
34
|
-
puts "---"
|
35
|
-
end
|
36
|
-
|
37
|
-
|
38
|
-
if toggle_on? 'show_starred_projects'
|
39
|
-
puts "Starred Projects"
|
40
|
-
|
41
|
-
$gitlab.projects(per_page: 9999, starred: 1).collect do |pr|
|
42
|
-
puts "#{indent 1}" + pr.to_hash['id'].to_s + ' ' + pr.to_hash['name']
|
43
|
-
project_menu pr, 2
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
if toggle_on? 'show_all_projects'
|
48
|
-
puts "All Projects"
|
49
|
-
|
50
|
-
$gitlab.projects(per_page: 9999).collect do |pr|
|
51
|
-
puts "#{indent 1}" + pr.to_hash['id'].to_s + ' ' + pr.to_hash['name']
|
52
|
-
project_menu pr, 2
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
if toggle_on? 'show_starred_pipelines'
|
57
|
-
puts "Starred Pipelines"
|
58
|
-
$gitlab.projects(per_page: 9999, starred: 1).collect do |pr|
|
59
|
-
puts "#{indent 1}" + pr.to_hash['id'].to_s + ' ' + pr.to_hash['name']
|
60
|
-
pipeline_menu pr, 2
|
61
|
-
end
|
62
|
-
end
|
63
|
-
if toggle_on? 'show_all_pipelines'
|
64
|
-
puts "All Pipelines"
|
65
|
-
$gitlab.projects(per_page: 9999).collect do |pr|
|
66
|
-
puts "#{indent 1}" + pr.to_hash['id'].to_s + ' ' + pr.to_hash['name']
|
67
|
-
pipeline_menu pr, 2
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
puts "---"
|
72
|
-
puts "Toggles"
|
73
|
-
toggle_line 1, 'show_starred_projects', "Show starred projects", "Hide starred projects"
|
74
|
-
toggle_line 1, 'show_all_projects', "Show all projects", "Hide all projects"
|
75
|
-
puts "#{indent 1}Clear issue focus | bash=#{shellwrap} param1=set param2=pipeline_focus param3=0 terminal=false refresh=true"
|
76
|
-
puts "#{indent 1}---"
|
77
|
-
toggle_line 1, 'show_starred_pipelines', "Show starred pipelines", "Hide starred pipelines"
|
78
|
-
toggle_line 1, 'show_all_pipelines', "Show all pipelines", "Hide all pipelines"
|
79
|
-
puts "#{indent 1}Clear pipeline focus | bash=#{shellwrap} param1=set param2=pipeline_focus param3=0 terminal=false refresh=true"
|
80
|
-
end
|
81
|
-
|
82
|
-
def install_test_gitlab_connection
|
83
|
-
puts "Testing GitLab connection"
|
84
|
-
|
85
|
-
$gitlab = Gitlab.client(endpoint: CONFIG['ENDPOINT'], private_token: CONFIG['TOKEN'])
|
86
|
-
|
87
|
-
begin
|
88
|
-
user = $gitlab.user
|
89
|
-
puts "User connected to this token: " + user.to_hash['name'] + "\n"
|
90
|
-
puts
|
91
|
-
|
92
|
-
|
93
|
-
puts "The configuration seems correct. you can now try using BitBar"
|
94
|
-
|
95
|
-
rescue
|
96
|
-
puts "ERROR Could not connect to the Gitlab API"
|
97
|
-
puts
|
98
|
-
puts "You may want to delete the configuration file and try to reconfigure"
|
99
|
-
puts
|
100
|
-
print "Shall I delete it for you? "
|
101
|
-
delete_conf = STDIN.gets.chomp.upcase
|
102
|
-
if delete_conf == "YES" or delete_conf == "Y"
|
103
|
-
File.delete CONFIG_FILE
|
104
|
-
puts "Deleted conf file. You can run this install again"
|
105
|
-
end
|
106
|
-
puts
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
def install_bitbar_symlinks
|
111
|
-
puts "Installing Symlinks to BitBar plugin folder"
|
112
|
-
if File.exists? File.expand_path(CONFIG['PLUGIN_FOLDER'])+'/gitlab-bitbar-plugin.rb'
|
113
|
-
File.delete File.expand_path(CONFIG['PLUGIN_FOLDER'])+'/gitlab-bitbar-plugin.rb'
|
114
|
-
end
|
115
|
-
File.symlink(File.expand_path(__FILE__), File.expand_path(CONFIG['PLUGIN_FOLDER'])+'/gitlab-bitbar-plugin.rb')
|
116
|
-
end
|
117
|
-
|
118
|
-
CONFIG_FILE =File.expand_path('~/.bitbar_gitlab_cnf.yml')
|
8
|
+
$conf = GitlabBitbarLibConfig.new __FILE__
|
119
9
|
|
120
10
|
if ARGV[0]=='install'
|
121
|
-
puts "Installing BitBar Gitlab Plugin by Pim Snel"
|
122
11
|
|
123
|
-
|
124
|
-
puts "you seem to have a configations file."
|
125
|
-
puts
|
126
|
-
else
|
127
|
-
|
128
|
-
newconf = {}
|
129
|
-
puts "Creating a minimal configuration file..."
|
130
|
-
puts
|
131
|
-
puts "Enter the URL to your GitLab Environment"
|
132
|
-
puts "E.g. https://gitlab.yourcompany.net (no ending slash)"
|
133
|
-
puts
|
134
|
-
print "Api URL: "
|
135
|
-
api_address = STDIN.gets.chomp
|
136
|
-
newconf['ENDPOINT'] = api_address + "/api/v4"
|
137
|
-
|
138
|
-
puts
|
139
|
-
puts "Enter a GitLab Access token for your GitLab Environment"
|
140
|
-
puts "Create them at #{api_address}/profile/personal_access_tokens"
|
141
|
-
puts
|
142
|
-
print "Access Token: "
|
143
|
-
newconf['TOKEN'] = STDIN.gets.chomp
|
144
|
-
|
145
|
-
## Check BitBar plugin folder
|
146
|
-
plugin_folder = `defaults read com.matryer.BitBar | grep pluginsDirectory | cut -d '"' -f2`.strip
|
147
|
-
if File.exists? File.expand_path(plugin_folder)
|
148
|
-
puts "I found this BitBar plugin folder: " + plugin_folder + "\n"
|
149
|
-
newconf['PLUGIN_FOLDER'] = plugin_folder
|
150
|
-
else
|
151
|
-
puts "Could not find the BitBar plugin folder."
|
152
|
-
print "Please enter the plugin path: "
|
153
|
-
newconf['PLUGIN_FOLDER'] = STDIN.gets.chomp
|
154
|
-
end
|
155
|
-
|
156
|
-
newconf['EXE_UTIL_DIR'] = File.dirname(File.expand_path(__FILE__))
|
157
|
-
|
158
|
-
puts
|
159
|
-
puts "writing configuration file..."
|
160
|
-
puts
|
161
|
-
File.open(CONFIG_FILE, 'w') { |file| file.write(newconf.to_yaml) }
|
162
|
-
end
|
163
|
-
|
164
|
-
CONFIG = YAML.load_file(CONFIG_FILE)
|
12
|
+
run_install
|
165
13
|
install_test_gitlab_connection
|
166
14
|
install_bitbar_symlinks
|
167
15
|
|
16
|
+
elsif ARGV[0]=='set'
|
17
|
+
$conf.set_key ARGV[1].to_sym, ARGV[2].to_i
|
168
18
|
else
|
169
|
-
if File.exists? CONFIG_FILE
|
170
|
-
|
171
|
-
CONFIG = YAML.load_file(CONFIG_FILE)
|
172
|
-
|
173
|
-
if ARGV[0]=='set'
|
174
|
-
if ARGV[1] == 'project_focus' && ARGV[2]
|
175
|
-
CONFIG['PROJECT_FOCUS']= ARGV[2].to_i
|
176
|
-
File.open(CONFIG_FILE, 'w') { |file| file.write(CONFIG.to_yaml) }
|
177
|
-
elsif ARGV[1].include?('TOGGLE_') && ARGV[2]
|
178
|
-
CONFIG[ARGV[1]]= ARGV[2].to_i
|
179
|
-
File.open(CONFIG_FILE, 'w') { |file| file.write(CONFIG.to_yaml) }
|
180
|
-
else
|
181
|
-
CONFIG[ARGV[1].upcase]= ARGV[2].to_i
|
182
|
-
File.open(CONFIG_FILE, 'w') { |file| file.write(CONFIG.to_yaml) }
|
183
|
-
end
|
184
|
-
|
185
|
-
else
|
186
|
-
$gitlab = Gitlab.client(endpoint: CONFIG['ENDPOINT'], private_token: CONFIG['TOKEN'])
|
187
|
-
run
|
188
|
-
end
|
189
19
|
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
puts "You might want to run 'gitlab-bitbar-plugin.rb install'"
|
195
|
-
end
|
20
|
+
$conf.missing_warning unless $conf.exists?
|
21
|
+
$gitlab = Gitlab.client(endpoint: $conf.get_key(:endpoint), private_token: $conf.get_key(:token))
|
22
|
+
$conf.try_exe_dir_exists
|
23
|
+
run_main
|
196
24
|
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
class GitlabBitbarLibConfig
|
2
|
+
|
3
|
+
attr_reader :exe_file
|
4
|
+
attr_reader :exe_dir
|
5
|
+
|
6
|
+
def initialize launch_file
|
7
|
+
@exe_dir = File.dirname(File.expand_path(launch_file))
|
8
|
+
@exe_file = File.expand_path(launch_file)
|
9
|
+
@config_file= File.expand_path('~/.bitbar_gitlab_cnf.yml')
|
10
|
+
load_config if exists?
|
11
|
+
end
|
12
|
+
|
13
|
+
def save_init init_conf
|
14
|
+
File.open(@config_file, 'w') { |file| file.write(init_conf.to_yaml) }
|
15
|
+
end
|
16
|
+
|
17
|
+
def exists?
|
18
|
+
true if File.exists? @config_file
|
19
|
+
end
|
20
|
+
|
21
|
+
def delete
|
22
|
+
File.delete @config_file
|
23
|
+
end
|
24
|
+
|
25
|
+
def load_config
|
26
|
+
@config = YAML.load_file(@config_file)
|
27
|
+
end
|
28
|
+
|
29
|
+
def save_config
|
30
|
+
File.open(@config_file, 'w') do |f|
|
31
|
+
f.write(@config.to_yaml)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def get_key sym
|
36
|
+
@config[sym.to_s.upcase] if @config.key?(sym.to_s.upcase)
|
37
|
+
end
|
38
|
+
|
39
|
+
def set_key sym, val
|
40
|
+
@config[sym.to_s.upcase] = val
|
41
|
+
save_config
|
42
|
+
end
|
43
|
+
|
44
|
+
def toggle_on? key
|
45
|
+
if @config['TOGGLE_'+key.to_s.upcase] and @config['TOGGLE_'+key.to_s.upcase] !=0
|
46
|
+
true
|
47
|
+
else
|
48
|
+
false
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def key_is_set key
|
53
|
+
if get_key(key) and get_key(key) != 0
|
54
|
+
true
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def missing_warning
|
59
|
+
puts "WARNING, could not execute BITBAR_GITLAB"
|
60
|
+
puts
|
61
|
+
puts "make sure '~/.bitbar_gitlab_cnf.yml' exists."
|
62
|
+
puts "You might want to run 'gitlab-bitbar-plugin.rb install'"
|
63
|
+
end
|
64
|
+
|
65
|
+
def try_exe_dir_exists
|
66
|
+
unless get_key :exe_util_dir
|
67
|
+
set_key :exe_util_dir, @exe_dir
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
|
72
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
def run_install
|
2
|
+
|
3
|
+
puts "Installing BitBar Gitlab Plugin by Pim Snel"
|
4
|
+
|
5
|
+
if $conf.exists?
|
6
|
+
$conf.try_exe_dir_exists
|
7
|
+
puts "you seem to have a configations file."
|
8
|
+
puts
|
9
|
+
else
|
10
|
+
|
11
|
+
newconf = {}
|
12
|
+
puts "Creating a minimal configuration file..."
|
13
|
+
puts
|
14
|
+
puts "Enter the URL to your GitLab Environment"
|
15
|
+
puts "E.g. https://gitlab.yourcompany.net (no ending slash)"
|
16
|
+
puts
|
17
|
+
print "Api URL: "
|
18
|
+
api_address = STDIN.gets.chomp
|
19
|
+
newconf['ENDPOINT'] = api_address + "/api/v4"
|
20
|
+
|
21
|
+
puts
|
22
|
+
puts "Enter a GitLab Access token for your GitLab Environment"
|
23
|
+
puts "Create them at #{api_address}/profile/personal_access_tokens"
|
24
|
+
puts
|
25
|
+
print "Access Token: "
|
26
|
+
newconf['TOKEN'] = STDIN.gets.chomp
|
27
|
+
|
28
|
+
## Check BitBar plugin folder
|
29
|
+
plugin_folder = `defaults read com.matryer.BitBar | grep pluginsDirectory | cut -d '"' -f2`.strip
|
30
|
+
if File.exists? File.expand_path(plugin_folder)
|
31
|
+
puts "I found this BitBar plugin folder: " + plugin_folder + "\n"
|
32
|
+
newconf['PLUGIN_FOLDER'] = plugin_folder
|
33
|
+
else
|
34
|
+
puts "Could not find the BitBar plugin folder."
|
35
|
+
print "Please enter the plugin path: "
|
36
|
+
newconf['PLUGIN_FOLDER'] = STDIN.gets.chomp
|
37
|
+
end
|
38
|
+
|
39
|
+
newconf['EXE_UTIL_DIR'] = $conf.exe_dir
|
40
|
+
|
41
|
+
puts
|
42
|
+
puts "writing configuration file..."
|
43
|
+
puts
|
44
|
+
$conf.save_init newconf
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
def install_bitbar_symlinks
|
50
|
+
puts "Installing Symlinks to BitBar plugin folder"
|
51
|
+
unless $conf.get_key :plugin_folder
|
52
|
+
plugin_folder = `defaults read com.matryer.BitBar | grep pluginsDirectory | cut -d '"' -f2`.strip
|
53
|
+
$conf.set_key :plugin_folder, plugin_folder
|
54
|
+
end
|
55
|
+
|
56
|
+
if File.exists? File.expand_path($conf.get_key :plugin_folder)+'/gitlab-bitbar-plugin.rb'
|
57
|
+
File.delete File.expand_path($conf.get_key :plugin_folder)+'/gitlab-bitbar-plugin.rb'
|
58
|
+
end
|
59
|
+
File.symlink($conf.exe_file, File.expand_path($conf.get_key :plugin_folder)+'/gitlab-bitbar-plugin.rb')
|
60
|
+
end
|
61
|
+
|
62
|
+
def install_test_gitlab_connection
|
63
|
+
puts "Testing GitLab connection"
|
64
|
+
|
65
|
+
$gitlab = Gitlab.client(endpoint: $conf.get_key(:endpoint), private_token: $conf.get_key(:token))
|
66
|
+
|
67
|
+
begin
|
68
|
+
user = $gitlab.user
|
69
|
+
puts "User connected to this token: " + user.to_hash['name'] + "\n"
|
70
|
+
puts
|
71
|
+
|
72
|
+
|
73
|
+
puts "The configuration seems correct. you can now try using BitBar"
|
74
|
+
|
75
|
+
rescue
|
76
|
+
puts "ERROR Could not connect to the Gitlab API"
|
77
|
+
puts
|
78
|
+
puts "You may want to delete the configuration file and try to reconfigure"
|
79
|
+
puts
|
80
|
+
print "Shall I delete it for you? "
|
81
|
+
delete_conf = STDIN.gets.chomp.upcase
|
82
|
+
if delete_conf == "YES" or delete_conf == "Y"
|
83
|
+
$conf.delete
|
84
|
+
puts "Deleted conf file. You can run this install again"
|
85
|
+
end
|
86
|
+
puts
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
@@ -0,0 +1,73 @@
|
|
1
|
+
def run_main
|
2
|
+
|
3
|
+
puts "GitLab"
|
4
|
+
puts "---"
|
5
|
+
|
6
|
+
puts "Refresh | refresh=true"
|
7
|
+
|
8
|
+
if $conf.key_is_set :project_focus
|
9
|
+
puts "---"
|
10
|
+
|
11
|
+
focus_project = $gitlab.project($conf.get_key :project_focus)
|
12
|
+
|
13
|
+
puts "PROJECT: #{focus_project.to_hash['name']} | href=#{focus_project.to_hash['web_url']}"
|
14
|
+
puts "Issues"
|
15
|
+
project_menu focus_project, 1, true
|
16
|
+
puts "---"
|
17
|
+
end
|
18
|
+
|
19
|
+
if $conf.key_is_set :pipeline_focus
|
20
|
+
puts "---"
|
21
|
+
|
22
|
+
focus_pipeline = $gitlab.project($conf.get_key :pipeline_focus)
|
23
|
+
|
24
|
+
puts "PIPELINE: #{focus_pipeline.to_hash['name']} | href=#{focus_pipeline.to_hash['web_url']}"
|
25
|
+
pipeline_focus_menu focus_pipeline, 0
|
26
|
+
|
27
|
+
puts "---"
|
28
|
+
end
|
29
|
+
|
30
|
+
if $conf.toggle_on? 'show_starred_projects'
|
31
|
+
puts "Starred Projects"
|
32
|
+
|
33
|
+
$gitlab.projects(per_page: 9999, starred: 1).collect do |pr|
|
34
|
+
puts "#{indent 1}" + pr.to_hash['id'].to_s + ' ' + pr.to_hash['name']
|
35
|
+
project_menu pr, 2
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
if $conf.toggle_on? 'show_all_projects'
|
40
|
+
puts "All Projects"
|
41
|
+
|
42
|
+
$gitlab.projects(per_page: 9999).collect do |pr|
|
43
|
+
puts "#{indent 1}" + pr.to_hash['id'].to_s + ' ' + pr.to_hash['name']
|
44
|
+
project_menu pr, 2
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
if $conf.toggle_on? 'show_starred_pipelines'
|
49
|
+
puts "Starred Pipelines"
|
50
|
+
$gitlab.projects(per_page: 9999, starred: 1).collect do |pr|
|
51
|
+
puts "#{indent 1}" + pr.to_hash['id'].to_s + ' ' + pr.to_hash['name']
|
52
|
+
pipeline_menu pr, 2
|
53
|
+
end
|
54
|
+
end
|
55
|
+
if $conf.toggle_on? 'show_all_pipelines'
|
56
|
+
puts "All Pipelines"
|
57
|
+
$gitlab.projects(per_page: 9999).collect do |pr|
|
58
|
+
puts "#{indent 1}" + pr.to_hash['id'].to_s + ' ' + pr.to_hash['name']
|
59
|
+
pipeline_menu pr, 2
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
puts "---"
|
64
|
+
puts "Toggles"
|
65
|
+
toggle_line 1, 'show_starred_projects', "Show starred projects", "Hide starred projects"
|
66
|
+
toggle_line 1, 'show_all_projects', "Show all projects", "Hide all projects"
|
67
|
+
puts "#{indent 1}Clear issue focus | bash=#{shellwrap} param1=set param2=pipeline_focus param3=0 terminal=false refresh=true"
|
68
|
+
puts "#{indent 1}---"
|
69
|
+
toggle_line 1, 'show_starred_pipelines', "Show starred pipelines", "Hide starred pipelines"
|
70
|
+
toggle_line 1, 'show_all_pipelines', "Show all pipelines", "Hide all pipelines"
|
71
|
+
puts "#{indent 1}Clear pipeline focus | bash=#{shellwrap} param1=set param2=pipeline_focus param3=0 terminal=false refresh=true"
|
72
|
+
end
|
73
|
+
|
@@ -1,5 +1,5 @@
|
|
1
1
|
def shellwrap
|
2
|
-
"#{
|
2
|
+
"#{$conf.get_key :exe_util_dir}/shellwrap.sh"
|
3
3
|
end
|
4
4
|
|
5
5
|
def project_menu pr, level, in_focus = false
|
@@ -45,7 +45,7 @@ end
|
|
45
45
|
def pipeline_focus_menu pr, level, in_focus = false
|
46
46
|
|
47
47
|
data = []
|
48
|
-
labels = ['id',
|
48
|
+
labels = ['id','status','web_url']
|
49
49
|
$gitlab.pipelines(pr.to_hash['id'].to_s,{per_page:3, page:1, state: 'running'}).collect do |iss|
|
50
50
|
|
51
51
|
d = []
|
@@ -59,6 +59,20 @@ def pipeline_focus_menu pr, level, in_focus = false
|
|
59
59
|
i=0
|
60
60
|
|
61
61
|
data.each do |d|
|
62
|
+
if i == 0
|
63
|
+
if $conf.get_key(:last_job_id) == d[0] and $conf.get_key(:last_job_status) != d[1]
|
64
|
+
if d[1] == 'success'
|
65
|
+
notify "-title 'GitLab Pipeline Passed' -message '#{d[0]} passed' -open '#{d[2]}'"
|
66
|
+
elsif d[1] == 'failed'
|
67
|
+
notify "-title 'GitLab Pipeline Failed' -message '#{d[0]} failed' -open '#{d[2]}'"
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
$conf.set_key :last_job_id, d[0]
|
72
|
+
$conf.set_key :last_job_status, d[1]
|
73
|
+
|
74
|
+
end
|
75
|
+
|
62
76
|
i+=1
|
63
77
|
|
64
78
|
puts "#{indent level}#{d[0]} #{d[1]} | href=#{d[2]}"
|
@@ -113,17 +127,10 @@ def indent i
|
|
113
127
|
scores
|
114
128
|
end
|
115
129
|
|
116
|
-
def toggle_on? key
|
117
|
-
if CONFIG['TOGGLE_'+key.upcase] and CONFIG['TOGGLE_'+key.upcase] !=0
|
118
|
-
true
|
119
|
-
else
|
120
|
-
false
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
130
|
def toggle_line level, key, on_text, off_text
|
125
131
|
|
126
|
-
if
|
132
|
+
if $conf.toggle_on? key
|
133
|
+
#if CONFIG['TOGGLE_'+key.upcase] && CONFIG['TOGGLE_'+key.upcase]!=0
|
127
134
|
text=off_text
|
128
135
|
status=0
|
129
136
|
else
|
data/lib/bitbar_gitlab.rb
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
require "bitbar_gitlab/version"
|
2
|
+
require 'bitbar_gitlab/gitlab_bitbar_lib_config.rb'
|
3
|
+
require 'bitbar_gitlab/gitlab_bitbar_lib_install.rb'
|
4
|
+
require 'bitbar_gitlab/gitlab_bitbar_lib_main.rb'
|
2
5
|
require 'bitbar_gitlab/gitlab_bitbar_lib_menu_utils.rb'
|
6
|
+
require 'bitbar_gitlab/gitlab_bitbar_lib_notify.rb'
|
3
7
|
|
4
8
|
module BitbarGitlab
|
5
9
|
class Error < StandardError; end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bitbar_gitlab
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pim Snel
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-02-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -89,7 +89,11 @@ files:
|
|
89
89
|
- exe/gitlab-bitbar-plugin.rb
|
90
90
|
- exe/shellwrap.sh
|
91
91
|
- lib/bitbar_gitlab.rb
|
92
|
+
- lib/bitbar_gitlab/gitlab_bitbar_lib_config.rb
|
93
|
+
- lib/bitbar_gitlab/gitlab_bitbar_lib_install.rb
|
94
|
+
- lib/bitbar_gitlab/gitlab_bitbar_lib_main.rb
|
92
95
|
- lib/bitbar_gitlab/gitlab_bitbar_lib_menu_utils.rb
|
96
|
+
- lib/bitbar_gitlab/gitlab_bitbar_lib_notify.rb
|
93
97
|
- lib/bitbar_gitlab/version.rb
|
94
98
|
homepage: https://github.com/mipmip/bitbar_gitlab
|
95
99
|
licenses:
|