Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
829f959d
Commit
829f959d
authored
Feb 27, 2014
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6201 from cchurch/devel
Escape subversion parameters for running svn commands
parents
cd7d7eb1
adeea2c3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
12 deletions
+18
-12
library/source_control/subversion
+12
-12
test/integration/roles/test_subversion/tasks/main.yml
+6
-0
No files found.
library/source_control/subversion
View file @
829f959d
...
...
@@ -94,47 +94,46 @@ class Subversion(object):
def
_exec
(
self
,
args
):
bits
=
[
'LANG=C'
,
self
.
svn_path
,
'--non-interactive'
,
'--trust-server-cert'
,
'--no-auth-cache'
,
]
if
self
.
username
:
bits
.
append
(
"--username '
%
s'"
%
self
.
username
)
bits
.
extend
([
"--username"
,
self
.
username
]
)
if
self
.
password
:
bits
.
append
(
"--password '
%
s'"
%
self
.
password
)
bits
.
app
end
(
args
)
rc
,
out
,
err
=
self
.
module
.
run_command
(
' '
.
join
(
bits
)
,
check_rc
=
True
)
bits
.
extend
([
"--password"
,
self
.
password
]
)
bits
.
ext
end
(
args
)
rc
,
out
,
err
=
self
.
module
.
run_command
(
bits
,
check_rc
=
True
)
return
out
.
splitlines
()
def
checkout
(
self
):
'''Creates new svn working directory if it does not already exist.'''
self
.
_exec
(
"checkout -r
%
s '
%
s' '
%
s'"
%
(
self
.
revision
,
self
.
repo
,
self
.
dest
)
)
self
.
_exec
(
[
"checkout"
,
"-r"
,
self
.
revision
,
self
.
repo
,
self
.
dest
]
)
def
switch
(
self
):
'''Change working directory's repo.'''
# switch to ensure we are pointing at correct repo.
self
.
_exec
(
"switch '
%
s' '
%
s'"
%
(
self
.
repo
,
self
.
dest
)
)
self
.
_exec
(
[
"switch"
,
self
.
repo
,
self
.
dest
]
)
def
update
(
self
):
'''Update existing svn working directory.'''
self
.
_exec
(
"update -r
%
s '
%
s'"
%
(
self
.
revision
,
self
.
dest
)
)
self
.
_exec
(
[
"update"
,
"-r"
,
self
.
revision
,
self
.
dest
]
)
def
revert
(
self
):
'''Revert svn working directory.'''
self
.
_exec
(
"revert -R '
%
s'"
%
self
.
dest
)
self
.
_exec
(
[
"revert"
,
"-R"
,
self
.
dest
]
)
def
get_revision
(
self
):
'''Revision and URL of subversion working directory.'''
text
=
'
\n
'
.
join
(
self
.
_exec
(
"info '
%
s'"
%
self
.
dest
))
text
=
'
\n
'
.
join
(
self
.
_exec
(
[
"info"
,
self
.
dest
]
))
rev
=
re
.
search
(
r'^Revision:.*$'
,
text
,
re
.
MULTILINE
)
.
group
(
0
)
url
=
re
.
search
(
r'^URL:.*$'
,
text
,
re
.
MULTILINE
)
.
group
(
0
)
return
rev
,
url
def
has_local_mods
(
self
):
'''True if revisioned files have been added or modified. Unrevisioned files are ignored.'''
lines
=
self
.
_exec
(
"status '
%
s'"
%
self
.
dest
)
lines
=
self
.
_exec
(
[
"status"
,
self
.
dest
]
)
# Match only revisioned files, i.e. ignore status '?'.
regex
=
re
.
compile
(
r'^[^?]'
)
# Has local mods if more than 0 modifed revisioned files.
...
...
@@ -142,7 +141,7 @@ class Subversion(object):
def
needs_update
(
self
):
curr
,
url
=
self
.
get_revision
()
out2
=
'
\n
'
.
join
(
self
.
_exec
(
"info -r HEAD '
%
s'"
%
self
.
dest
))
out2
=
'
\n
'
.
join
(
self
.
_exec
(
[
"info"
,
"-r"
,
"HEAD"
,
self
.
dest
]
))
head
=
re
.
search
(
r'^Revision:.*$'
,
out2
,
re
.
MULTILINE
)
.
group
(
0
)
rev1
=
int
(
curr
.
split
(
':'
)[
1
]
.
strip
())
rev2
=
int
(
head
.
split
(
':'
)[
1
]
.
strip
())
...
...
@@ -176,6 +175,7 @@ def main():
password
=
module
.
params
[
'password'
]
svn_path
=
module
.
params
[
'executable'
]
or
module
.
get_bin_path
(
'svn'
,
True
)
os
.
environ
[
'LANG'
]
=
'C'
svn
=
Subversion
(
module
,
dest
,
repo
,
revision
,
username
,
password
,
svn_path
)
if
not
os
.
path
.
exists
(
dest
):
...
...
test/integration/roles/test_subversion/tasks/main.yml
View file @
829f959d
...
...
@@ -84,6 +84,12 @@
-
"
trunk.stat.isdir"
-
"
branches.stat.isdir"
-
name
:
checkout with quotes in username
subversion
:
repo={{ repo }} dest={{ checkout_dir }} username="quoteme'''"
register
:
subverted3
-
debug
:
var=subverted3
# FIXME: this needs to be fixed in the code see GitHub 6079
#- name: verify on a reclone things are marked unchanged
...
...
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