gitlab-fogbugz 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/HISTORY.md +12 -0
- data/README.markdown +1 -0
- data/Rakefile +2 -2
- data/TODO +5 -2
- data/bin/gitlab-fogbugz-server +113 -108
- data/test/fogbugz_listener_test.rb +1 -1
- data/test/message_parser_test.rb +1 -1
- metadata +3 -2
data/HISTORY.md
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# 0.0.3 / 2012-07-15
|
2
|
+
* Make gitlab-fogbugz-server actually work when installed as gem
|
3
|
+
* Fix tests in Ruby 1.9.2 (did work in 1.8 and 1.9.3)
|
4
|
+
|
5
|
+
# 0.0.2 / 2012-07-12
|
6
|
+
* Switched from curl to programmatically use the FogBugz API via ruby-fogbugz
|
7
|
+
The initial reason to use curl were Ruby 1.8 SSL issues; just hope they've
|
8
|
+
been fixed in the last four years.
|
9
|
+
|
10
|
+
# 0.0.1 / 2012-07-12
|
11
|
+
* Forked from github-fogbugz
|
12
|
+
* First adaption to work with GitLiab
|
data/README.markdown
CHANGED
data/Rakefile
CHANGED
@@ -4,7 +4,7 @@ require "rake/testtask"
|
|
4
4
|
require "rake/gempackagetask"
|
5
5
|
|
6
6
|
GEM = "gitlab-fogbugz"
|
7
|
-
VERSION = "0.0.
|
7
|
+
VERSION = "0.0.3"
|
8
8
|
AUTHOR = ["John Reilly", "François Beausoleil", "Markus Fischer"]
|
9
9
|
EMAIL = ["jr@trms.com", "francois@teksol.info", "markus@fischer.name"]
|
10
10
|
HOMEPAGE = "http://github.com/mfn/gitlab-fogbugz"
|
@@ -32,7 +32,7 @@ spec = Gem::Specification.new do |s|
|
|
32
32
|
s.require_path = "lib"
|
33
33
|
|
34
34
|
# Must reference lib/message_parser.rb explicitely, or it won't be automatically generated
|
35
|
-
s.files = %w(LICENSE README.markdown Rakefile TODO lib/message_parser.rb) + Dir.glob("{lib,test,config,samples,bin}/**/*")
|
35
|
+
s.files = %w(HISTORY.md LICENSE README.markdown Rakefile TODO lib/message_parser.rb) + Dir.glob("{lib,test,config,samples,bin}/**/*")
|
36
36
|
end
|
37
37
|
|
38
38
|
Rake::GemPackageTask.new(spec) do |pkg|
|
data/TODO
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
-
TODO:
|
2
|
-
|
1
|
+
# TODO:
|
2
|
+
* Implement FogBugz checkins once GitLab provides this feature
|
3
3
|
(see https://github.com/gitlabhq/gitlabhq/issues/747 )
|
4
|
+
* After switching to Sinatra::Base, automagically --help and e.g. setting port
|
5
|
+
from sinatra isn't available anymore. Provide some alternative or do in a
|
6
|
+
smarter way.
|
data/bin/gitlab-fogbugz-server
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# vim: filetype=ruby:
|
2
3
|
require 'rubygems'
|
3
4
|
require 'json'
|
4
|
-
require 'sinatra'
|
5
|
+
require 'sinatra/base'
|
5
6
|
require 'yaml'
|
6
7
|
require 'cgi'
|
7
8
|
require 'fileutils'
|
@@ -60,128 +61,130 @@ end
|
|
60
61
|
# about all of your developers. Each dev must
|
61
62
|
# authenticate once with this app, then the token
|
62
63
|
# is kept on the filesystem.
|
64
|
+
class GitlabFogbugzServer < Sinatra::Base
|
63
65
|
|
64
|
-
##
|
65
|
-
# GitLab should send its post-receive hook here.
|
66
|
-
post '/' do
|
67
|
-
|
68
|
-
|
69
|
-
end
|
66
|
+
##
|
67
|
+
# GitLab should send its post-receive hook here.
|
68
|
+
post '/' do
|
69
|
+
request.body.rewind
|
70
|
+
GitlabFogbugz.new(request.body.read)
|
71
|
+
end
|
70
72
|
|
71
|
-
AUTH_FORM = lambda {|fb_url, params|
|
72
|
-
|
73
|
-
<h1>FogBugz Authentication</h1>
|
74
|
-
<p>This form will authenticate you to <strong>#{fb_url}</strong></p>
|
75
|
-
<form method="post" action="/authenticate">
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
</form>
|
82
|
-
EOHTML
|
83
|
-
}
|
73
|
+
AUTH_FORM = lambda {|fb_url, params|
|
74
|
+
<<-EOHTML
|
75
|
+
<h1>FogBugz Authentication</h1>
|
76
|
+
<p>This form will authenticate you to <strong>#{fb_url}</strong></p>
|
77
|
+
<form method="post" action="/authenticate">
|
78
|
+
<p><label for="email">Email:</label><br/>
|
79
|
+
<input name="email" size="40" value="#{params['email']}"/></p>
|
80
|
+
<p><label for="password">Password:</label><br/>
|
81
|
+
<input type="password" name="password" size="20"/></p>
|
82
|
+
<p><input type="submit" value="Authenticate to FogBugz"/></p>
|
83
|
+
</form>
|
84
|
+
EOHTML
|
85
|
+
}
|
84
86
|
|
85
|
-
get "/login" do
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
87
|
+
get "/login" do
|
88
|
+
if fb_main_url = config['fb_main_url'] then
|
89
|
+
AUTH_FORM.call(fb_main_url, Hash.new)
|
90
|
+
else
|
91
|
+
"<h1>A configuration error exists</h1><p>Ooops, the configuration file does not exist at path: <strong><tt>#{config_path}</tt></strong>.</p>"
|
92
|
+
end
|
90
93
|
end
|
91
|
-
end
|
92
94
|
|
93
|
-
post "/authenticate" do
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
95
|
+
post "/authenticate" do
|
96
|
+
begin
|
97
|
+
api = Fogbugz::Interface.new(:email => params["email"], :password => params["password"], :uri => config["fb_main_url"])
|
98
|
+
tokens[ params["email"] ] = api.authenticate
|
99
|
+
write_tokens
|
100
|
+
redirect "/authenticated"
|
101
|
+
rescue Fogbugz::AuthenticationException
|
102
|
+
"<p>Failed authentication: <strong>#{$!.message}</strong></p>" + AUTH_FORM.call(config['fb_main_url'], params)
|
103
|
+
end
|
101
104
|
end
|
102
|
-
end
|
103
|
-
|
104
|
-
get "/authenticated" do
|
105
|
-
<<-HTML
|
106
|
-
<h1>Authenticated</h1>
|
107
|
-
<p>You are now authenticated to FogBugz. Go forth and commit!</p>
|
108
|
-
|
109
|
-
<h2>Writing commit messages</h2>
|
110
|
-
<p>Your commit messages can now contain text like the following to automatically manage your cases:</p>
|
111
|
-
<blockquote>
|
112
|
-
<p>Implemented foo, corrected baz.</p>
|
113
|
-
<p>Implements #1234, references #2345. Closes #1234.</p>
|
114
|
-
</blockquote>
|
115
|
-
<p>This would automatically add the commit message to cases #1234 <em>and</em> #2345. The commit message will be appended as an event to the case. In addition, case #1234 will be closed.</p>
|
116
|
-
<p>You can also mention multiple cases with one keyword, e.g. <tt>Implements #1234 and #5123</tt>.</p>
|
117
|
-
<p>GitlabFogbugz recognizes the following keywords (also singular versions of the same keywords):</p>
|
118
|
-
<ul>
|
119
|
-
<li><tt>bugzid:</tt><br>For "compatibility" with the subversion wrapper provided by Fogcreek; however you still need to prefix the case number with <tt>#</tt>. Works like <tt>references</tt>.</li>
|
120
|
-
<li><tt>closes</tt></li>
|
121
|
-
<li><tt>completes</tt></li>
|
122
|
-
<li><tt>fixes</tt></li>
|
123
|
-
<li><tt>implements</tt></li>
|
124
|
-
<li><tt>reopens</tt></li>
|
125
|
-
<li><tt>references</tt> or <tt>refs</tt><br>Does not change the state of the case, just adds the commit message to this case.</li>
|
126
|
-
<li><tt>resolves</tt><br>Resolves is different then <tt>closes</tt>, <tt>completes</tt>, <tt>fixes</tt> and <tt>implements</tt>: it does not explicitly sets the FogBugz case status, thus changes the case to it's categories default status for resolved cases: Bug -> "fixed", Feature -> "Implemented", Inquiry -> "Responded" and Schedule Item -> "Completed"</li>
|
127
|
-
</ul>
|
128
|
-
<p>NOTE: FogBugz does not allow closing a case that isn't resolved, so you really must use "Implements X, closes X", or else it won't work.</p>
|
129
|
-
<p>Back to <a href="/tokens">Authenticated users</a></p>
|
130
|
-
HTML
|
131
|
-
end
|
132
105
|
|
133
|
-
get "/
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
106
|
+
get "/authenticated" do
|
107
|
+
<<-HTML
|
108
|
+
<h1>Authenticated</h1>
|
109
|
+
<p>You are now authenticated to FogBugz. Go forth and commit!</p>
|
110
|
+
|
111
|
+
<h2>Writing commit messages</h2>
|
112
|
+
<p>Your commit messages can now contain text like the following to automatically manage your cases:</p>
|
113
|
+
<blockquote>
|
114
|
+
<p>Implemented foo, corrected baz.</p>
|
115
|
+
<p>Implements #1234, references #2345. Closes #1234.</p>
|
116
|
+
</blockquote>
|
117
|
+
<p>This would automatically add the commit message to cases #1234 <em>and</em> #2345. The commit message will be appended as an event to the case. In addition, case #1234 will be closed.</p>
|
118
|
+
<p>You can also mention multiple cases with one keyword, e.g. <tt>Implements #1234 and #5123</tt>.</p>
|
119
|
+
<p>GitlabFogbugz recognizes the following keywords (also singular versions of the same keywords):</p>
|
120
|
+
<ul>
|
121
|
+
<li><tt>bugzid:</tt><br>For "compatibility" with the subversion wrapper provided by Fogcreek; however you still need to prefix the case number with <tt>#</tt>. Works like <tt>references</tt>.</li>
|
122
|
+
<li><tt>closes</tt></li>
|
123
|
+
<li><tt>completes</tt></li>
|
124
|
+
<li><tt>fixes</tt></li>
|
125
|
+
<li><tt>implements</tt></li>
|
126
|
+
<li><tt>reopens</tt></li>
|
127
|
+
<li><tt>references</tt> or <tt>refs</tt><br>Does not change the state of the case, just adds the commit message to this case.</li>
|
128
|
+
<li><tt>resolves</tt><br>Resolves is different then <tt>closes</tt>, <tt>completes</tt>, <tt>fixes</tt> and <tt>implements</tt>: it does not explicitly sets the FogBugz case status, thus changes the case to it's categories default status for resolved cases: Bug -> "fixed", Feature -> "Implemented", Inquiry -> "Responded" and Schedule Item -> "Completed"</li>
|
129
|
+
</ul>
|
130
|
+
<p>NOTE: FogBugz does not allow closing a case that isn't resolved, so you really must use "Implements X, closes X", or else it won't work.</p>
|
131
|
+
<p>Back to <a href="/tokens">Authenticated users</a></p>
|
132
|
+
HTML
|
141
133
|
end
|
142
134
|
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
redirect "/tokens"
|
153
|
-
end
|
135
|
+
get "/tokens" do
|
136
|
+
response = []
|
137
|
+
response << "<h1>List of authenticated users</h1>"
|
138
|
+
response << "<ul>"
|
139
|
+
tokens.map do |email, token|
|
140
|
+
response << "<li>#{email}"
|
141
|
+
response << %Q(<form method="post" action="/remove"><input type="hidden" name="email" value="#{email}"/><input type="submit" value="Remove"/></form>)
|
142
|
+
response << "</li>"
|
143
|
+
end
|
154
144
|
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
# Diff url: http://localhost:4567/repo_url?type=diff&repo=^REPO&file=^FILE&r1=^R1&r2=^R2
|
159
|
-
get '/repo_url' do
|
160
|
-
#pull out the repo's scm viewer url from the config file
|
161
|
-
if params[:type] == 'log'
|
162
|
-
url = config['repos'][params[:repo]]['log_url']
|
163
|
-
elsif params[:type] == 'diff'
|
164
|
-
url = config['repos'][params[:repo]]['diff_url']
|
165
|
-
else
|
166
|
-
"Unknown repo viewer type."
|
145
|
+
response << "</ul>"
|
146
|
+
response << %Q(<p><a href="/login">Add a user</a></p>)
|
147
|
+
response.join("\n")
|
167
148
|
end
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
redirect url
|
149
|
+
|
150
|
+
post "/remove" do
|
151
|
+
redirect "/tokens" unless params["email"]
|
152
|
+
tokens.delete(params["email"])
|
153
|
+
write_tokens
|
154
|
+
redirect "/tokens"
|
175
155
|
end
|
156
|
+
|
157
|
+
##
|
158
|
+
# Set the log and diff urls (in fogbugz's site settings) to point here.
|
159
|
+
# Log url: http://localhost:4567/repo_url?type=log&repo=^REPO&file=^FILE&r1=^R1&r2=^R2
|
160
|
+
# Diff url: http://localhost:4567/repo_url?type=diff&repo=^REPO&file=^FILE&r1=^R1&r2=^R2
|
161
|
+
get '/repo_url' do
|
162
|
+
#pull out the repo's scm viewer url from the config file
|
163
|
+
if params[:type] == 'log'
|
164
|
+
url = config['repos'][params[:repo]]['log_url']
|
165
|
+
elsif params[:type] == 'diff'
|
166
|
+
url = config['repos'][params[:repo]]['diff_url']
|
167
|
+
else
|
168
|
+
"Unknown repo viewer type."
|
169
|
+
end
|
176
170
|
|
177
|
-
|
171
|
+
if url
|
172
|
+
url.gsub!(/\^REPO/, params[:repo])
|
173
|
+
url.gsub!(/\^FILE/, params[:file])
|
174
|
+
url.gsub!(/\^R1/, params[:r1])
|
175
|
+
url.gsub!(/\^R2/, params[:r2])
|
176
|
+
redirect url
|
177
|
+
end
|
178
|
+
|
179
|
+
end
|
178
180
|
|
179
|
-
error do
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
end
|
181
|
+
error do
|
182
|
+
err = request.env['sinatra.error']
|
183
|
+
puts "Error handling request: #{err.name}"
|
184
|
+
puts err.backtrace.join("\n")
|
185
|
+
end
|
184
186
|
|
187
|
+
end
|
185
188
|
|
186
189
|
##
|
187
190
|
# This class does all of the json parsing and submits a push's commits to fogbugz
|
@@ -255,3 +258,5 @@ class GitlabFogbugz
|
|
255
258
|
end
|
256
259
|
end
|
257
260
|
end
|
261
|
+
|
262
|
+
GitlabFogbugzServer.run!
|
data/test/message_parser_test.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gitlab-fogbugz
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2012-07-
|
14
|
+
date: 2012-07-15 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: sinatra
|
@@ -92,6 +92,7 @@ extra_rdoc_files:
|
|
92
92
|
- LICENSE
|
93
93
|
- TODO
|
94
94
|
files:
|
95
|
+
- HISTORY.md
|
95
96
|
- LICENSE
|
96
97
|
- README.markdown
|
97
98
|
- Rakefile
|