Skip to content

Commit 200e128

Browse files
committed
Make hook work with Ruby 1.9.x
1 parent 845ae5e commit 200e128

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Diff for: contrib/hooks/post-receive.redmine_gitolite.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def get_git_repository_config(varname)
1818
(%x[git config #{varname} ]).chomp.strip
1919
end
2020
def get_http_params(rgh_vars)
21-
clear_time = Time.new.utc.to_i.to_s
21+
clear_time = Time.new.utc.to_i.to_s
2222
params = { "clear_time" => clear_time, "encoded_time" => Digest::SHA1.hexdigest(clear_time.to_s + rgh_vars["key"]) }
2323
rgh_vars.each_key do |v|
2424
if v != "key"
@@ -42,11 +42,11 @@ def set_form_data(request, params, sep = '&')
4242
end
4343

4444
def urlencode(str)
45-
str.gsub(/[^a-zA-Z0-9_\.\-]/n) {|s| sprintf('%%%02x', s[0]) }
45+
URI.encode(str,/[^a-zA-Z0-9_\.\-]/)
4646
end
4747

4848
def run_query(url_str, params, with_https)
49-
url_str = (with_https ? "https://" : "http://" ) + url_str.gsub(/^http[s]*:\/\//, "")
49+
url_str = (with_https ? "https://" : "http://" ) + url_str.gsub(/^http[s]*:\/\//, "")
5050
success = false
5151
begin
5252
url = URI.parse(url_str)
@@ -98,7 +98,7 @@ def run_query(url_str, params, with_https)
9898

9999
# Let's read the refs passed to us
100100
refs = []
101-
$<.each do |line|
101+
$<.each do |line|
102102
r = line.chomp.strip.split
103103
refs.push( [ r[0].to_s, r[1].to_s, r[2].to_s ].join(",") )
104104
end

0 commit comments

Comments
 (0)