Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
O
OHR Support
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
97
Issues
97
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
OHR Support
Commits
86faa88e
Commit
86faa88e
authored
Mar 27, 2011
by
Eric Davis
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'ticket/master/225-upstream-scm'
parents
8d6133f6
6d0fcf55
Show whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
346 additions
and
201 deletions
+346
-201
.gitignore
.gitignore
+2
-0
.hgignore
.hgignore
+2
-0
repositories_controller.rb
app/controllers/repositories_controller.rb
+19
-18
abstract_adapter.rb
lib/redmine/scm/adapters/abstract_adapter.rb
+22
-10
bazaar_adapter.rb
lib/redmine/scm/adapters/bazaar_adapter.rb
+24
-14
cvs_adapter.rb
lib/redmine/scm/adapters/cvs_adapter.rb
+45
-34
darcs_adapter.rb
lib/redmine/scm/adapters/darcs_adapter.rb
+23
-15
filesystem_adapter.rb
lib/redmine/scm/adapters/filesystem_adapter.rb
+6
-1
git_adapter.rb
lib/redmine/scm/adapters/git_adapter.rb
+24
-10
mercurial_adapter.rb
lib/redmine/scm/adapters/mercurial_adapter.rb
+21
-9
subversion_adapter.rb
lib/redmine/scm/adapters/subversion_adapter.rb
+28
-20
testing.rake
lib/tasks/testing.rake
+2
-1
bazaar_adapter_test.rb
test/unit/lib/redmine/scm/adapters/bazaar_adapter_test.rb
+25
-0
cvs_adapter_test.rb
test/unit/lib/redmine/scm/adapters/cvs_adapter_test.rb
+1
-0
git_adapter_test.rb
test/unit/lib/redmine/scm/adapters/git_adapter_test.rb
+82
-61
subversion_adapter_test.rb
.../unit/lib/redmine/scm/adapters/subversion_adapter_test.rb
+20
-8
No files found.
.gitignore
View file @
86faa88e
/.project
/.loadpath
/config/additional_environment.rb
/config/additional_environment.rb
/config/configuration.yml
/config/configuration.yml
/config/database.yml
/config/database.yml
...
...
.hgignore
View file @
86faa88e
syntax: glob
syntax: glob
.project
.loadpath
config/additional_environment.rb
config/additional_environment.rb
config/configuration.yml
config/configuration.yml
config/database.yml
config/database.yml
...
...
app/controllers/repositories_controller.rb
View file @
86faa88e
...
@@ -122,9 +122,10 @@ class RepositoriesController < ApplicationController
...
@@ -122,9 +122,10 @@ class RepositoriesController < ApplicationController
@content
=
@repository
.
cat
(
@path
,
@rev
)
@content
=
@repository
.
cat
(
@path
,
@rev
)
(
show_error_not_found
;
return
)
unless
@content
(
show_error_not_found
;
return
)
unless
@content
if
'raw'
==
params
[
:format
]
||
@content
.
is_binary_data?
||
(
@entry
.
size
&&
@entry
.
size
>
Setting
.
file_max_size_displayed
.
to_i
.
kilobyte
)
if
'raw'
==
params
[
:format
]
||
@content
.
is_binary_data?
||
(
@entry
.
size
&&
@entry
.
size
>
Setting
.
file_max_size_displayed
.
to_i
.
kilobyte
)
# Force the download
# Force the download
send_data
@content
,
:filename
=>
@path
.
split
(
'/'
).
last
send_data
@content
,
:filename
=>
filename_for_content_disposition
(
@path
.
split
(
'/'
).
last
)
else
else
# Prevent empty lines when displaying a file with Windows style eol
# Prevent empty lines when displaying a file with Windows style eol
@content
.
gsub!
(
"
\r\n
"
,
"
\n
"
)
@content
.
gsub!
(
"
\r\n
"
,
"
\n
"
)
...
...
lib/redmine/scm/adapters/abstract_adapter.rb
View file @
86faa88e
...
@@ -25,6 +25,10 @@ module Redmine
...
@@ -25,6 +25,10 @@ module Redmine
class
AbstractAdapter
#:nodoc:
class
AbstractAdapter
#:nodoc:
class
<<
self
class
<<
self
def
client_command
""
end
# Returns the version of the scm client
# Returns the version of the scm client
# Eg: [1, 5, 0] or [] if unknown
# Eg: [1, 5, 0] or [] if unknown
def
client_version
def
client_version
...
@@ -45,6 +49,18 @@ module Redmine
...
@@ -45,6 +49,18 @@ module Redmine
def
client_version_above?
(
v
,
options
=
{})
def
client_version_above?
(
v
,
options
=
{})
((
client_version
<=>
v
)
>=
0
)
||
(
client_version
.
empty?
&&
options
[
:unknown
])
((
client_version
<=>
v
)
>=
0
)
||
(
client_version
.
empty?
&&
options
[
:unknown
])
end
end
def
client_available
true
end
def
shell_quote
(
str
)
if
Redmine
::
Platform
.
mswin?
'"'
+
str
.
gsub
(
/"/
,
'\\"'
)
+
'"'
else
"'"
+
str
.
gsub
(
/'/
,
"'
\"
'
\"
'"
)
+
"'"
end
end
end
end
def
initialize
(
url
,
root_url
=
nil
,
login
=
nil
,
password
=
nil
)
def
initialize
(
url
,
root_url
=
nil
,
login
=
nil
,
password
=
nil
)
...
@@ -150,11 +166,7 @@ module Redmine
...
@@ -150,11 +166,7 @@ module Redmine
end
end
def
shell_quote
(
str
)
def
shell_quote
(
str
)
if
Redmine
::
Platform
.
mswin?
self
.
class
.
shell_quote
(
str
)
'"'
+
str
.
gsub
(
/"/
,
'\\"'
)
+
'"'
else
"'"
+
str
.
gsub
(
/'/
,
"'
\"
'
\"
'"
)
+
"'"
end
end
end
private
private
...
...
lib/redmine/scm/adapters/bazaar_adapter.rb
View file @
86faa88e
...
@@ -25,9 +25,19 @@ module Redmine
...
@@ -25,9 +25,19 @@ module Redmine
# Bazaar executable name
# Bazaar executable name
BZR_BIN
=
Redmine
::
Configuration
[
'scm_bazaar_command'
]
||
"bzr"
BZR_BIN
=
Redmine
::
Configuration
[
'scm_bazaar_command'
]
||
"bzr"
class
<<
self
def
client_command
@@bin
||=
BZR_BIN
end
def
sq_bin
@@sq_bin
||=
shell_quote
(
BZR_BIN
)
end
end
# Get info about the repository
# Get info about the repository
def
info
def
info
cmd
=
"
#{
BZR_BIN
}
revno
#{
target
(
''
)
}
"
cmd
=
"
#{
self
.
class
.
sq_bin
}
revno
#{
target
(
''
)
}
"
info
=
nil
info
=
nil
shellout
(
cmd
)
do
|
io
|
shellout
(
cmd
)
do
|
io
|
if
io
.
read
=~
%r{^(
\d
+)
\r
?$}
if
io
.
read
=~
%r{^(
\d
+)
\r
?$}
...
@@ -49,7 +59,7 @@ module Redmine
...
@@ -49,7 +59,7 @@ module Redmine
def
entries
(
path
=
nil
,
identifier
=
nil
)
def
entries
(
path
=
nil
,
identifier
=
nil
)
path
||=
''
path
||=
''
entries
=
Entries
.
new
entries
=
Entries
.
new
cmd
=
"
#{
BZR_BIN
}
ls -v --show-ids"
cmd
=
"
#{
self
.
class
.
sq_bin
}
ls -v --show-ids"
identifier
=
-
1
unless
identifier
&&
identifier
.
to_i
>
0
identifier
=
-
1
unless
identifier
&&
identifier
.
to_i
>
0
cmd
<<
" -r
#{
identifier
.
to_i
}
"
cmd
<<
" -r
#{
identifier
.
to_i
}
"
cmd
<<
"
#{
target
(
path
)
}
"
cmd
<<
"
#{
target
(
path
)
}
"
...
@@ -77,7 +87,7 @@ module Redmine
...
@@ -77,7 +87,7 @@ module Redmine
identifier_from
=
(
identifier_from
and
identifier_from
.
to_i
>
0
)
?
identifier_from
.
to_i
:
'last:1'
identifier_from
=
(
identifier_from
and
identifier_from
.
to_i
>
0
)
?
identifier_from
.
to_i
:
'last:1'
identifier_to
=
(
identifier_to
and
identifier_to
.
to_i
>
0
)
?
identifier_to
.
to_i
:
1
identifier_to
=
(
identifier_to
and
identifier_to
.
to_i
>
0
)
?
identifier_to
.
to_i
:
1
revisions
=
Revisions
.
new
revisions
=
Revisions
.
new
cmd
=
"
#{
BZR_BIN
}
log -v --show-ids -r
#{
identifier_to
}
..
#{
identifier_from
}
#{
target
(
path
)
}
"
cmd
=
"
#{
self
.
class
.
sq_bin
}
log -v --show-ids -r
#{
identifier_to
}
..
#{
identifier_from
}
#{
target
(
path
)
}
"
shellout
(
cmd
)
do
|
io
|
shellout
(
cmd
)
do
|
io
|
revision
=
nil
revision
=
nil
parsing
=
nil
parsing
=
nil
...
@@ -143,7 +153,7 @@ module Redmine
...
@@ -143,7 +153,7 @@ module Redmine
if
identifier_from
if
identifier_from
identifier_from
=
identifier_from
.
to_i
identifier_from
=
identifier_from
.
to_i
end
end
cmd
=
"
#{
BZR_BIN
}
diff -r
#{
identifier_to
}
..
#{
identifier_from
}
#{
target
(
path
)
}
"
cmd
=
"
#{
self
.
class
.
sq_bin
}
diff -r
#{
identifier_to
}
..
#{
identifier_from
}
#{
target
(
path
)
}
"
diff
=
[]
diff
=
[]
shellout
(
cmd
)
do
|
io
|
shellout
(
cmd
)
do
|
io
|
io
.
each_line
do
|
line
|
io
.
each_line
do
|
line
|
...
@@ -155,7 +165,7 @@ module Redmine
...
@@ -155,7 +165,7 @@ module Redmine
end
end
def
cat
(
path
,
identifier
=
nil
)
def
cat
(
path
,
identifier
=
nil
)
cmd
=
"
#{
BZR_BIN
}
cat"
cmd
=
"
#{
self
.
class
.
sq_bin
}
cat"
cmd
<<
" -r
#{
identifier
.
to_i
}
"
if
identifier
&&
identifier
.
to_i
>
0
cmd
<<
" -r
#{
identifier
.
to_i
}
"
if
identifier
&&
identifier
.
to_i
>
0
cmd
<<
"
#{
target
(
path
)
}
"
cmd
<<
"
#{
target
(
path
)
}
"
cat
=
nil
cat
=
nil
...
@@ -168,7 +178,7 @@ module Redmine
...
@@ -168,7 +178,7 @@ module Redmine
end
end
def
annotate
(
path
,
identifier
=
nil
)
def
annotate
(
path
,
identifier
=
nil
)
cmd
=
"
#{
BZR_BIN
}
annotate --all"
cmd
=
"
#{
self
.
class
.
sq_bin
}
annotate --all"
cmd
<<
" -r
#{
identifier
.
to_i
}
"
if
identifier
&&
identifier
.
to_i
>
0
cmd
<<
" -r
#{
identifier
.
to_i
}
"
if
identifier
&&
identifier
.
to_i
>
0
cmd
<<
"
#{
target
(
path
)
}
"
cmd
<<
"
#{
target
(
path
)
}
"
blame
=
Annotate
.
new
blame
=
Annotate
.
new
...
...
lib/redmine/scm/adapters/cvs_adapter.rb
View file @
86faa88e
...
@@ -25,6 +25,16 @@ module Redmine
...
@@ -25,6 +25,16 @@ module Redmine
# CVS executable name
# CVS executable name
CVS_BIN
=
Redmine
::
Configuration
[
'scm_cvs_command'
]
||
"cvs"
CVS_BIN
=
Redmine
::
Configuration
[
'scm_cvs_command'
]
||
"cvs"
class
<<
self
def
client_command
@@bin
||=
CVS_BIN
end
def
sq_bin
@@sq_bin
||=
shell_quote
(
CVS_BIN
)
end
end
# Guidelines for the input:
# Guidelines for the input:
# url -> the project-path, relative to the cvsroot (eg. module name)
# url -> the project-path, relative to the cvsroot (eg. module name)
# root_url -> the good old, sometimes damned, CVSROOT
# root_url -> the good old, sometimes damned, CVSROOT
...
@@ -63,7 +73,7 @@ module Redmine
...
@@ -63,7 +73,7 @@ module Redmine
logger
.
debug
"<cvs> entries '
#{
path
}
' with identifier '
#{
identifier
}
'"
logger
.
debug
"<cvs> entries '
#{
path
}
' with identifier '
#{
identifier
}
'"
path_with_project
=
"
#{
url
}#{
with_leading_slash
(
path
)
}
"
path_with_project
=
"
#{
url
}#{
with_leading_slash
(
path
)
}
"
entries
=
Entries
.
new
entries
=
Entries
.
new
cmd
=
"
#{
CVS_BIN
}
-d
#{
shell_quote
root_url
}
rls -e"
cmd
=
"
#{
self
.
class
.
sq_bin
}
-d
#{
shell_quote
root_url
}
rls -e"
cmd
<<
" -D
\"
#{
time_to_cvstime
(
identifier
)
}
\"
"
if
identifier
cmd
<<
" -D
\"
#{
time_to_cvstime
(
identifier
)
}
\"
"
if
identifier
cmd
<<
"
#{
shell_quote
path_with_project
}
"
cmd
<<
"
#{
shell_quote
path_with_project
}
"
shellout
(
cmd
)
do
|
io
|
shellout
(
cmd
)
do
|
io
|
...
@@ -108,7 +118,7 @@ module Redmine
...
@@ -108,7 +118,7 @@ module Redmine
logger
.
debug
"<cvs> revisions path:'
#{
path
}
',identifier_from
#{
identifier_from
}
, identifier_to
#{
identifier_to
}
"
logger
.
debug
"<cvs> revisions path:'
#{
path
}
',identifier_from
#{
identifier_from
}
, identifier_to
#{
identifier_to
}
"
path_with_project
=
"
#{
url
}#{
with_leading_slash
(
path
)
}
"
path_with_project
=
"
#{
url
}#{
with_leading_slash
(
path
)
}
"
cmd
=
"
#{
CVS_BIN
}
-d
#{
shell_quote
root_url
}
rlog"
cmd
=
"
#{
self
.
class
.
sq_bin
}
-d
#{
shell_quote
root_url
}
rlog"
cmd
<<
" -d
\"
>
#{
time_to_cvstime_rlog
(
identifier_from
)
}
\"
"
if
identifier_from
cmd
<<
" -d
\"
>
#{
time_to_cvstime_rlog
(
identifier_from
)
}
\"
"
if
identifier_from
cmd
<<
"
#{
shell_quote
path_with_project
}
"
cmd
<<
"
#{
shell_quote
path_with_project
}
"
shellout
(
cmd
)
do
|
io
|
shellout
(
cmd
)
do
|
io
|
...
@@ -229,7 +239,7 @@ module Redmine
...
@@ -229,7 +239,7 @@ module Redmine
def
diff
(
path
,
identifier_from
,
identifier_to
=
nil
)
def
diff
(
path
,
identifier_from
,
identifier_to
=
nil
)
logger
.
debug
"<cvs> diff path:'
#{
path
}
',identifier_from
#{
identifier_from
}
, identifier_to
#{
identifier_to
}
"
logger
.
debug
"<cvs> diff path:'
#{
path
}
',identifier_from
#{
identifier_from
}
, identifier_to
#{
identifier_to
}
"
path_with_project
=
"
#{
url
}#{
with_leading_slash
(
path
)
}
"
path_with_project
=
"
#{
url
}#{
with_leading_slash
(
path
)
}
"
cmd
=
"
#{
CVS_BIN
}
-d
#{
shell_quote
root_url
}
rdiff -u -r
#{
identifier_to
}
-r
#{
identifier_from
}
#{
shell_quote
path_with_project
}
"
cmd
=
"
#{
self
.
class
.
sq_bin
}
-d
#{
shell_quote
root_url
}
rdiff -u -r
#{
identifier_to
}
-r
#{
identifier_from
}
#{
shell_quote
path_with_project
}
"
diff
=
[]
diff
=
[]
shellout
(
cmd
)
do
|
io
|
shellout
(
cmd
)
do
|
io
|
io
.
each_line
do
|
line
|
io
.
each_line
do
|
line
|
...
@@ -244,11 +254,12 @@ module Redmine
...
@@ -244,11 +254,12 @@ module Redmine
identifier
=
(
identifier
)
?
identifier
:
"HEAD"
identifier
=
(
identifier
)
?
identifier
:
"HEAD"
logger
.
debug
"<cvs> cat path:'
#{
path
}
',identifier
#{
identifier
}
"
logger
.
debug
"<cvs> cat path:'
#{
path
}
',identifier
#{
identifier
}
"
path_with_project
=
"
#{
url
}#{
with_leading_slash
(
path
)
}
"
path_with_project
=
"
#{
url
}#{
with_leading_slash
(
path
)
}
"
cmd
=
"
#{
CVS_BIN
}
-d
#{
shell_quote
root_url
}
co"
cmd
=
"
#{
self
.
class
.
sq_bin
}
-d
#{
shell_quote
root_url
}
co"
cmd
<<
" -D
\"
#{
time_to_cvstime
(
identifier
)
}
\"
"
if
identifier
cmd
<<
" -D
\"
#{
time_to_cvstime
(
identifier
)
}
\"
"
if
identifier
cmd
<<
" -p
#{
shell_quote
path_with_project
}
"
cmd
<<
" -p
#{
shell_quote
path_with_project
}
"
cat
=
nil
cat
=
nil
shellout
(
cmd
)
do
|
io
|
shellout
(
cmd
)
do
|
io
|
io
.
binmode
cat
=
io
.
read
cat
=
io
.
read
end
end
return
nil
if
$?
&&
$?
.
exitstatus
!=
0
return
nil
if
$?
&&
$?
.
exitstatus
!=
0
...
@@ -259,7 +270,7 @@ module Redmine
...
@@ -259,7 +270,7 @@ module Redmine
identifier
=
(
identifier
)
?
identifier
.
to_i
:
"HEAD"
identifier
=
(
identifier
)
?
identifier
.
to_i
:
"HEAD"
logger
.
debug
"<cvs> annotate path:'
#{
path
}
',identifier
#{
identifier
}
"
logger
.
debug
"<cvs> annotate path:'
#{
path
}
',identifier
#{
identifier
}
"
path_with_project
=
"
#{
url
}#{
with_leading_slash
(
path
)
}
"
path_with_project
=
"
#{
url
}#{
with_leading_slash
(
path
)
}
"
cmd
=
"
#{
CVS_BIN
}
-d
#{
shell_quote
root_url
}
rannotate -r
#{
identifier
}
#{
shell_quote
path_with_project
}
"
cmd
=
"
#{
self
.
class
.
sq_bin
}
-d
#{
shell_quote
root_url
}
rannotate -r
#{
identifier
}
#{
shell_quote
path_with_project
}
"
blame
=
Annotate
.
new
blame
=
Annotate
.
new
shellout
(
cmd
)
do
|
io
|
shellout
(
cmd
)
do
|
io
|
io
.
each_line
do
|
line
|
io
.
each_line
do
|
line
|
...
...
lib/redmine/scm/adapters/darcs_adapter.rb
View file @
86faa88e
...
@@ -26,6 +26,14 @@ module Redmine
...
@@ -26,6 +26,14 @@ module Redmine
DARCS_BIN
=
Redmine
::
Configuration
[
'scm_darcs_command'
]
||
"darcs"
DARCS_BIN
=
Redmine
::
Configuration
[
'scm_darcs_command'
]
||
"darcs"
class
<<
self
class
<<
self
def
client_command
@@bin
||=
DARCS_BIN
end
def
sq_bin
@@sq_bin
||=
shell_quote
(
DARCS_BIN
)
end
def
client_version
def
client_version
@@client_version
||=
(
darcs_binary_version
||
[])
@@client_version
||=
(
darcs_binary_version
||
[])
end
end
...
@@ -38,7 +46,7 @@ module Redmine
...
@@ -38,7 +46,7 @@ module Redmine
end
end
def
darcs_binary_version_from_command_line
def
darcs_binary_version_from_command_line
shellout
(
"
#{
DARCS_BIN
}
--version"
)
{
|
io
|
io
.
read
}.
to_s
shellout
(
"
#{
sq_bin
}
--version"
)
{
|
io
|
io
.
read
}.
to_s
end
end
end
end
...
@@ -66,7 +74,7 @@ module Redmine
...
@@ -66,7 +74,7 @@ module Redmine
path
=
(
self
.
class
.
client_version_above?
([
2
,
2
,
0
])
?
@url
:
'.'
)
path
=
(
self
.
class
.
client_version_above?
([
2
,
2
,
0
])
?
@url
:
'.'
)
end
end
entries
=
Entries
.
new
entries
=
Entries
.
new
cmd
=
"
#{
DARCS_BIN
}
annotate --repodir
#{
shell_quote
@url
}
--xml-output"
cmd
=
"
#{
self
.
class
.
sq_bin
}
annotate --repodir
#{
shell_quote
@url
}
--xml-output"
cmd
<<
" --match
#{
shell_quote
(
"hash
#{
identifier
}
"
)
}
"
if
identifier
cmd
<<
" --match
#{
shell_quote
(
"hash
#{
identifier
}
"
)
}
"
if
identifier
cmd
<<
"
#{
shell_quote
path
}
"
cmd
<<
"
#{
shell_quote
path
}
"
shellout
(
cmd
)
do
|
io
|
shellout
(
cmd
)
do
|
io
|
...
@@ -90,7 +98,7 @@ module Redmine
...
@@ -90,7 +98,7 @@ module Redmine
def
revisions
(
path
=
nil
,
identifier_from
=
nil
,
identifier_to
=
nil
,
options
=
{})
def
revisions
(
path
=
nil
,
identifier_from
=
nil
,
identifier_to
=
nil
,
options
=
{})
path
=
'.'
if
path
.
blank?
path
=
'.'
if
path
.
blank?
revisions
=
Revisions
.
new
revisions
=
Revisions
.
new
cmd
=
"
#{
DARCS_BIN
}
changes --repodir
#{
shell_quote
@url
}
--xml-output"
cmd
=
"
#{
self
.
class
.
sq_bin
}
changes --repodir
#{
shell_quote
@url
}
--xml-output"
cmd
<<
" --from-match
#{
shell_quote
(
"hash
#{
identifier_from
}
"
)
}
"
if
identifier_from
cmd
<<
" --from-match
#{
shell_quote
(
"hash
#{
identifier_from
}
"
)
}
"
if
identifier_from
cmd
<<
" --last
#{
options
[
:limit
].
to_i
}
"
if
options
[
:limit
]
cmd
<<
" --last
#{
options
[
:limit
].
to_i
}
"
if
options
[
:limit
]
shellout
(
cmd
)
do
|
io
|
shellout
(
cmd
)
do
|
io
|
...
@@ -116,7 +124,7 @@ module Redmine
...
@@ -116,7 +124,7 @@ module Redmine
def
diff
(
path
,
identifier_from
,
identifier_to
=
nil
)
def
diff
(
path
,
identifier_from
,
identifier_to
=
nil
)
path
=
'*'
if
path
.
blank?
path
=
'*'
if
path
.
blank?
cmd
=
"
#{
DARCS_BIN
}
diff --repodir
#{
shell_quote
@url
}
"
cmd
=
"
#{
self
.
class
.
sq_bin
}
diff --repodir
#{
shell_quote
@url
}
"
if
identifier_to
.
nil?
if
identifier_to
.
nil?
cmd
<<
" --match
#{
shell_quote
(
"hash
#{
identifier_from
}
"
)
}
"
cmd
<<
" --match
#{
shell_quote
(
"hash
#{
identifier_from
}
"
)
}
"
else
else
...
@@ -135,7 +143,7 @@ module Redmine
...
@@ -135,7 +143,7 @@ module Redmine
end
end
def
cat
(
path
,
identifier
=
nil
)
def
cat
(
path
,
identifier
=
nil
)
cmd
=
"
#{
DARCS_BIN
}
show content --repodir
#{
shell_quote
@url
}
"
cmd
=
"
#{
self
.
class
.
sq_bin
}
show content --repodir
#{
shell_quote
@url
}
"
cmd
<<
" --match
#{
shell_quote
(
"hash
#{
identifier
}
"
)
}
"
if
identifier
cmd
<<
" --match
#{
shell_quote
(
"hash
#{
identifier
}
"
)
}
"
if
identifier
cmd
<<
"
#{
shell_quote
path
}
"
cmd
<<
"
#{
shell_quote
path
}
"
cat
=
nil
cat
=
nil
...
@@ -199,7 +207,7 @@ module Redmine
...
@@ -199,7 +207,7 @@ module Redmine
# Retrieve changed paths for a single patch
# Retrieve changed paths for a single patch
def
get_paths_for_patch_raw
(
hash
)
def
get_paths_for_patch_raw
(
hash
)
cmd
=
"
#{
DARCS_BIN
}
annotate --repodir
#{
shell_quote
@url
}
--summary --xml-output"
cmd
=
"
#{
self
.
class
.
sq_bin
}
annotate --repodir
#{
shell_quote
@url
}
--summary --xml-output"
cmd
<<
" --match
#{
shell_quote
(
"hash
#{
hash
}
"
)
}
"
cmd
<<
" --match
#{
shell_quote
(
"hash
#{
hash
}
"
)
}
"
paths
=
[]
paths
=
[]
shellout
(
cmd
)
do
|
io
|
shellout
(
cmd
)
do
|
io
|
...
...
lib/redmine/scm/adapters/filesystem_adapter.rb
View file @
86faa88e
...
@@ -26,6 +26,11 @@ module Redmine
...
@@ -26,6 +26,11 @@ module Redmine
module
Adapters
module
Adapters
class
FilesystemAdapter
<
AbstractAdapter
class
FilesystemAdapter
<
AbstractAdapter
class
<<
self
def
client_available
true
end
end
def
initialize
(
url
,
root_url
=
nil
,
login
=
nil
,
password
=
nil
)
def
initialize
(
url
,
root_url
=
nil
,
login
=
nil
,
password
=
nil
)
@url
=
with_trailling_slash
(
url
)
@url
=
with_trailling_slash
(
url
)
...
...
lib/redmine/scm/adapters/git_adapter.rb
View file @
86faa88e
...
@@ -24,6 +24,20 @@ module Redmine
...
@@ -24,6 +24,20 @@ module Redmine
# Git executable name
# Git executable name
GIT_BIN
=
Redmine
::
Configuration
[
'scm_git_command'
]
||
"git"
GIT_BIN
=
Redmine
::
Configuration
[
'scm_git_command'
]
||
"git"
class
<<
self
def
client_command
@@bin
||=
GIT_BIN
end
def
sq_bin
@@sq_bin
||=
shell_quote
(
GIT_BIN
)
end
def
client_available
!
client_version
.
empty?
end
end
def
info
def
info
begin
begin
Info
.
new
(
:root_url
=>
url
,
:lastrev
=>
lastrev
(
''
,
nil
))
Info
.
new
(
:root_url
=>
url
,
:lastrev
=>
lastrev
(
''
,
nil
))
...
@@ -35,7 +49,7 @@ module Redmine
...
@@ -35,7 +49,7 @@ module Redmine
def
branches
def
branches
return
@branches
if
@branches
return
@branches
if
@branches
@branches
=
[]
@branches
=
[]
cmd
=
"
#{
GIT_BIN
}
--git-dir
#{
target
(
''
)
}
branch --no-color"
cmd
=
"
#{
self
.
class
.
sq_bin
}
--git-dir
#{
target
(
''
)
}
branch --no-color"
shellout
(
cmd
)
do
|
io
|
shellout
(
cmd
)
do
|
io
|
io
.
each_line
do
|
line
|
io
.
each_line
do
|
line
|
@branches
<<
line
.
match
(
'\s*\*?\s*(.*)$'
)[
1
]
@branches
<<
line
.
match
(
'\s*\*?\s*(.*)$'
)[
1
]
...
@@ -46,7 +60,7 @@ module Redmine
...
@@ -46,7 +60,7 @@ module Redmine
def
tags
def
tags
return
@tags
if
@tags
return
@tags
if
@tags
cmd
=
"
#{
GIT_BIN
}
--git-dir
#{
target
(
''
)
}
tag"
cmd
=
"
#{
self
.
class
.
sq_bin
}
--git-dir
#{
target
(
''
)
}
tag"
shellout
(
cmd
)
do
|
io
|
shellout
(
cmd
)
do
|
io
|
@tags
=
io
.
readlines
.
sort!
.
map
{
|
t
|
t
.
strip
}
@tags
=
io
.
readlines
.
sort!
.
map
{
|
t
|
t
.
strip
}
end
end
...
@@ -59,7 +73,7 @@ module Redmine
...
@@ -59,7 +73,7 @@ module Redmine
def
entries
(
path
=
nil
,
identifier
=
nil
)
def
entries
(
path
=
nil
,
identifier
=
nil
)
path
||=
''
path
||=
''
entries
=
Entries
.
new
entries
=
Entries
.
new
cmd
=
"
#{
GIT_BIN
}
--git-dir
#{
target
(
''
)
}
ls-tree -l "
cmd
=
"
#{
self
.
class
.
sq_bin
}
--git-dir
#{
target
(
''
)
}
ls-tree -l "
cmd
<<
shell_quote
(
"HEAD:"
+
path
)
if
identifier
.
nil?
cmd
<<
shell_quote
(
"HEAD:"
+
path
)
if
identifier
.
nil?
cmd
<<
shell_quote
(
identifier
+
":"
+
path
)
if
identifier
cmd
<<
shell_quote
(
identifier
+
":"
+
path
)
if
identifier
shellout
(
cmd
)
do
|
io
|
shellout
(
cmd
)
do
|
io
|
...
@@ -86,7 +100,7 @@ module Redmine
...
@@ -86,7 +100,7 @@ module Redmine
def
lastrev
(
path
,
rev
)
def
lastrev
(
path
,
rev
)
return
nil
if
path
.
nil?
return
nil
if
path
.
nil?
cmd
=
"
#{
GIT_BIN
}
--git-dir
#{
target
(
''
)
}
log --no-color --date=iso --pretty=fuller --no-merges -n 1 "
cmd
=
"
#{
self
.
class
.
sq_bin
}
--git-dir
#{
target
(
''
)
}
log --no-color --date=iso --pretty=fuller --no-merges -n 1 "
cmd
<<
"
#{
shell_quote
rev
}
"
if
rev
cmd
<<
"
#{
shell_quote
rev
}
"
if
rev
cmd
<<
"--
#{
shell_quote
path
}
"
unless
path
.
empty?
cmd
<<
"--
#{
shell_quote
path
}
"
unless
path
.
empty?
lines
=
[]
lines
=
[]
...
@@ -114,7 +128,7 @@ module Redmine
...
@@ -114,7 +128,7 @@ module Redmine
def
revisions
(
path
,
identifier_from
,
identifier_to
,
options
=
{})
def
revisions
(
path
,
identifier_from
,
identifier_to
,
options
=
{})
revisions
=
Revisions
.
new
revisions
=
Revisions
.
new
cmd
=
"
#{
GIT_BIN
}
--git-dir
#{
target
(
''
)
}
log --no-color --raw --date=iso --pretty=fuller "
cmd
=
"
#{
self
.
class
.
sq_bin
}
--git-dir
#{
target
(
''
)
}
log --no-color --raw --date=iso --pretty=fuller "
cmd
<<
" --reverse "
if
options
[
:reverse
]
cmd
<<
" --reverse "
if
options
[
:reverse
]
cmd
<<
" --all "
if
options
[
:all
]
cmd
<<
" --all "
if
options
[
:all
]
cmd
<<
" -n
#{
options
[
:limit
].
to_i
}
"
if
options
[
:limit
]
cmd
<<
" -n
#{
options
[
:limit
].
to_i
}
"
if
options
[
:limit
]
...
@@ -209,9 +223,9 @@ module Redmine
...
@@ -209,9 +223,9 @@ module Redmine
path
||=
''
path
||=
''
if
identifier_to
if
identifier_to
cmd
=
"
#{
GIT_BIN
}
--git-dir
#{
target
(
''
)
}
diff --no-color
#{
shell_quote
identifier_to
}
#{
shell_quote
identifier_from
}
"
cmd
=
"
#{
self
.
class
.
sq_bin
}
--git-dir
#{
target
(
''
)
}
diff --no-color
#{
shell_quote
identifier_to
}
#{
shell_quote
identifier_from
}
"
else
else
cmd
=
"
#{
GIT_BIN
}
--git-dir
#{
target
(
''
)
}
show --no-color
#{
shell_quote
identifier_from
}
"
cmd
=
"
#{
self
.
class
.
sq_bin
}
--git-dir
#{
target
(
''
)
}
show --no-color
#{
shell_quote
identifier_from
}
"
end
end
cmd
<<
" --
#{
shell_quote
path
}
"
unless
path
.
empty?
cmd
<<
" --
#{
shell_quote
path
}
"
unless
path
.
empty?
...
@@ -227,7 +241,7 @@ module Redmine
...
@@ -227,7 +241,7 @@ module Redmine
def
annotate
(
path
,
identifier
=
nil
)
def
annotate
(
path
,
identifier
=
nil
)
identifier
=
'HEAD'
if
identifier
.
blank?
identifier
=
'HEAD'
if
identifier
.
blank?
cmd
=
"
#{
GIT_BIN
}
--git-dir
#{
target
(
''
)
}
blame -p
#{
shell_quote
identifier
}
--
#{
shell_quote
path
}
"
cmd
=
"
#{
self
.
class
.
sq_bin
}
--git-dir
#{
target
(
''
)
}
blame -p
#{
shell_quote
identifier
}
--
#{
shell_quote
path
}
"
blame
=
Annotate
.
new
blame
=
Annotate
.
new
content
=
nil
content
=
nil
shellout
(
cmd
)
{
|
io
|
io
.
binmode
;
content
=
io
.
read
}
shellout
(
cmd
)
{
|
io
|
io
.
binmode
;
content
=
io
.
read
}
...
@@ -255,7 +269,7 @@ module Redmine
...
@@ -255,7 +269,7 @@ module Redmine
if
identifier
.
nil?
if
identifier
.
nil?
identifier
=
'HEAD'
identifier
=
'HEAD'
end
end
cmd
=
"
#{
GIT_BIN
}
--git-dir
#{
target
(
''
)
}
show --no-color
#{
shell_quote
(
identifier
+
':'
+
path
)
}
"
cmd
=
"
#{
self
.
class
.
sq_bin
}
--git-dir
#{
target
(
''
)
}
show --no-color
#{
shell_quote
(
identifier
+
':'
+
path
)
}
"
cat
=
nil
cat
=
nil
shellout
(
cmd
)
do
|
io
|
shellout
(
cmd
)
do
|
io
|
io
.
binmode
io
.
binmode
...
...
lib/redmine/scm/adapters/mercurial_adapter.rb
View file @
86faa88e
...
@@ -30,10 +30,22 @@ module Redmine
...
@@ -30,10 +30,22 @@ module Redmine
TEMPLATE_EXTENSION
=
"tmpl"
TEMPLATE_EXTENSION
=
"tmpl"
class
<<
self
class
<<
self
def
client_command
@@bin
||=
HG_BIN
end
def
sq_bin
@@sq_bin
||=
shell_quote
(
HG_BIN
)
end
def
client_version
def
client_version
@@client_version
||=
(
hgversion
||
[])
@@client_version
||=
(
hgversion
||
[])
end
end
def
client_available
!
client_version
.
empty?
end
def
hgversion
def
hgversion
# The hg version is expressed either as a
# The hg version is expressed either as a
# release number (eg 0.9.5 or 1.0) or as a revision
# release number (eg 0.9.5 or 1.0) or as a revision
...
@@ -45,7 +57,7 @@ module Redmine
...
@@ -45,7 +57,7 @@ module Redmine
end
end
def
hgversion_from_command_line
def
hgversion_from_command_line
shellout
(
"
#{
HG_BIN
}
--version"
)
{
|
io
|
io
.
read
}.
to_s
shellout
(
"
#{
sq_bin
}
--version"
)
{
|
io
|
io
.
read
}.
to_s
end
end
def
template_path
def
template_path
...
@@ -63,7 +75,7 @@ module Redmine
...
@@ -63,7 +75,7 @@ module Redmine
end
end
def
info
def
info
cmd
=
"
#{
HG_BIN
}
-R
#{
target
(
''
)
}
root"
cmd
=
"
#{
self
.
class
.
sq_bin
}
-R
#{
target
(
''
)
}
root"
root_url
=
nil
root_url
=
nil
shellout
(
cmd
)
do
|
io
|
shellout
(
cmd
)
do
|
io
|
root_url
=
io
.
read
root_url
=
io
.
read
...
@@ -80,7 +92,7 @@ module Redmine
...
@@ -80,7 +92,7 @@ module Redmine
def
entries
(
path
=
nil
,
identifier
=
nil
)
def
entries
(
path
=
nil
,
identifier
=
nil
)
path
||=
''
path
||=
''
entries
=
Entries
.
new
entries
=
Entries
.
new
cmd
=
"
#{
HG_BIN
}
-R
#{
target
(
''
)
}
--cwd
#{
target
(
''
)
}
locate"
cmd
=
"
#{
self
.
class
.
sq_bin
}
-R
#{
target
(
''
)
}
--cwd
#{
target
(
''
)
}
locate"
cmd
<<
" -r
#{
hgrev
(
identifier
)
}
"
cmd
<<
" -r
#{
hgrev
(
identifier
)
}
"
cmd
<<
" "
+
shell_quote
(
"path:
#{
path
}
"
)
unless
path
.
empty?
cmd
<<
" "
+
shell_quote
(
"path:
#{
path
}
"
)
unless
path
.
empty?
shellout
(
cmd
)
do
|
io
|
shellout
(
cmd
)
do
|
io
|
...
@@ -106,7 +118,7 @@ module Redmine
...
@@ -106,7 +118,7 @@ module Redmine
# makes Mercurial produce a xml output.
# makes Mercurial produce a xml output.
def
revisions
(
path
=
nil
,
identifier_from
=
nil
,
identifier_to
=
nil
,
options
=
{})
def
revisions
(
path
=
nil
,
identifier_from
=
nil
,
identifier_to
=
nil
,
options
=
{})
revisions
=
Revisions
.
new
revisions
=
Revisions
.
new
cmd
=
"
#{
HG_BIN
}
--debug --encoding utf8 -R
#{
target
(
''
)
}
log -C --style
#{
shell_quote
self
.
class
.
template_path
}
"
cmd
=
"
#{
self
.
class
.
sq_bin
}
--debug --encoding utf8 -R
#{
target
(
''
)
}
log -C --style
#{
shell_quote
self
.
class
.
template_path
}
"
if
identifier_from
&&
identifier_to
if
identifier_from
&&
identifier_to
cmd
<<
" -r
#{
hgrev
(
identifier_from
)
}
:
#{
hgrev
(
identifier_to
)
}
"
cmd
<<
" -r
#{
hgrev
(
identifier_from
)
}
:
#{
hgrev
(
identifier_to
)
}
"
elsif
identifier_from
elsif
identifier_from
...
@@ -164,7 +176,7 @@ module Redmine
...
@@ -164,7 +176,7 @@ module Redmine
return
[]
return
[]
end
end
end
end
cmd
=
"
#{
HG_BIN
}
-R
#{
target
(
''
)
}
--config diff.git=false diff --nodates
#{
diff_args
}
"
cmd
=
"
#{
self
.
class
.
sq_bin
}
-R
#{
target
(
''
)
}
--config diff.git=false diff --nodates
#{
diff_args
}
"
cmd
<<
" -I
#{
target
(
path
)
}
"
unless
path
.
empty?
cmd
<<
" -I
#{
target
(
path
)
}
"
unless
path
.
empty?
shellout
(
cmd
)
do
|
io
|
shellout
(
cmd
)
do
|
io
|
io
.
each_line
do
|
line
|
io
.
each_line
do
|
line
|
...
@@ -176,7 +188,7 @@ module Redmine
...
@@ -176,7 +188,7 @@ module Redmine
end
end
def
cat
(
path
,
identifier
=
nil
)
def
cat
(
path
,
identifier
=
nil
)
cmd
=
"
#{
HG_BIN
}
-R
#{
target
(
''
)
}
cat"
cmd
=
"
#{
self
.
class
.
sq_bin
}
-R
#{
target
(
''
)
}
cat"
cmd
<<
" -r
#{
hgrev
(
identifier
)
}
"
cmd
<<
" -r
#{
hgrev
(
identifier
)
}
"
cmd
<<
"
#{
target
(
path
)
}
"
cmd
<<
"
#{
target
(
path
)
}
"
cat
=
nil
cat
=
nil
...
@@ -190,7 +202,7 @@ module Redmine
...
@@ -190,7 +202,7 @@ module Redmine
def
annotate
(
path
,
identifier
=
nil
)
def
annotate
(
path
,
identifier
=
nil
)
path
||=
''
path
||=
''
cmd
=
"
#{
HG_BIN
}
-R
#{
target
(
''
)
}
"
cmd
=
"
#{
self
.
class
.
sq_bin
}
-R
#{
target
(
''
)
}
"
cmd
<<
" annotate -ncu"
cmd
<<
" annotate -ncu"
cmd
<<
" -r
#{
hgrev
(
identifier
)
}
"
cmd
<<
" -r
#{
hgrev
(
identifier
)
}
"
cmd
<<
"
#{
target
(
path
)
}
"
cmd
<<
"
#{
target
(
path
)
}
"
...
...
lib/redmine/scm/adapters/subversion_adapter.rb
View file @
86faa88e
...
@@ -27,12 +27,20 @@ module Redmine
...
@@ -27,12 +27,20 @@ module Redmine
SVN_BIN
=
Redmine
::
Configuration
[
'scm_subversion_command'
]
||
"svn"
SVN_BIN
=
Redmine
::
Configuration
[
'scm_subversion_command'
]
||
"svn"
class
<<
self
class
<<
self
def
client_command
@@bin
||=
SVN_BIN
end
def
sq_bin
@@sq_bin
||=
shell_quote
(
SVN_BIN
)
end
def
client_version
def
client_version
@@client_version
||=
(
svn_binary_version
||
[])
@@client_version
||=
(
svn_binary_version
||
[])
end
end
def
svn_binary_version
def
svn_binary_version
cmd
=
"
#{
SVN_BIN
}
--version"
cmd
=
"
#{
sq_bin
}
--version"
version
=
nil
version
=
nil
shellout
(
cmd
)
do
|
io
|
shellout
(
cmd
)
do
|
io
|
# Read svn version in first returned line
# Read svn version in first returned line
...
@@ -47,7 +55,7 @@ module Redmine
...
@@ -47,7 +55,7 @@ module Redmine
# Get info about the svn repository
# Get info about the svn repository
def
info
def
info
cmd
=
"
#{
SVN_BIN
}
info --xml
#{
target
}
"
cmd
=
"
#{
self
.
class
.
sq_bin
}
info --xml
#{
target
}
"
cmd
<<
credentials_string
cmd
<<
credentials_string
info
=
nil
info
=
nil
shellout
(
cmd
)
do
|
io
|
shellout
(
cmd
)
do
|
io
|
...
@@ -77,7 +85,7 @@ module Redmine
...
@@ -77,7 +85,7 @@ module Redmine
path
||=
''
path
||=
''
identifier
=
(
identifier
and
identifier
.
to_i
>
0
)
?
identifier
.
to_i
:
"HEAD"
identifier
=
(
identifier
and
identifier
.
to_i
>
0
)
?
identifier
.
to_i
:
"HEAD"
entries
=
Entries
.
new
entries
=
Entries
.
new
cmd
=
"
#{
SVN_BIN
}
list --xml
#{
target
(
path
)
}
@
#{
identifier
}
"
cmd
=
"
#{
self
.
class
.
sq_bin
}
list --xml
#{
target
(
path
)
}
@
#{
identifier
}
"
cmd
<<
credentials_string
cmd
<<
credentials_string
shellout
(
cmd
)
do
|
io
|
shellout
(
cmd
)
do
|
io
|
output
=
io
.
read
output
=
io
.
read
...
@@ -116,7 +124,7 @@ module Redmine
...
@@ -116,7 +124,7 @@ module Redmine
return
nil
unless
self
.
class
.
client_version_above?
([
1
,
5
,
0
])
return
nil
unless
self
.
class
.
client_version_above?
([
1
,
5
,
0
])
identifier
=
(
identifier
and
identifier
.
to_i
>
0
)
?
identifier
.
to_i
:
"HEAD"
identifier
=
(
identifier
and
identifier
.
to_i
>
0
)
?
identifier
.
to_i
:
"HEAD"
cmd
=
"
#{
SVN_BIN
}
proplist --verbose --xml
#{
target
(
path
)
}
@
#{
identifier
}
"
cmd
=
"
#{
self
.
class
.
sq_bin
}
proplist --verbose --xml
#{
target
(
path
)
}
@
#{
identifier
}
"
cmd
<<
credentials_string
cmd
<<
credentials_string
properties
=
{}
properties
=
{}
shellout
(
cmd
)
do
|
io
|
shellout
(
cmd
)
do
|
io
|
...
@@ -138,7 +146,7 @@ module Redmine
...
@@ -138,7 +146,7 @@ module Redmine
identifier_from
=
(
identifier_from
&&
identifier_from
.
to_i
>
0
)
?
identifier_from
.
to_i
:
"HEAD"
identifier_from
=
(
identifier_from
&&
identifier_from
.
to_i
>
0
)
?
identifier_from
.
to_i
:
"HEAD"
identifier_to
=
(
identifier_to
&&
identifier_to
.
to_i
>
0
)
?
identifier_to
.
to_i
:
1
identifier_to
=
(
identifier_to
&&
identifier_to
.
to_i
>
0
)
?
identifier_to
.
to_i
:
1
revisions
=
Revisions
.
new
revisions
=
Revisions
.
new
cmd
=
"
#{
SVN_BIN
}
log --xml -r
#{
identifier_from
}
:
#{
identifier_to
}
"
cmd
=
"
#{
self
.
class
.
sq_bin
}
log --xml -r
#{
identifier_from
}
:
#{
identifier_to
}
"
cmd
<<
credentials_string
cmd
<<
credentials_string
cmd
<<
" --verbose "
if
options
[
:with_paths
]
cmd
<<
" --verbose "
if
options
[
:with_paths
]
cmd
<<
" --limit
#{
options
[
:limit
].
to_i
}
"
if
options
[
:limit
]
cmd
<<
" --limit
#{
options
[
:limit
].
to_i
}
"
if
options
[
:limit
]
...
@@ -177,7 +185,7 @@ module Redmine
...
@@ -177,7 +185,7 @@ module Redmine
identifier_from
=
(
identifier_from
and
identifier_from
.
to_i
>
0
)
?
identifier_from
.
to_i
:
''
identifier_from
=
(
identifier_from
and
identifier_from
.
to_i
>
0
)
?
identifier_from
.
to_i
:
''
identifier_to
=
(
identifier_to
and
identifier_to
.
to_i
>
0
)
?
identifier_to
.
to_i
:
(
identifier_from
.
to_i
-
1
)
identifier_to
=
(
identifier_to
and
identifier_to
.
to_i
>
0
)
?
identifier_to
.
to_i
:
(
identifier_from
.
to_i
-
1
)
cmd
=
"
#{
SVN_BIN
}
diff -r "
cmd
=
"
#{
self
.
class
.
sq_bin
}
diff -r "
cmd
<<
"
#{
identifier_to
}
:"
cmd
<<
"
#{
identifier_to
}
:"
cmd
<<
"
#{
identifier_from
}
"
cmd
<<
"
#{
identifier_from
}
"
cmd
<<
"
#{
target
(
path
)
}
@
#{
identifier_from
}
"
cmd
<<
"
#{
target
(
path
)
}
@
#{
identifier_from
}
"
...
@@ -194,7 +202,7 @@ module Redmine
...
@@ -194,7 +202,7 @@ module Redmine
def
cat
(
path
,
identifier
=
nil
)
def
cat
(
path
,
identifier
=
nil
)
identifier
=
(
identifier
and
identifier
.
to_i
>
0
)
?
identifier
.
to_i
:
"HEAD"
identifier
=
(
identifier
and
identifier
.
to_i
>
0
)
?
identifier
.
to_i
:
"HEAD"
cmd
=
"
#{
SVN_BIN
}
cat
#{
target
(
path
)
}
@
#{
identifier
}
"
cmd
=
"
#{
self
.
class
.
sq_bin
}
cat
#{
target
(
path
)
}
@
#{
identifier
}
"
cmd
<<
credentials_string
cmd
<<
credentials_string
cat
=
nil
cat
=
nil
shellout
(
cmd
)
do
|
io
|
shellout
(
cmd
)
do
|
io
|
...
@@ -207,7 +215,7 @@ module Redmine
...
@@ -207,7 +215,7 @@ module Redmine
def
annotate
(
path
,
identifier
=
nil
)
def
annotate
(
path
,
identifier
=
nil
)
identifier
=
(
identifier
and
identifier
.
to_i
>
0
)
?
identifier
.
to_i
:
"HEAD"
identifier
=
(
identifier
and
identifier
.
to_i
>
0
)
?
identifier
.
to_i
:
"HEAD"
cmd
=
"
#{
SVN_BIN
}
blame
#{
target
(
path
)
}
@
#{
identifier
}
"
cmd
=
"
#{
self
.
class
.
sq_bin
}
blame
#{
target
(
path
)
}
@
#{
identifier
}
"
cmd
<<
credentials_string
cmd
<<
credentials_string
blame
=
Annotate
.
new
blame
=
Annotate
.
new
shellout
(
cmd
)
do
|
io
|
shellout
(
cmd
)
do
|
io
|
...
...
lib/tasks/testing.rake
View file @
86faa88e
...
@@ -51,7 +51,8 @@ namespace :test do
...
@@ -51,7 +51,8 @@ namespace :test do
(
supported_scms
-
[
:subversion
,
:mercurial
]).
each
do
|
scm
|
(
supported_scms
-
[
:subversion
,
:mercurial
]).
each
do
|
scm
|
desc
"Creates a test
#{
scm
}
repository"
desc
"Creates a test
#{
scm
}
repository"
task
scm
=>
:create_dir
do
task
scm
=>
:create_dir
do
system
"gunzip < test/fixtures/repositories/
#{
scm
}
_repository.tar.gz | tar -xv -C tmp/test"
# system "gunzip < test/fixtures/repositories/#{scm}_repository.tar.gz | tar -xv -C tmp/test"
system
"tar -xvz -C tmp/test -f test/fixtures/repositories/
#{
scm
}
_repository.tar.gz"
end
end
end
end
...
...
test/unit/lib/redmine/scm/adapters/bazaar_adapter_test.rb
0 → 100644
View file @
86faa88e
require
File
.
expand_path
(
'../../../../../../test_helper'
,
__FILE__
)
begin
require
'mocha'
class
BazaarAdapterTest
<
ActiveSupport
::
TestCase
REPOSITORY_PATH
=
RAILS_ROOT
.
gsub
(
%r{config
\/\.\.
}
,
''
)
+
'/tmp/test/bazaar_repository'
if
File
.
directory?
(
REPOSITORY_PATH
)
def
setup
@adapter
=
Redmine
::
Scm
::
Adapters
::
BazaarAdapter
.
new
(
MODULE_NAME
,
REPOSITORY_PATH
)
end
else
puts
"Bazaar test repository NOT FOUND. Skipping unit tests !!!"
def
test_fake
;
assert
true
end
end
end
rescue
LoadError
class
BazaarMochaFake
<
ActiveSupport
::
TestCase
def
test_fake
;
assert
(
false
,
"Requires mocha to run those tests"
)
end
end
end
test/unit/lib/redmine/scm/adapters/cvs_adapter_test.rb
View file @
86faa88e
...
@@ -5,6 +5,7 @@ begin
...
@@ -5,6 +5,7 @@ begin
class
CvsAdapterTest
<
ActiveSupport
::
TestCase
class
CvsAdapterTest
<
ActiveSupport
::
TestCase
REPOSITORY_PATH
=
RAILS_ROOT
.
gsub
(
%r{config
\/\.\.
}
,
''
)
+
'/tmp/test/cvs_repository'
REPOSITORY_PATH
=
RAILS_ROOT
.
gsub
(
%r{config
\/\.\.
}
,
''
)
+
'/tmp/test/cvs_repository'
REPOSITORY_PATH
.
gsub!
(
/\//
,
"
\\
"
)
if
Redmine
::
Platform
.
mswin?
MODULE_NAME
=
'test'
MODULE_NAME
=
'test'
if
File
.
directory?
(
REPOSITORY_PATH
)
if
File
.
directory?
(
REPOSITORY_PATH
)
...
...
test/unit/lib/redmine/scm/adapters/git_adapter_test.rb
View file @
86faa88e
# encoding: utf-8
# encoding: utf-8
# This file includes UTF-8 "Felix Schäfer".
# We need to consider Ruby 1.9 compatibility.
require
File
.
expand_path
(
'../../../../../../test_helper'
,
__FILE__
)
require
File
.
expand_path
(
'../../../../../../test_helper'
,
__FILE__
)
begin
require
'mocha'
class
GitAdapterTest
<
ActiveSupport
::
TestCase
class
GitAdapterTest
<
ActiveSupport
::
TestCase
REPOSITORY_PATH
=
RAILS_ROOT
.
gsub
(
%r{config
\/\.\.
}
,
''
)
+
'/tmp/test/git_repository'
REPOSITORY_PATH
=
RAILS_ROOT
.
gsub
(
%r{config
\/\.\.
}
,
''
)
+
'/tmp/test/git_repository'
if
File
.
directory?
(
REPOSITORY_PATH
)
if
File
.
directory?
(
REPOSITORY_PATH
)
...
@@ -23,15 +28,20 @@ class GitAdapterTest < ActiveSupport::TestCase
...
@@ -23,15 +28,20 @@ class GitAdapterTest < ActiveSupport::TestCase
end
end
def
test_getting_revisions_with_spaces_in_filename
def
test_getting_revisions_with_spaces_in_filename
assert_equal
1
,
@adapter
.
revisions
(
"filemane with spaces.txt"
,
nil
,
nil
,
:all
=>
true
).
length
assert_equal
1
,
@adapter
.
revisions
(
"filemane with spaces.txt"
,
nil
,
nil
,
:all
=>
true
).
length
end
end
def
test_getting_revisions_with_leading_and_trailing_spaces_in_filename
def
test_getting_revisions_with_leading_and_trailing_spaces_in_filename
assert_equal
" filename with a leading space.txt "
,
@adapter
.
revisions
(
" filename with a leading space.txt "
,
nil
,
nil
,
:all
=>
true
)[
0
].
paths
[
0
][
:path
]
assert_equal
" filename with a leading space.txt "
,
@adapter
.
revisions
(
" filename with a leading space.txt "
,
nil
,
nil
,
:all
=>
true
)[
0
].
paths
[
0
][
:path
]
end
end
def
test_getting_entries_with_leading_and_trailing_spaces_in_filename
def
test_getting_entries_with_leading_and_trailing_spaces_in_filename
assert_equal
" filename with a leading space.txt "
,
@adapter
.
entries
(
''
,
'83ca5fd546063a3c7dc2e568ba3355661a9e2b2c'
)[
3
].
name
assert_equal
" filename with a leading space.txt "
,
@adapter
.
entries
(
''
,
'83ca5fd546063a3c7dc2e568ba3355661a9e2b2c'
)[
3
].
name
end
end
def
test_annotate
def
test_annotate
...
@@ -39,7 +49,8 @@ class GitAdapterTest < ActiveSupport::TestCase
...
@@ -39,7 +49,8 @@ class GitAdapterTest < ActiveSupport::TestCase
assert_kind_of
Redmine
::
Scm
::
Adapters
::
Annotate
,
annotate
assert_kind_of
Redmine
::
Scm
::
Adapters
::
Annotate
,
annotate
assert_equal
41
,
annotate
.
lines
.
size
assert_equal
41
,
annotate
.
lines
.
size
assert_equal
"# This program is free software; you can redistribute it and/or"
,
annotate
.
lines
[
4
].
strip
assert_equal
"# This program is free software; you can redistribute it and/or"
,
annotate
.
lines
[
4
].
strip
assert_equal
"7234cb2750b63f47bff735edc50a1c0a433c2518"
,
annotate
.
revisions
[
4
].
identifier
assert_equal
"7234cb2750b63f47bff735edc50a1c0a433c2518"
,
annotate
.
revisions
[
4
].
identifier
assert_equal
"jsmith"
,
annotate
.
revisions
[
4
].
author
assert_equal
"jsmith"
,
annotate
.
revisions
[
4
].
author
end
end
...
@@ -50,7 +61,8 @@ class GitAdapterTest < ActiveSupport::TestCase
...
@@ -50,7 +61,8 @@ class GitAdapterTest < ActiveSupport::TestCase
end
end
def
test_last_rev
def
test_last_rev
last_rev
=
@adapter
.
lastrev
(
"README"
,
"4f26664364207fa8b1af9f8722647ab2d4ac5d43"
)
last_rev
=
@adapter
.
lastrev
(
"README"
,
"4f26664364207fa8b1af9f8722647ab2d4ac5d43"
)
assert_equal
"4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8"
,
last_rev
.
scmid
assert_equal
"4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8"
,
last_rev
.
scmid
assert_equal
"4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8"
,
last_rev
.
identifier
assert_equal
"4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8"
,
last_rev
.
identifier
assert_equal
"Adam Soltys <asoltys@gmail.com>"
,
last_rev
.
author
assert_equal
"Adam Soltys <asoltys@gmail.com>"
,
last_rev
.
author
...
@@ -58,14 +70,23 @@ class GitAdapterTest < ActiveSupport::TestCase
...
@@ -58,14 +70,23 @@ class GitAdapterTest < ActiveSupport::TestCase
end
end
def
test_last_rev_with_spaces_in_filename
def
test_last_rev_with_spaces_in_filename
last_rev
=
@adapter
.
lastrev
(
"filemane with spaces.txt"
,
"ed5bb786bbda2dee66a2d50faf51429dbc043a7b"
)
last_rev
=
@adapter
.
lastrev
(
"filemane with spaces.txt"
,
"ed5bb786bbda2dee66a2d50faf51429dbc043a7b"
)
assert_equal
"ed5bb786bbda2dee66a2d50faf51429dbc043a7b"
,
last_rev
.
scmid
assert_equal
"ed5bb786bbda2dee66a2d50faf51429dbc043a7b"
,
last_rev
.
scmid
assert_equal
"ed5bb786bbda2dee66a2d50faf51429dbc043a7b"
,
last_rev
.
identifier
assert_equal
"ed5bb786bbda2dee66a2d50faf51429dbc043a7b"
,
last_rev
.
identifier
assert_equal
"Felix Schäfer <felix@fachschaften.org>"
,
last_rev
.
author
assert_equal
"Felix Schäfer <felix@fachschaften.org>"
,
last_rev
.
author
assert_equal
"2010-09-18 19:59:46"
.
to_time
,
last_rev
.
time
assert_equal
"2010-09-18 19:59:46"
.
to_time
,
last_rev
.
time
end
end
else
else
puts
"Git test repository NOT FOUND. Skipping unit tests !!!"
puts
"Git test repository NOT FOUND. Skipping unit tests !!!"
def
test_fake
;
assert
true
end
def
test_fake
;
assert
true
end
end
end
end
rescue
LoadError
class
GitMochaFake
<
ActiveSupport
::
TestCase
def
test_fake
;
assert
(
false
,
"Requires mocha to run those tests"
)
end
end
end
end
test/unit/lib/redmine/scm/adapters/subversion_adapter_test.rb
View file @
86faa88e
...
@@ -17,9 +17,15 @@
...
@@ -17,9 +17,15 @@
require
File
.
expand_path
(
'../../../../../../test_helper'
,
__FILE__
)
require
File
.
expand_path
(
'../../../../../../test_helper'
,
__FILE__
)
class
SubversionAdapterTest
<
ActiveSupport
::
TestCase
begin
require
'mocha'
class
SubversionAdapterTest
<
ActiveSupport
::
TestCase
if
repository_configured?
(
'subversion'
)
if
repository_configured?
(
'subversion'
)
def
setup
end
def
test_client_version
def
test_client_version
v
=
Redmine
::
Scm
::
Adapters
::
SubversionAdapter
.
client_version
v
=
Redmine
::
Scm
::
Adapters
::
SubversionAdapter
.
client_version
assert
v
.
is_a?
(
Array
)
assert
v
.
is_a?
(
Array
)
...
@@ -28,4 +34,10 @@ class SubversionAdapterTest < ActiveSupport::TestCase
...
@@ -28,4 +34,10 @@ class SubversionAdapterTest < ActiveSupport::TestCase
puts
"Subversion test repository NOT FOUND. Skipping unit tests !!!"
puts
"Subversion test repository NOT FOUND. Skipping unit tests !!!"
def
test_fake
;
assert
true
end
def
test_fake
;
assert
true
end
end
end
end
rescue
LoadError
class
SubversionMochaFake
<
ActiveSupport
::
TestCase
def
test_fake
;
assert
(
false
,
"Requires mocha to run those tests"
)
end
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment