svn_wc_tree 0.0.3 → 0.0.5
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.
- data/ChangeLog +12 -0
- data/Manifest +1 -1
- data/README.rdoc +3 -3
- data/bin/svn_wc_tree +64 -40
- data/lib/svn_wc_broker.rb +18 -10
- data/lib/svn_wc_client.rb +136 -39
- data/svn_conf.yaml +13 -8
- data/svn_wc_tree/index.html +6 -1
- data/svn_wc_tree/js/swt.js +64 -58
- data/tests/test_installer_bin.rb +430 -0
- metadata +10 -5
- data/svn_wc_tree.conf +0 -9
data/ChangeLog
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
version 0.0.5
|
2
|
+
* bug fix: default svn_status uses filter if set
|
3
|
+
|
4
|
+
version 0.0.4
|
5
|
+
* dir entries now grouped togther
|
6
|
+
* added filter(s): regex and amount. (amount filter is very beta)
|
7
|
+
* can filter svn_status and svn_list (set field use right click js menu)
|
8
|
+
(for instance, use filter with svn_list to delete unneeded files)
|
9
|
+
|
10
|
+
version 0.0.3
|
11
|
+
* added (installer unit tests)
|
12
|
+
|
1
13
|
version 0.0.2
|
2
14
|
* initial release
|
3
15
|
* run as PHP app (Ruby installation still required)
|
data/Manifest
CHANGED
@@ -3,6 +3,7 @@ cgi/svn_wc_broker.cgi
|
|
3
3
|
ChangeLog
|
4
4
|
lib/svn_wc_broker.rb
|
5
5
|
lib/svn_wc_client.rb
|
6
|
+
tests/test_installer_bin.rb
|
6
7
|
LICENSE
|
7
8
|
Manifest
|
8
9
|
README.rdoc
|
@@ -11,7 +12,6 @@ svn_wc_tree/css/swt.css
|
|
11
12
|
svn_wc_tree/img/swt_spinner.gif
|
12
13
|
svn_wc_tree/index.html
|
13
14
|
svn_wc_tree/index.php
|
14
|
-
svn_wc_tree.conf
|
15
15
|
svn_wc_tree/js/swt.js
|
16
16
|
svn_wc_tree/js/jquery-1.3.2.js
|
17
17
|
svn_wc_tree/js/jquery.blockUI-2.31.js
|
data/README.rdoc
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
= svn_wc_tree
|
2
2
|
|
3
3
|
A Web application front end that operates on the working copy of an
|
4
|
-
Subversion (SVN) repository.
|
4
|
+
Subversion (SVN) repository. (See Requirements)
|
5
5
|
|
6
6
|
|
7
7
|
== VERSION:
|
8
8
|
|
9
|
-
Version 0.0.
|
9
|
+
Version 0.0.5
|
10
10
|
|
11
11
|
NOTE: THIS IS ALPHA QUALITY SOFTWARE, use at your own risk!
|
12
12
|
|
@@ -293,7 +293,7 @@ See the ChangeLog file for details.
|
|
293
293
|
Copyright 2010 David Wright (david_v_wright@yahoo.com), all rights reserved.
|
294
294
|
|
295
295
|
|
296
|
-
svn_wc_tree 0.0.
|
296
|
+
svn_wc_tree 0.0.5 is released under the LGPL license.
|
297
297
|
|
298
298
|
|
299
299
|
== AUTHOR:
|
data/bin/svn_wc_tree
CHANGED
@@ -31,29 +31,53 @@
|
|
31
31
|
# location (filesystem path) of your svn_wc.conf file (readable by 'httpd
|
32
32
|
# runs as' owner)
|
33
33
|
#
|
34
|
-
# --
|
35
|
-
#
|
36
|
-
# (
|
34
|
+
# --copy_conf_from, -f [copy_conf_from]:
|
35
|
+
# copy your conf file (svn_conf.yaml) from filesystem path to
|
36
|
+
# (copy_conf_to)
|
37
37
|
#
|
38
|
-
# --
|
39
|
-
#
|
40
|
-
# (
|
38
|
+
# --copy_conf_to, -t [copy_conf_to]:
|
39
|
+
# copy your conf file (svn_conf.yaml) to filesystem path from
|
40
|
+
# (copy_conf_from)
|
41
41
|
#
|
42
42
|
#
|
43
43
|
# Example:
|
44
|
-
# svn_wc_tree --html /var/htdocs --cgi /var/cgi-bin \
|
45
|
-
# --post_to_url 'http://example.com/cgi-bin/ \
|
46
|
-
# --conf_location /opt/conf/svn_conf.yaml
|
47
|
-
#
|
48
|
-
# sudo svn_wc_tree --html /var/htdocs --post_to_url 'cgi-bin/cgi.rb'
|
49
44
|
#
|
45
|
+
# # install into /var/htdocs, post to PHP, use conf file already at location
|
50
46
|
# sudo svn_wc_tree --html /var/htdocs --php true \
|
51
47
|
# --conf_location /opt/svn_wc_tree/svn_conf.yaml
|
52
48
|
#
|
49
|
+
# # install (app/html/js) into /var/htdocs
|
50
|
+
# # install CGI into /var/cgi-bin
|
51
|
+
# # post to CGI script at 'http://example.com/cgi-bin/svn_wc_broker.cgi'
|
52
|
+
# # (install at path: /var/cgi-bin)
|
53
|
+
# # use conf file already at location
|
54
|
+
# svn_wc_tree --html /var/htdocs --cgi /var/cgi-bin \
|
55
|
+
# --post_to_url 'http://example.com/cgi-bin/svn_wc_broker.cgi' \
|
56
|
+
# --conf_location /opt/conf/svn_conf.yaml
|
57
|
+
#
|
58
|
+
# # install (app/html/js) into /var/htdocs
|
59
|
+
# # install CGI into /var/cgi-bin
|
60
|
+
# # post to CGI (pre existing script) at 'cgi-bin/cgi.rb' (must be relative
|
61
|
+
# # to the app html dir, or fully qualified path)
|
62
|
+
# # conf file path already added to the pre existing cgi you wrote
|
63
|
+
# sudo svn_wc_tree --html /var/htdocs --post_to_url 'cgi-bin/cgi.rb'
|
64
|
+
#
|
65
|
+
# # install app into /var/www
|
66
|
+
# # install CGI into /usr/lib/cgi-bin
|
67
|
+
# # post to CGI (use apps provided cgi script - installed with --cgi)
|
68
|
+
# # using fully qualified path)
|
69
|
+
# # copy conf file from /tmp/svn_conf.yaml to /usr/local/svn_wc_tree dir/)
|
53
70
|
# sudo svn_wc_tree --html /var/www --cgi /usr/lib/cgi-bin \
|
54
|
-
# --post_to_url 'http://localhost/cgi-bin/'
|
55
|
-
# /tmp/svn_conf.yaml
|
56
|
-
|
71
|
+
# --post_to_url 'http://localhost/cgi-bin/svn_wc_broker.cgi' \
|
72
|
+
# --copy_conf_from /tmp/svn_conf.yaml \
|
73
|
+
# --copy_conf_to /usr/local/svn_wc_tree
|
74
|
+
#
|
75
|
+
# # install app into `$HOME`/public_html
|
76
|
+
# # post to PHP (resource provided by this app)
|
77
|
+
# # copy conf file from, to
|
78
|
+
# sudo svn_wc_tree --html ~/public_html --php true \
|
79
|
+
# --copy_conf_from `pwd`/svn_conf.yaml \
|
80
|
+
# --copy_conf_to /home/dwright/test_svn/wc
|
57
81
|
|
58
82
|
require 'getoptlong'
|
59
83
|
require 'rdoc/usage'
|
@@ -66,17 +90,17 @@ opts = GetoptLong.new(
|
|
66
90
|
[ '--cgi', '-c', GetoptLong::OPTIONAL_ARGUMENT],
|
67
91
|
[ '--php', '-p', GetoptLong::OPTIONAL_ARGUMENT],
|
68
92
|
[ '--conf_location', '-o', GetoptLong::OPTIONAL_ARGUMENT],
|
69
|
-
[ '--
|
70
|
-
[ '--
|
93
|
+
[ '--copy_conf_from', '-f', GetoptLong::OPTIONAL_ARGUMENT],
|
94
|
+
[ '--copy_conf_to' , '-t', GetoptLong::OPTIONAL_ARGUMENT]
|
71
95
|
)
|
72
96
|
|
73
97
|
html_dir = nil
|
74
98
|
cgi_dir = nil
|
75
|
-
php
|
99
|
+
@php = false
|
76
100
|
post_to_url = 'index.php' # assume php mode
|
77
101
|
conf_location = nil
|
78
|
-
|
79
|
-
|
102
|
+
copy_conf_from = nil
|
103
|
+
copy_conf_to = nil
|
80
104
|
|
81
105
|
opts.each do |opt, arg|
|
82
106
|
case opt
|
@@ -89,36 +113,36 @@ opts.each do |opt, arg|
|
|
89
113
|
when '--cgi'
|
90
114
|
if arg != '' then cgi_dir = arg end
|
91
115
|
when '--php'
|
92
|
-
if arg != '' then php = true end
|
116
|
+
if arg != '' then @php = true end
|
93
117
|
when '--post_to_url'
|
94
118
|
#if php then raise ArgumentError, 'post_to_url, is not used when php'
|
95
119
|
if arg != '' then post_to_url = arg end
|
96
120
|
when '--conf_location'
|
97
121
|
if arg != '' then conf_location = arg end
|
98
|
-
when '--
|
99
|
-
if arg != '' then
|
100
|
-
when '--
|
101
|
-
if arg != '' then
|
122
|
+
when '--copy_conf_from'
|
123
|
+
if arg != '' then copy_conf_from = arg end
|
124
|
+
when '--copy_conf_to'
|
125
|
+
if arg != '' then copy_conf_to = arg end
|
102
126
|
end
|
103
127
|
end
|
104
128
|
|
105
129
|
# methods
|
106
130
|
|
107
|
-
def handle_conf(
|
131
|
+
def handle_conf(copy_conf_from, copy_conf_to, cgi_dir=nil)
|
132
|
+
raise "#{copy_conf_to} is a file!" if File.file? copy_conf_to
|
133
|
+
FileUtils.mkdir copy_conf_to unless File.directory? copy_conf_to
|
134
|
+
|
108
135
|
begin
|
109
|
-
FileUtils.
|
110
|
-
FileUtils.cp move_conf_from, move_conf_to
|
136
|
+
FileUtils.cp copy_conf_from, copy_conf_to
|
111
137
|
rescue
|
112
|
-
#puts "Destination conf file exists #{
|
138
|
+
#puts "Destination conf file exists #{copy_conf_to}"
|
113
139
|
end
|
114
140
|
# now edit lib to set conf_file path
|
115
|
-
|
116
|
-
to_name = File.basename(move_conf_from) # name of conf file
|
117
|
-
conf_abs_path = File.join(to_path, to_name)
|
141
|
+
conf_abs_path = File.join(copy_conf_to, File.basename(copy_conf_from))
|
118
142
|
set_conf_file_in_cgi(cgi_dir, conf_abs_path) if cgi_dir
|
119
143
|
end
|
120
144
|
|
121
|
-
def set_conf_file_in_cgi(cgi_dir, conf_location
|
145
|
+
def set_conf_file_in_cgi(cgi_dir, conf_location)
|
122
146
|
cgi_file = File.join(cgi_dir, 'svn_wc_broker.cgi')
|
123
147
|
File.open(cgi_file, 'r+') do |cf|
|
124
148
|
lines = cf.readlines
|
@@ -126,7 +150,7 @@ def set_conf_file_in_cgi(cgi_dir, conf_location, php=nil)
|
|
126
150
|
el.gsub! /CONF_FILE = nil/,
|
127
151
|
"CONF_FILE = '#{conf_location}'"
|
128
152
|
# dont print header when run under php
|
129
|
-
el.gsub! /print cgi.header/, '#print cgi.header' if php
|
153
|
+
el.gsub! /print cgi.header/, '#print cgi.header' if @php
|
130
154
|
end
|
131
155
|
cf.pos = 0
|
132
156
|
cf.print lines
|
@@ -171,9 +195,9 @@ rescue Exception => e
|
|
171
195
|
end
|
172
196
|
|
173
197
|
# cgi script
|
174
|
-
cgi_path = html_dest if php
|
198
|
+
cgi_path = html_dest if @php
|
175
199
|
# if set, will overwrite php cgi url
|
176
|
-
cgi_path = cgi_dir if cgi_dir
|
200
|
+
cgi_path = cgi_dir if cgi_dir
|
177
201
|
|
178
202
|
if cgi_path
|
179
203
|
begin
|
@@ -188,7 +212,7 @@ end
|
|
188
212
|
if conf_location
|
189
213
|
if cgi_path and conf_location
|
190
214
|
begin
|
191
|
-
set_conf_file_in_cgi(cgi_path, conf_location
|
215
|
+
set_conf_file_in_cgi(cgi_path, conf_location)
|
192
216
|
rescue Exception => e
|
193
217
|
puts "line:#{__LINE__} Exception: #{e.message}"
|
194
218
|
exit 1
|
@@ -206,12 +230,12 @@ end
|
|
206
230
|
|
207
231
|
begin
|
208
232
|
# conf file
|
209
|
-
if
|
210
|
-
if not (
|
211
|
-
puts 'if using "
|
233
|
+
if copy_conf_from or copy_conf_to
|
234
|
+
if not (copy_conf_from and copy_conf_to)
|
235
|
+
puts 'if using "copy_", both copy_conf_to and copy_conf_from must be set'
|
212
236
|
exit 1
|
213
237
|
end
|
214
|
-
handle_conf(
|
238
|
+
handle_conf(copy_conf_from, copy_conf_to, cgi_path)
|
215
239
|
end
|
216
240
|
rescue Exception => e
|
217
241
|
puts "line:#{__LINE__} Exception: #{e.message}"
|
data/lib/svn_wc_broker.rb
CHANGED
@@ -21,12 +21,11 @@ require 'svn_wc_client'
|
|
21
21
|
#
|
22
22
|
# Broker requests between web app (AJAX) to svn_wc_client
|
23
23
|
#
|
24
|
-
# (this probably
|
25
|
-
#
|
26
|
-
# already changed)
|
24
|
+
# (this script is probably unnecessary and can be done away with
|
25
|
+
# it's left over from an early design decision which has changed)
|
27
26
|
#
|
28
|
-
#
|
29
|
-
#
|
27
|
+
# what it does: populate the top level array element with :run_error
|
28
|
+
# set to any exception that occurs: #repo[0]={:run_error => "Error: #{e.message}"}
|
30
29
|
#
|
31
30
|
module SvnWcBroker
|
32
31
|
|
@@ -41,7 +40,7 @@ module SvnWcBroker
|
|
41
40
|
# set abs_path to your configuration file
|
42
41
|
def set_conf_file(conf) ; @conf_file = conf ; end
|
43
42
|
|
44
|
-
# makes the requests against svn_wc
|
43
|
+
# makes the requests against our lib which, uses the ruby gem lib 'svn_wc'
|
45
44
|
include SvnRepoClient
|
46
45
|
|
47
46
|
# pass web requests in, handle defined actions, return results
|
@@ -49,9 +48,11 @@ module SvnWcBroker
|
|
49
48
|
# contains our web POST request
|
50
49
|
def handle_responses(params)
|
51
50
|
|
52
|
-
|
51
|
+
#--
|
52
|
+
# to debug during devel
|
53
53
|
#return svn_results debug_request(params['do_svn_action'])
|
54
54
|
#return svn_results debug_request(params.to_s.to_a)
|
55
|
+
#++
|
55
56
|
if params['do_svn_action'] \
|
56
57
|
&& (params['do_svn_action'].to_s == 'Do Svn Action')
|
57
58
|
|
@@ -59,7 +60,7 @@ module SvnWcBroker
|
|
59
60
|
if params and params['svn_action'].to_s.strip.empty?
|
60
61
|
return svn_results
|
61
62
|
else
|
62
|
-
return svn_results send(
|
63
|
+
return svn_results( send(:do_requested_action, params) )
|
63
64
|
end
|
64
65
|
|
65
66
|
else
|
@@ -93,7 +94,14 @@ module SvnWcBroker
|
|
93
94
|
end
|
94
95
|
|
95
96
|
end
|
96
|
-
|
97
|
+
# eval known actions only
|
98
|
+
# svn_list takes args # svn_status takes args
|
99
|
+
if action == 'list' || action == 'status'
|
100
|
+
eval("svn_#{action}('#{params['filter_re']}','#{params['filter_amt']}')")
|
101
|
+
else
|
102
|
+
# danger will robinson, only eval known supported actions
|
103
|
+
eval("svn_#{action}") if SUPPORTED_ACTIONS.index(action)
|
104
|
+
end
|
97
105
|
rescue Exception => exn
|
98
106
|
resp_data[0] = {:run_error => "Error: #{exn.message}"}
|
99
107
|
end
|
@@ -106,7 +114,7 @@ module SvnWcBroker
|
|
106
114
|
run_error = String.new
|
107
115
|
|
108
116
|
begin
|
109
|
-
svn_status_list = svn_status
|
117
|
+
svn_status_list = svn_status(params['filter_re'], params['filter_amt'])
|
110
118
|
rescue Exception => e
|
111
119
|
run_error << e.message
|
112
120
|
end
|
data/lib/svn_wc_client.rb
CHANGED
@@ -18,7 +18,7 @@ require 'svn_wc'
|
|
18
18
|
|
19
19
|
#
|
20
20
|
# receives method/action requests from web app (AJAX) returns data in expected format
|
21
|
-
# is just a client of svn_wc
|
21
|
+
# is just a 'simple' client of ruby gem lib 'svn_wc'
|
22
22
|
#
|
23
23
|
# returned data is generally a array of anonymous hashes containing
|
24
24
|
# svn entries info, or errors.
|
@@ -33,6 +33,7 @@ require 'svn_wc'
|
|
33
33
|
# each_details[:repo_root_local_path] = File.join(@repo_root, '/')
|
34
34
|
#
|
35
35
|
module SvnRepoClient
|
36
|
+
STATUS_SPACER = "\t" # swt.js (js/jqtree file uses this)
|
36
37
|
|
37
38
|
@@svn_wc = SvnWc::RepoAccess.new
|
38
39
|
|
@@ -41,53 +42,66 @@ module SvnRepoClient
|
|
41
42
|
|
42
43
|
# if conf file exists and have a working copy of the repo, return the path
|
43
44
|
# to it, otherwise create it (do a checkout, not forced)
|
45
|
+
# set force_checkout = true to force a checkout
|
44
46
|
# returns svn_repo_working_copy abs_path
|
45
47
|
def get_repo
|
46
48
|
if File.file? @conf_file
|
47
49
|
@@svn_wc.set_conf @conf_file
|
48
50
|
else raise ArgumentError, "config file not found! #{@conf_file}" end
|
49
51
|
|
50
|
-
if not File.directory? @@svn_wc.svn_repo_working_copy
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
52
|
+
#if not File.directory? @@svn_wc.svn_repo_working_copy
|
53
|
+
begin
|
54
|
+
if not File.directory? @@svn_wc.svn_repo_working_copy \
|
55
|
+
or @@svn_wc.force_checkout
|
56
|
+
#@@svn_wc.do_checkout(true, @@svn_wc.force_checkout)
|
57
|
+
@@svn_wc.do_checkout(true)
|
55
58
|
end
|
59
|
+
rescue SvnWc::RepoAccessError => e
|
60
|
+
raise e.message
|
56
61
|
end
|
57
62
|
@repo_root = @@svn_wc.svn_repo_working_copy
|
58
63
|
end
|
59
64
|
|
60
|
-
|
61
|
-
# do checkout if not exists at local path
|
62
|
-
def svn_status
|
65
|
+
def svn_status(f_regex=nil, f_amt=nil)
|
63
66
|
get_repo
|
64
|
-
|
65
|
-
ent = Array.new
|
67
|
+
repo_entries = Array.new
|
66
68
|
begin
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
69
|
+
l_svn_list = Array.new
|
70
|
+
@@svn_wc.status.each { |el|
|
71
|
+
status_info = {}
|
72
|
+
#status_info[:last_changed_rev] = el[:last_changed_rev]
|
73
|
+
status_info[:status] = el[:status]
|
74
|
+
status_info[:error] = ''
|
75
|
+
status_info[:entry_name] = el[:path]
|
76
|
+
if File.directory?(File.join(@repo_root, el[:path]))
|
77
|
+
status_info[:kind] = 2 # is dir
|
78
|
+
else
|
79
|
+
status_info[:kind] = 1 # is 'file'
|
80
|
+
end
|
81
|
+
#apply filter - limit result set with filter
|
82
|
+
#f_regex, f_amt = 'cof/htdocs/template', 10
|
83
|
+
if f_regex.nil?
|
84
|
+
l_svn_list.push status_info
|
85
|
+
elsif el[:path].match(f_regex)
|
86
|
+
l_svn_list.push status_info
|
87
|
+
end
|
88
|
+
#l_svn_list.push status_info
|
89
|
+
if f_amt.nil? or f_amt.empty?
|
90
|
+
elsif l_svn_list.size > f_amt.to_i
|
91
|
+
break
|
92
|
+
end
|
93
|
+
}
|
94
|
+
|
95
|
+
@entries_list = _to_expected_json_format(l_svn_list)
|
96
|
+
repo_entries.push info_data
|
83
97
|
rescue SvnWc::RepoAccessError => e
|
98
|
+
#@error = e.message
|
84
99
|
@error = "#{e.message} #{@@svn_wc}"
|
85
|
-
|
100
|
+
repo_entries.push info_data
|
86
101
|
end
|
87
|
-
|
88
|
-
st_list.push info_data if ent.length > 0
|
89
|
-
st_list
|
102
|
+
repo_entries
|
90
103
|
end
|
104
|
+
|
91
105
|
|
92
106
|
# diff current to previous (HEAD only)
|
93
107
|
# returns diff content
|
@@ -218,23 +232,37 @@ module SvnRepoClient
|
|
218
232
|
|
219
233
|
# recursively list entries, provides file or dir info and access to
|
220
234
|
# nice repo/file info
|
221
|
-
def svn_list
|
235
|
+
def svn_list(f_regex=nil, f_amt=nil)
|
222
236
|
get_repo
|
223
237
|
repo_entries = Array.new
|
224
238
|
begin
|
225
239
|
l_svn_list = Array.new
|
226
240
|
@@svn_wc.list.each { |el|
|
227
241
|
status_info = {}
|
228
|
-
|
229
|
-
status_info[:kind] = 1 # is 'file'
|
242
|
+
fqpn = File.join(@repo_root, el[:entry])
|
230
243
|
#status_info[:last_changed_rev] = el[:last_changed_rev]
|
231
|
-
|
232
|
-
|
233
|
-
|
244
|
+
status_info[:entry_name] = fqpn
|
245
|
+
status_info[:status] = ' '
|
246
|
+
if File.directory? fqpn
|
247
|
+
status_info[:kind] = 2 # is dir
|
248
|
+
else
|
249
|
+
status_info[:kind] = 1 # is 'file'
|
250
|
+
end
|
251
|
+
#apply filter - limit result set with filter
|
252
|
+
#f_regex, f_amt = 'cof/htdocs/template', 10
|
253
|
+
if f_regex.nil?
|
254
|
+
l_svn_list.push status_info
|
255
|
+
elsif el[:entry].match(f_regex)
|
256
|
+
l_svn_list.push status_info
|
257
|
+
end
|
258
|
+
#l_svn_list.push status_info
|
259
|
+
if f_amt.nil? or f_amt.empty?
|
260
|
+
elsif l_svn_list.size > f_amt.to_i
|
261
|
+
break
|
234
262
|
end
|
235
|
-
l_svn_list.push status_info
|
236
263
|
}
|
237
|
-
|
264
|
+
#@entries_list = l_svn_list
|
265
|
+
@entries_list = _to_expected_json_format(l_svn_list)
|
238
266
|
repo_entries.push info_data
|
239
267
|
rescue SvnWc::RepoAccessError => e
|
240
268
|
@error = e.message
|
@@ -243,6 +271,53 @@ module SvnRepoClient
|
|
243
271
|
repo_entries
|
244
272
|
end
|
245
273
|
|
274
|
+
def _collect_and_group(file_info_list)
|
275
|
+
|
276
|
+
entries_group_by_dir = {}
|
277
|
+
file_info_list.each do |el|
|
278
|
+
en = el[:entry_name]
|
279
|
+
if el[:kind] == 2
|
280
|
+
entries_group_by_dir[en] = [] unless entries_group_by_dir[en]
|
281
|
+
entries_group_by_dir[en].push en
|
282
|
+
elsif el[:kind] == 1
|
283
|
+
entries_group_by_dir[File.dirname(en)] = [] unless entries_group_by_dir[File.dirname(en)]
|
284
|
+
entries_group_by_dir[File.dirname(en)].push "#{en}:#{el[:status]}"
|
285
|
+
end
|
286
|
+
end
|
287
|
+
|
288
|
+
entries_group_by_dir
|
289
|
+
end
|
290
|
+
|
291
|
+
def _to_expected_json_format(file_info_list)
|
292
|
+
require 'enumerator' # to_enum :each_with_index
|
293
|
+
|
294
|
+
entries_group_by_dir = _collect_and_group(file_info_list)
|
295
|
+
|
296
|
+
entries_formatted = {}
|
297
|
+
entries_formatted[:children] = []
|
298
|
+
atts = {}
|
299
|
+
atts[:id] = ''
|
300
|
+
c_entries = {}
|
301
|
+
c_entries[:attributes] = atts
|
302
|
+
c_entries[:data] = ''
|
303
|
+
entries = []
|
304
|
+
id = 0
|
305
|
+
entries_group_by_dir.each do |k|
|
306
|
+
entries_formatted[:state] = 'open'
|
307
|
+
entries_formatted[:data] = k[0]
|
308
|
+
entries_formatted[:children] = k[1].to_enum(:each_with_index).collect{|x,i|
|
309
|
+
next unless x and x.split(':')[1]
|
310
|
+
{:attributes => {:id => i}, :data => x.split(':')[1] + STATUS_SPACER + x.split(':')[0]}
|
311
|
+
}
|
312
|
+
entries.push entries_formatted
|
313
|
+
entries_formatted = {}
|
314
|
+
c_entries = {}
|
315
|
+
end
|
316
|
+
|
317
|
+
entries
|
318
|
+
|
319
|
+
end
|
320
|
+
|
246
321
|
def info_data
|
247
322
|
each_details = Hash.new
|
248
323
|
each_details[:file] = @path
|
@@ -264,3 +339,25 @@ module SvnRepoClient
|
|
264
339
|
end
|
265
340
|
|
266
341
|
end
|
342
|
+
|
343
|
+
if __FILE__ == $0
|
344
|
+
@conf_file = '/home/httpd/radmin/config/svn_conf.yaml'
|
345
|
+
#p SvnRepoClient::svn_list
|
346
|
+
#p svn_list
|
347
|
+
#p svn_list
|
348
|
+
#p Object.new.extend(self).svn_list
|
349
|
+
|
350
|
+
class Object
|
351
|
+
require 'fileutils'
|
352
|
+
require 'svn_wc_client'
|
353
|
+
include SvnRepoClient
|
354
|
+
#svn_list
|
355
|
+
end
|
356
|
+
#p eval("svn_list")
|
357
|
+
p svn_list
|
358
|
+
#p SvnRepoClient::svn_list
|
359
|
+
#p Tester.new.svn_list
|
360
|
+
|
361
|
+
|
362
|
+
end
|
363
|
+
|
data/svn_conf.yaml
CHANGED
@@ -1,9 +1,14 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
svn_repo_master : svn+ssh://svn_test_user@localhost/tmp/svnrepo
|
4
|
-
|
5
|
-
svn_repo_working_copy : /tmp/repo_test
|
6
|
-
svn_user : svn_test_user
|
7
|
-
svn_pass : svn_test_pass
|
8
|
-
svn_repo_config_path : /tmp/config
|
1
|
+
##svn_repo_master : file:///tmp/svn/repo_test
|
2
|
+
##svn_repo_master : svn+ssh:///tmp/svnrepo
|
3
|
+
#svn_repo_master : svn+ssh://svn_test_user@localhost/tmp/svnrepo
|
4
|
+
##svn_repo_master : svn+ssh://example.com/tmp/svnrepo
|
5
|
+
#svn_repo_working_copy : /tmp/repo_test
|
6
|
+
#svn_user : svn_test_user
|
7
|
+
#svn_pass : svn_test_pass
|
8
|
+
#svn_repo_config_path : /tmp/config
|
9
|
+
|
10
|
+
svn_repo_master : file:///home/dwright/test_svn/test_repo
|
11
|
+
svn_repo_working_copy : /home/dwright/test_svn/wc
|
12
|
+
svn_repo_config_path : /home/dwright/test_svn/
|
13
|
+
force_checkout : true
|
9
14
|
|
data/svn_wc_tree/index.html
CHANGED
@@ -124,7 +124,12 @@
|
|
124
124
|
<input type='hidden' id="svn_local_repo_root" value='' />
|
125
125
|
|
126
126
|
<a id='disp_repo_info'>~</a><div id="display_repo_info" class="disp_no"></div>
|
127
|
-
|
127
|
+
<br/>
|
128
|
+
<br/>
|
129
|
+
Filter: <input type='text' id='swt_filter_re' size='25'/> [Limit by Terms, Regex Ok]<br/>
|
130
|
+
Filter: <input type='text' id='swt_filter_amt' size='3'/> [Limit by Amount]
|
131
|
+
<br/>
|
132
|
+
<br/>
|
128
133
|
<!-- start: show results from svn actions -->
|
129
134
|
<div id="show_hide_container" class="disp_no">
|
130
135
|
<a id="hide_n_show">[-]</a>
|
data/svn_wc_tree/js/swt.js
CHANGED
@@ -20,6 +20,9 @@ var POST_URL = '';
|
|
20
20
|
///////////////////////////////////////////////////////////////////////////////
|
21
21
|
|
22
22
|
//XXX/TODO this file needs to be refactored
|
23
|
+
// TODO upgrade to 1.0.a, or whatever newest of jstree is, unfortunelty
|
24
|
+
// the API does not appear to be backwards compatible, so a rewrite will be
|
25
|
+
// needed
|
23
26
|
|
24
27
|
var STATUS_SPACER = "\t"; // " "
|
25
28
|
var SVN_ACTION = '';
|
@@ -47,11 +50,13 @@ $.blockUI.defaults.css =
|
|
47
50
|
//$.blockUI.defaults.applyPlatformOpacityRules = false;
|
48
51
|
$(document).ajaxStart($.blockUI).ajaxStop($.unblockUI);
|
49
52
|
|
50
|
-
|
51
53
|
$(document).ready(function(){
|
52
54
|
var CHECKED_FILE_NAMES = []
|
53
55
|
var SVN_ENTRIES = []
|
54
56
|
|
57
|
+
// 'onload' populate 'keep filter' if has been set
|
58
|
+
keep_filter($.cookie('swt_filter_re'));
|
59
|
+
|
55
60
|
// the repo tree
|
56
61
|
$(function () {
|
57
62
|
$("#svn_repo_entries_tree").tree({
|
@@ -177,6 +182,10 @@ $(document).ready(function(){
|
|
177
182
|
refresh : {
|
178
183
|
label : "refresh tree",
|
179
184
|
action : function (NODE, TREE_OBJ) {
|
185
|
+
var re_filter = $("#swt_filter_re").val();
|
186
|
+
//console.log(re_filter);
|
187
|
+
// set current filter to a cookie
|
188
|
+
$.cookie('swt_filter_re', re_filter);
|
180
189
|
window.location.reload();
|
181
190
|
//history.go();
|
182
191
|
},
|
@@ -243,24 +252,23 @@ $(document).ready(function(){
|
|
243
252
|
return {
|
244
253
|
'do_svn_action': 'Do Svn Action',
|
245
254
|
'svn_action' : SVN_ACTION,
|
246
|
-
'svn_files' : [gather_selected_files()]
|
255
|
+
'svn_files' : [gather_selected_files()],
|
256
|
+
'filter_re' : $("#swt_filter_re").val(),
|
257
|
+
'filter_amt' : $("#swt_filter_amt").val()
|
247
258
|
}
|
248
259
|
}
|
249
260
|
}
|
250
261
|
});
|
251
262
|
});
|
252
263
|
|
264
|
+
// XXX this is called for all ajax requests (i.e. 'refresh')
|
253
265
|
function on_data(DATA, TREE_OBJ) {
|
254
266
|
//console.log('on DATA'); console.log(DATA);
|
255
267
|
if (!DATA) document.write('No Data received, possibly your session expired');
|
256
268
|
|
257
269
|
var entries_list = new Array
|
270
|
+
|
258
271
|
if (DATA && DATA.length) {
|
259
|
-
var f_nodes = {
|
260
|
-
'state' : 'open',
|
261
|
-
'data' : DATA[0].repo_root_local_path,
|
262
|
-
'children' : new Array
|
263
|
-
};
|
264
272
|
$("#svn_local_repo_root").val(DATA[0].repo_root_local_path);
|
265
273
|
|
266
274
|
// display high level repo info
|
@@ -268,49 +276,49 @@ $(document).ready(function(){
|
|
268
276
|
|
269
277
|
if (DATA[0].run_error) return display_error_message(DATA[0].run_error);
|
270
278
|
if (DATA[0].error) return display_error_message(DATA[0].error);
|
279
|
+
if (DATA[0].entries == undefined) display_error_message('no result');
|
271
280
|
|
272
|
-
|
273
|
-
var f_node_children = new Array;
|
274
|
-
var has_status = ' ';
|
275
|
-
var repo_initial_state = 'open'; // open|closed
|
276
281
|
var amount_of_entries = DATA[0].entries.length;
|
277
|
-
if (amount_of_entries ==
|
278
|
-
|
279
|
-
|
282
|
+
if (amount_of_entries == 0) {
|
283
|
+
if ($("#swt_filter_re").val()) report_no_match_if_filter();
|
284
|
+
else repo_up_to_date();
|
285
|
+
|
286
|
+
// use repo root as default when no results
|
287
|
+
var repo_default = {
|
288
|
+
'state' : 'open',
|
289
|
+
'data' : DATA[0].repo_root_local_path
|
290
|
+
}
|
291
|
+
entries_list.push(repo_default);
|
292
|
+
}
|
280
293
|
for (i = 0; i<amount_of_entries; i++) {
|
281
294
|
ent = DATA[0].entries[i];
|
282
295
|
if (ent === undefined) continue;
|
283
|
-
|
284
|
-
|
285
|
-
'state' : repo_initial_state,
|
286
|
-
'data' : ent.dir_name,
|
287
|
-
'children' : f_node_children
|
288
|
-
};
|
289
|
-
entries_list.push(f_nodes)
|
290
|
-
f_node_children = new Array;
|
291
|
-
} // regular file
|
292
|
-
else if (ent.kind == 1){ // file
|
293
|
-
if (ent.status) has_status = ent.status
|
294
|
-
var f_node_child = {
|
295
|
-
'attributes' : {'id' : i},
|
296
|
-
data : has_status + STATUS_SPACER + ent.entry_name
|
297
|
-
};
|
298
|
-
f_node_children.push(f_node_child)
|
299
|
-
}
|
296
|
+
//console.log(ent);
|
297
|
+
entries_list.push(ent);
|
300
298
|
}
|
301
299
|
}
|
302
300
|
//console.log(entries_list);
|
303
301
|
return entries_list;
|
304
302
|
}
|
305
303
|
|
306
|
-
function
|
307
|
-
|
304
|
+
function keep_filter(re_filter){
|
305
|
+
//console.log(re_filter);
|
306
|
+
$("#swt_filter_re").val(re_filter);
|
307
|
+
}
|
308
|
+
|
309
|
+
// limit result set with filter
|
310
|
+
function is_filtered(file_name, re_filter){
|
311
|
+
if(!file_name.match(re_filter)) return true;
|
312
|
+
return false;
|
313
|
+
}
|
314
|
+
|
315
|
+
function report_no_match_if_filter(){
|
316
|
+
$("#svn_action_results").prepend('<p style="color:blue">No Match.</p>');
|
317
|
+
}
|
318
|
+
|
319
|
+
function repo_up_to_date(){
|
308
320
|
$("#svn_action_results").prepend('<p style="color:blue">'
|
309
321
|
+ 'Repository is up to date.</p>');
|
310
|
-
//if (DATA[0].entries === undefined){
|
311
|
-
// entries_list.push(f_nodes)
|
312
|
-
//}
|
313
|
-
//return entries_list;
|
314
322
|
}
|
315
323
|
|
316
324
|
function post_req_non_svn(action) {
|
@@ -393,7 +401,8 @@ $(document).ready(function(){
|
|
393
401
|
var run_err = undefined;
|
394
402
|
if (resp && resp[0] && resp[0].run_error) run_err = resp[0].run_error;
|
395
403
|
else if (resp && resp.run_error) run_err = resp.run_error;
|
396
|
-
|
404
|
+
|
405
|
+
if (run_err) return display_error_message(resp.run_error);
|
397
406
|
|
398
407
|
// update tree display post success action
|
399
408
|
if (svn_action == 'commit') change_display_selected_files(STATUS_SPACER);
|
@@ -408,36 +417,36 @@ $(document).ready(function(){
|
|
408
417
|
|
409
418
|
display_svn_results = process_content_and_entries(resp[i], svn_action,
|
410
419
|
display_svn_results);
|
420
|
+
//console.log(display_svn_results);
|
411
421
|
}
|
412
422
|
|
413
423
|
if (show_response_area) $('#show_hide_container').show();
|
414
424
|
// populate our div
|
415
425
|
$("#svn_action_results").html(display_svn_results);
|
416
426
|
}
|
417
|
-
|
418
427
|
|
419
|
-
|
420
|
-
|
421
|
-
|
428
|
+
function process_content_and_entries(jdata, svn_action, display_svn_results){
|
429
|
+
var error = '';
|
430
|
+
var contents = '';
|
422
431
|
|
423
|
-
|
432
|
+
if (jdata.error) error = '<p style="color:red">'+jdata.error+'</p>';
|
424
433
|
|
425
|
-
|
426
|
-
|
427
|
-
|
434
|
+
// used for 'diff'
|
435
|
+
if (jdata.content) // expand newline to line break, '<' to html entity
|
436
|
+
contents += jdata.content.replace(/</g, '<').replace(/\n/g, '<br/>');
|
428
437
|
|
429
|
-
|
438
|
+
//if (jdata.entries) process_entries(jdata.entries, svn_action);
|
430
439
|
|
431
|
-
|
432
|
-
|
440
|
+
if (jdata.repo_root_local_path)
|
441
|
+
$("#svn_local_repo_root").val(jdata.repo_root_local_path);
|
433
442
|
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
443
|
+
if (contents)
|
444
|
+
display_svn_results += error + '<p style="color:grey">'+contents+'</p>';
|
445
|
+
else
|
446
|
+
display_svn_results += error;
|
438
447
|
|
439
|
-
|
440
|
-
|
448
|
+
return display_svn_results;
|
449
|
+
}
|
441
450
|
|
442
451
|
function process_entries(entries, svn_action){
|
443
452
|
SVN_ENTRIES = entries;
|
@@ -465,8 +474,6 @@ $(document).ready(function(){
|
|
465
474
|
}
|
466
475
|
|
467
476
|
function change_display_selected_files(to_show){
|
468
|
-
//console.log(CHECKED_FILE_NAMES);
|
469
|
-
|
470
477
|
for(j=0;j<CHECKED_FILE_NAMES.length;j++){
|
471
478
|
if(CHECKED_FILE_NAMES[j] !== undefined){
|
472
479
|
//remove the status, was committed (i.e 'M', or '?', '!', etc)
|
@@ -478,7 +485,6 @@ $(document).ready(function(){
|
|
478
485
|
$.tree.focused().remove('#' + j, ent);
|
479
486
|
}
|
480
487
|
}
|
481
|
-
|
482
488
|
}
|
483
489
|
|
484
490
|
|
@@ -0,0 +1,430 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'fileutils'
|
3
|
+
require 'tempfile'
|
4
|
+
|
5
|
+
# unit tests to prove installation of svn_wc_tree
|
6
|
+
# just testing the bin/ installer
|
7
|
+
|
8
|
+
class TestSvnWcTreeBinInstaller < Test::Unit::TestCase
|
9
|
+
|
10
|
+
INSTALLER = File.join(File.dirname(__FILE__), "..", "bin", 'svn_wc_tree')
|
11
|
+
|
12
|
+
# --html, -l [html_dir]:
|
13
|
+
# Move all web files to the directory path specified.
|
14
|
+
# A directory called svn_wc_tree will be created at this path.
|
15
|
+
#
|
16
|
+
# --cgi, -c [cgi_dir]:
|
17
|
+
# Move the included CGI script to the path specified.
|
18
|
+
# path/directory must exist and must be able to execute CGI scripts
|
19
|
+
#
|
20
|
+
# --post_to_url, -u [post_to_url]:
|
21
|
+
# a URL that will receive AJAX requests and return the required JSON.
|
22
|
+
# (see the CGI script provided)
|
23
|
+
#
|
24
|
+
# --php, -p [php]:
|
25
|
+
# Run as a PHP application. (use only as last choice)
|
26
|
+
# (Ruby is still required; CGI not needed)
|
27
|
+
#
|
28
|
+
# --conf_location, -u [conf_location]:
|
29
|
+
# location (filesystem path) of your svn_wc.conf file (readable by 'httpd
|
30
|
+
# runs as' owner)
|
31
|
+
#
|
32
|
+
# --copy_conf_from, -f [copy_conf_from]:
|
33
|
+
# move your conf file (svn_conf.yaml) from filesystem path to
|
34
|
+
# (copy_conf_to)
|
35
|
+
#
|
36
|
+
# --copy_conf_to, -t [copy_conf_to]:
|
37
|
+
# move your conf file (svn_conf.yaml) to filesystem path from
|
38
|
+
# (copy_conf_from)
|
39
|
+
#
|
40
|
+
#
|
41
|
+
# Example:
|
42
|
+
# svn_wc_tree --html /var/htdocs --cgi /var/cgi-bin \
|
43
|
+
# --post_to_url 'http://example.com/cgi-bin/' \
|
44
|
+
# --conf_location /opt/conf/svn_conf.yaml
|
45
|
+
#
|
46
|
+
# sudo svn_wc_tree --html /var/htdocs --php true \
|
47
|
+
# --conf_location /opt/svn_wc_tree/svn_conf.yaml
|
48
|
+
#
|
49
|
+
# sudo svn_wc_tree --html /var/www --cgi /usr/lib/cgi-bin \
|
50
|
+
# --post_to_url 'http://localhost/cgi-bin/' --copy_conf_from \
|
51
|
+
# /tmp/svn_conf.yaml --copy_conf_to /usr/local/svn_wc_tree
|
52
|
+
|
53
|
+
def setup
|
54
|
+
@conf = {
|
55
|
+
#"svn_repo_master" => "svn+ssh://localhost/home/dwright/svnrepo",
|
56
|
+
"svn_repo_master" => "file://#{Dir.mktmpdir('R')}",
|
57
|
+
#"svn_user" => "svn_test_user",
|
58
|
+
#"svn_pass" => "svn_test_pass",
|
59
|
+
"svn_repo_working_copy" => "#{Dir.mktmpdir('F')}",
|
60
|
+
"svn_repo_config_path" => Dir.mktmpdir('N')
|
61
|
+
}
|
62
|
+
#@conf_file = new_unique_file_at_path(Dir.mktmpdir('C'))
|
63
|
+
@conf_file = Tempfile.new(%w(conf_ .yaml)).path
|
64
|
+
File.open(@conf_file, 'w') {|fl| fl.write YAML::dump(@conf) }
|
65
|
+
end
|
66
|
+
|
67
|
+
def teardown
|
68
|
+
FileUtils.rm_r @html_dir if @html_dir
|
69
|
+
FileUtils.rm_r @cgi_dir if @cgi_dir
|
70
|
+
#FileUtils.rm_r @conf_file
|
71
|
+
end
|
72
|
+
|
73
|
+
def test_no_arg
|
74
|
+
assert `#{INSTALLER}`.match('Required argument missing')
|
75
|
+
end
|
76
|
+
|
77
|
+
def test_help
|
78
|
+
opt = '--help'
|
79
|
+
#assert `#{INSTALLER} #{opt}`.grep(/Usage\n-----\nsvn_wc_tree \[OPTIONS\]/)[0]
|
80
|
+
assert `#{INSTALLER} #{opt}`.match('svn_wc_tree: install the svn_wc_tree web application.')
|
81
|
+
opt = '-h'
|
82
|
+
assert `#{INSTALLER} #{opt}`.match('svn_wc_tree: install the svn_wc_tree web application.')
|
83
|
+
end
|
84
|
+
|
85
|
+
def test_missing_required_arg
|
86
|
+
opt = '--php true'
|
87
|
+
assert `#{INSTALLER} #{opt}`.match('Required argument missing')
|
88
|
+
end
|
89
|
+
|
90
|
+
def test_required_arg_empty
|
91
|
+
opt = '--html ""'
|
92
|
+
assert `#{INSTALLER} #{opt}`.match('path cannot be empty!')
|
93
|
+
end
|
94
|
+
|
95
|
+
def test_most_basic_install_non_functional__no_php_no_cgi_no_conf
|
96
|
+
@html_dir = Dir.mktmpdir('H')
|
97
|
+
|
98
|
+
assert !File.directory?(File.join(@html_dir, 'svn_wc_tree'))
|
99
|
+
|
100
|
+
opt = "--html #{@html_dir}"
|
101
|
+
# no output, is success
|
102
|
+
assert `#{INSTALLER} #{opt}`.empty?
|
103
|
+
|
104
|
+
# created dir at target location
|
105
|
+
assert File.directory?(File.join(@html_dir, 'svn_wc_tree'))
|
106
|
+
assert File.file?(File.join(@html_dir, 'svn_wc_tree', 'index.html'))
|
107
|
+
assert File.file?(File.join(@html_dir, 'svn_wc_tree', 'js', 'swt.js'))
|
108
|
+
end
|
109
|
+
|
110
|
+
def test_basic_install_functional__no_php_no_cgi_no_conf_POST_to_other_resource
|
111
|
+
@html_dir = Dir.mktmpdir('H')
|
112
|
+
|
113
|
+
assert !File.directory?(File.join(@html_dir, 'svn_wc_tree'))
|
114
|
+
|
115
|
+
opts = "--html #{@html_dir} --post_to_url '/svn/svn_controller'"
|
116
|
+
|
117
|
+
# no output, is success
|
118
|
+
assert `#{INSTALLER} #{opts}`.empty?
|
119
|
+
|
120
|
+
# created dir at target location
|
121
|
+
assert File.directory?(File.join(@html_dir, 'svn_wc_tree'))
|
122
|
+
assert File.file?(File.join(@html_dir, 'svn_wc_tree', 'index.html'))
|
123
|
+
js_file = File.join(@html_dir, 'svn_wc_tree', 'js', 'swt.js')
|
124
|
+
assert File.file? js_file
|
125
|
+
|
126
|
+
is_ok = false
|
127
|
+
File.readlines(js_file).each do |line|
|
128
|
+
if line.grep(/var POST_URL = '\/svn\/svn_controller';/)[0]
|
129
|
+
is_ok = true
|
130
|
+
break
|
131
|
+
end
|
132
|
+
end
|
133
|
+
assert is_ok
|
134
|
+
end
|
135
|
+
|
136
|
+
# works but doesn't make sense,...
|
137
|
+
# conf file must be added by hand to the POST resource
|
138
|
+
|
139
|
+
# why would you want this combination?
|
140
|
+
def test_conf_path_not_written_anywhere__install_no_php_no_cgi
|
141
|
+
@html_dir = Dir.mktmpdir('H')
|
142
|
+
|
143
|
+
assert File.file?(@conf_file)
|
144
|
+
assert !File.directory?(File.join(@html_dir, 'svn_wc_tree'))
|
145
|
+
|
146
|
+
opts = "--html #{@html_dir} --post_to_url '/svn/svn_controller' "
|
147
|
+
opts << "--conf_location #{@conf_file}"
|
148
|
+
|
149
|
+
# no output, is success
|
150
|
+
assert `#{INSTALLER} #{opts}`.empty?
|
151
|
+
|
152
|
+
# created dir at target location
|
153
|
+
assert File.directory?(File.join(@html_dir, 'svn_wc_tree'))
|
154
|
+
assert File.file?(File.join(@html_dir, 'svn_wc_tree', 'index.html'))
|
155
|
+
js_file = File.join(@html_dir, 'svn_wc_tree', 'js', 'swt.js')
|
156
|
+
assert File.file? js_file
|
157
|
+
|
158
|
+
is_ok = false
|
159
|
+
File.readlines(js_file).each do |line|
|
160
|
+
if line.grep(/var POST_URL = '\/svn\/svn_controller';/)[0]
|
161
|
+
is_ok = true
|
162
|
+
break
|
163
|
+
end
|
164
|
+
end
|
165
|
+
assert is_ok
|
166
|
+
end
|
167
|
+
|
168
|
+
def test_default_js_file_POST_url_is_empty
|
169
|
+
js_file = File.join(File.dirname(__FILE__), "..",
|
170
|
+
'svn_wc_tree', 'js', 'swt.js')
|
171
|
+
assert File.file? js_file
|
172
|
+
|
173
|
+
is_ok = false
|
174
|
+
File.readlines(js_file).each do |line|
|
175
|
+
if line.grep(/var POST_URL = '';/)[0]
|
176
|
+
is_ok = true
|
177
|
+
break
|
178
|
+
end
|
179
|
+
end
|
180
|
+
assert is_ok
|
181
|
+
end
|
182
|
+
|
183
|
+
def test_default_cgi_file_POST_url_is_empty
|
184
|
+
cgi_file = File.join('..', 'cgi', 'svn_wc_broker.cgi')
|
185
|
+
cgi_file = File.join(File.dirname(__FILE__), "..", 'cgi',
|
186
|
+
'svn_wc_broker.cgi')
|
187
|
+
assert File.file? cgi_file
|
188
|
+
|
189
|
+
is_ok = false
|
190
|
+
is_ok2 = false
|
191
|
+
File.readlines(cgi_file).each do |line|
|
192
|
+
if line.grep(/CONF_FILE = nil/)[0]
|
193
|
+
is_ok = true
|
194
|
+
next
|
195
|
+
end
|
196
|
+
|
197
|
+
if line.grep(/print cgi.header/)[0]
|
198
|
+
is_ok2 = true
|
199
|
+
break
|
200
|
+
end
|
201
|
+
|
202
|
+
end
|
203
|
+
assert is_ok
|
204
|
+
assert is_ok2
|
205
|
+
end
|
206
|
+
|
207
|
+
# conf file must be added by hand to the POST resource (wherever that is)
|
208
|
+
def test_install_functional__php_no_conf
|
209
|
+
@html_dir = Dir.mktmpdir('H')
|
210
|
+
|
211
|
+
assert !File.directory?(File.join(@html_dir, 'svn_wc_tree'))
|
212
|
+
|
213
|
+
opts = "--html #{@html_dir} --php true"
|
214
|
+
|
215
|
+
# no output, is success
|
216
|
+
assert `#{INSTALLER} #{opts}`.empty?
|
217
|
+
|
218
|
+
# created dir at target location
|
219
|
+
assert File.directory?(File.join(@html_dir, 'svn_wc_tree'))
|
220
|
+
assert File.file?(File.join(@html_dir, 'svn_wc_tree', 'index.html'))
|
221
|
+
assert File.file?(File.join(@html_dir, 'svn_wc_tree', 'index.php'))
|
222
|
+
js_file = File.join(@html_dir, 'svn_wc_tree', 'js', 'swt.js')
|
223
|
+
assert File.file? js_file
|
224
|
+
|
225
|
+
is_ok = false
|
226
|
+
File.readlines(js_file).each do |line|
|
227
|
+
if line.grep(/var POST_URL = 'index.php';/)[0]
|
228
|
+
is_ok = true
|
229
|
+
break
|
230
|
+
end
|
231
|
+
end
|
232
|
+
assert is_ok
|
233
|
+
end
|
234
|
+
|
235
|
+
def test_install_functional__php_w_conf
|
236
|
+
@html_dir = Dir.mktmpdir('H')
|
237
|
+
|
238
|
+
assert !File.directory?(File.join(@html_dir, 'svn_wc_tree'))
|
239
|
+
|
240
|
+
opts = "--html #{@html_dir} --php true "
|
241
|
+
opts << "--conf_location #{@conf_file}"
|
242
|
+
|
243
|
+
# no output, is success
|
244
|
+
assert `#{INSTALLER} #{opts}`.empty?
|
245
|
+
|
246
|
+
# created dir at target location
|
247
|
+
assert File.directory?(File.join(@html_dir, 'svn_wc_tree'))
|
248
|
+
assert File.file?(File.join(@html_dir, 'svn_wc_tree', 'index.html'))
|
249
|
+
assert File.file?(File.join(@html_dir, 'svn_wc_tree', 'index.php'))
|
250
|
+
js_file = File.join(@html_dir, 'svn_wc_tree', 'js', 'swt.js')
|
251
|
+
cgi_file = File.join(@html_dir, 'svn_wc_tree', 'svn_wc_broker.cgi')
|
252
|
+
assert File.file? js_file
|
253
|
+
assert File.file? cgi_file
|
254
|
+
|
255
|
+
is_ok = false
|
256
|
+
File.readlines(js_file).each do |line|
|
257
|
+
if line.grep(/var POST_URL = 'index.php';/)[0]
|
258
|
+
is_ok = true
|
259
|
+
break
|
260
|
+
end
|
261
|
+
end
|
262
|
+
assert is_ok
|
263
|
+
|
264
|
+
is_ok = false
|
265
|
+
is_ok2 = false
|
266
|
+
File.readlines(cgi_file).each do |line|
|
267
|
+
if line.grep(/CONF_FILE = '#{@conf_file}'/)[0]
|
268
|
+
is_ok = true
|
269
|
+
next
|
270
|
+
end
|
271
|
+
if line.grep(/#print cgi.header/)[0]
|
272
|
+
is_ok2 = true
|
273
|
+
break
|
274
|
+
end
|
275
|
+
end
|
276
|
+
assert is_ok
|
277
|
+
assert is_ok2
|
278
|
+
end
|
279
|
+
|
280
|
+
def test_install_functional__cgi_w_conf
|
281
|
+
@html_dir = Dir.mktmpdir('H')
|
282
|
+
@cgi_dir = Dir.mktmpdir('C')
|
283
|
+
|
284
|
+
assert !File.directory?(File.join(@html_dir, 'svn_wc_tree'))
|
285
|
+
|
286
|
+
opts = "--html #{@html_dir} --cgi #{@cgi_dir} --conf_location #{@conf_file} "
|
287
|
+
opts << "--post_to_url 'http://example.com/cgi-bin/'"
|
288
|
+
|
289
|
+
# no output, is success
|
290
|
+
assert `#{INSTALLER} #{opts}`.empty?
|
291
|
+
|
292
|
+
# created dir at target location
|
293
|
+
assert File.directory?(File.join(@html_dir, 'svn_wc_tree'))
|
294
|
+
assert File.file?(File.join(@html_dir, 'svn_wc_tree', 'index.html'))
|
295
|
+
# is still copied over, do we want that, if not needed?
|
296
|
+
assert File.file?(File.join(@html_dir, 'svn_wc_tree', 'index.php'))
|
297
|
+
# not php mode, so not copied to html/php dir
|
298
|
+
assert !File.file?(File.join(@html_dir, 'svn_wc_tree', 'svn_wc_broker.cgi'))
|
299
|
+
|
300
|
+
js_file = File.join(@html_dir, 'svn_wc_tree', 'js', 'swt.js')
|
301
|
+
cgi_file = File.join(@cgi_dir, 'svn_wc_broker.cgi')
|
302
|
+
assert File.file? js_file
|
303
|
+
assert File.file? cgi_file
|
304
|
+
|
305
|
+
is_ok = false
|
306
|
+
File.readlines(js_file).each do |line|
|
307
|
+
if line.grep(/var POST_URL = 'http:\/\/example.com\/cgi-bin\/';/)[0]
|
308
|
+
is_ok = true
|
309
|
+
break
|
310
|
+
end
|
311
|
+
end
|
312
|
+
assert is_ok
|
313
|
+
|
314
|
+
is_ok = false
|
315
|
+
File.readlines(cgi_file).each do |line|
|
316
|
+
if line.grep(/CONF_FILE = '#{@conf_file}'/)[0]
|
317
|
+
is_ok = true
|
318
|
+
break
|
319
|
+
end
|
320
|
+
end
|
321
|
+
assert is_ok
|
322
|
+
end
|
323
|
+
|
324
|
+
# TODO
|
325
|
+
#def test_cgi_precendence_over_php_if_both_set
|
326
|
+
# try mis-matched opts
|
327
|
+
|
328
|
+
def test_install_functional_cgi_all_opts
|
329
|
+
@html_dir = Dir.mktmpdir('H')
|
330
|
+
@cgi_dir = Dir.mktmpdir('C')
|
331
|
+
@conf_to = Dir.mktmpdir('F')
|
332
|
+
|
333
|
+
@new_conf = File.join(@conf_to, File.basename(@conf_file))
|
334
|
+
|
335
|
+
assert !File.directory?(File.join(@html_dir, 'svn_wc_tree'))
|
336
|
+
assert File.file?(@conf_file)
|
337
|
+
assert !File.file?(@new_conf)
|
338
|
+
|
339
|
+
opts = "--html #{@html_dir} --cgi #{@cgi_dir} "
|
340
|
+
opts << "--post_to_url 'http://example.com/cgi-bin/' "
|
341
|
+
opts << "--copy_conf_from #{@conf_file} "
|
342
|
+
opts << "--copy_conf_to #{@conf_to} "
|
343
|
+
opts << "--conf_location #{@new_conf} "
|
344
|
+
|
345
|
+
# no output, is success
|
346
|
+
assert `#{INSTALLER} #{opts}`.empty?
|
347
|
+
|
348
|
+
# created dir at target location
|
349
|
+
assert File.directory?(File.join(@html_dir, 'svn_wc_tree'))
|
350
|
+
assert File.file?(File.join(@html_dir, 'svn_wc_tree', 'index.html'))
|
351
|
+
assert File.directory?(@conf_to)
|
352
|
+
|
353
|
+
js_file = File.join(@html_dir, 'svn_wc_tree', 'js', 'swt.js')
|
354
|
+
cgi_file = File.join(@cgi_dir, 'svn_wc_broker.cgi')
|
355
|
+
assert File.file? js_file
|
356
|
+
assert File.file? cgi_file
|
357
|
+
|
358
|
+
assert File.file?(@conf_file)
|
359
|
+
assert File.file?(@new_conf)
|
360
|
+
|
361
|
+
is_ok = false
|
362
|
+
File.readlines(js_file).each do |line|
|
363
|
+
if line.grep(/var POST_URL = 'http:\/\/example.com\/cgi-bin\/';/)[0]
|
364
|
+
is_ok = true
|
365
|
+
break
|
366
|
+
end
|
367
|
+
end
|
368
|
+
assert is_ok
|
369
|
+
|
370
|
+
is_ok = false
|
371
|
+
File.readlines(cgi_file).each do |line|
|
372
|
+
if line.grep(/CONF_FILE = '#{@new_conf}'/)[0]
|
373
|
+
is_ok = true
|
374
|
+
break
|
375
|
+
end
|
376
|
+
|
377
|
+
if line.grep(/print cgi.header/)[0]
|
378
|
+
is_ok = true
|
379
|
+
break
|
380
|
+
end
|
381
|
+
end
|
382
|
+
assert is_ok
|
383
|
+
end
|
384
|
+
|
385
|
+
|
386
|
+
end
|
387
|
+
|
388
|
+
|
389
|
+
if VERSION < '1.8.7'
|
390
|
+
# File lib/tmpdir.rb, line 99
|
391
|
+
def Dir.mktmpdir(prefix_suffix=nil, tmpdir=nil)
|
392
|
+
case prefix_suffix
|
393
|
+
when nil
|
394
|
+
prefix = "d"
|
395
|
+
suffix = ""
|
396
|
+
when String
|
397
|
+
prefix = prefix_suffix
|
398
|
+
suffix = ""
|
399
|
+
when Array
|
400
|
+
prefix = prefix_suffix[0]
|
401
|
+
suffix = prefix_suffix[1]
|
402
|
+
else
|
403
|
+
raise ArgumentError, "unexpected prefix_suffix: #{prefix_suffix.inspect}"
|
404
|
+
end
|
405
|
+
tmpdir ||= Dir.tmpdir
|
406
|
+
t = Time.now.strftime("%Y%m%d")
|
407
|
+
n = nil
|
408
|
+
begin
|
409
|
+
path = "#{tmpdir}/#{prefix}#{t}-#{$$}-#{rand(0x100000000).to_s(36)}"
|
410
|
+
path << "-#{n}" if n
|
411
|
+
path << suffix
|
412
|
+
Dir.mkdir(path, 0700)
|
413
|
+
rescue Errno::EEXIST
|
414
|
+
n ||= 0
|
415
|
+
n += 1
|
416
|
+
retry
|
417
|
+
end
|
418
|
+
|
419
|
+
if block_given?
|
420
|
+
begin
|
421
|
+
yield path
|
422
|
+
ensure
|
423
|
+
FileUtils.rm_r path
|
424
|
+
end
|
425
|
+
else
|
426
|
+
path
|
427
|
+
end
|
428
|
+
end
|
429
|
+
end
|
430
|
+
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: svn_wc_tree
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 21
|
4
5
|
prerelease: false
|
5
6
|
segments:
|
6
7
|
- 0
|
7
8
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
9
|
+
- 5
|
10
|
+
version: 0.0.5
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- David Wright
|
@@ -14,7 +15,7 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2010-
|
18
|
+
date: 2010-10-12 00:00:00 -07:00
|
18
19
|
default_executable:
|
19
20
|
dependencies: []
|
20
21
|
|
@@ -34,6 +35,7 @@ files:
|
|
34
35
|
- ChangeLog
|
35
36
|
- lib/svn_wc_broker.rb
|
36
37
|
- lib/svn_wc_client.rb
|
38
|
+
- tests/test_installer_bin.rb
|
37
39
|
- LICENSE
|
38
40
|
- Manifest
|
39
41
|
- README.rdoc
|
@@ -42,7 +44,6 @@ files:
|
|
42
44
|
- svn_wc_tree/img/swt_spinner.gif
|
43
45
|
- svn_wc_tree/index.html
|
44
46
|
- svn_wc_tree/index.php
|
45
|
-
- svn_wc_tree.conf
|
46
47
|
- svn_wc_tree/js/swt.js
|
47
48
|
- svn_wc_tree/js/jquery-1.3.2.js
|
48
49
|
- svn_wc_tree/js/jquery.blockUI-2.31.js
|
@@ -96,23 +97,27 @@ rdoc_options: []
|
|
96
97
|
require_paths:
|
97
98
|
- lib
|
98
99
|
required_ruby_version: !ruby/object:Gem::Requirement
|
100
|
+
none: false
|
99
101
|
requirements:
|
100
102
|
- - ">="
|
101
103
|
- !ruby/object:Gem::Version
|
104
|
+
hash: 3
|
102
105
|
segments:
|
103
106
|
- 0
|
104
107
|
version: "0"
|
105
108
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
109
|
+
none: false
|
106
110
|
requirements:
|
107
111
|
- - ">="
|
108
112
|
- !ruby/object:Gem::Version
|
113
|
+
hash: 3
|
109
114
|
segments:
|
110
115
|
- 0
|
111
116
|
version: "0"
|
112
117
|
requirements: []
|
113
118
|
|
114
119
|
rubyforge_project:
|
115
|
-
rubygems_version: 1.3.
|
120
|
+
rubygems_version: 1.3.7
|
116
121
|
signing_key:
|
117
122
|
specification_version: 3
|
118
123
|
summary: svn_wc_tree is a web application (GUI) that enables basic operations on a working copy of a Subversion repository.
|