Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.recipe.build.saved
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jérome Perrin
slapos.recipe.build.saved
Commits
9fff941c
Commit
9fff941c
authored
Sep 01, 2014
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gitclone: refuse deleting a working copy with local commits or changes
parent
83632948
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
3 deletions
+42
-3
CHANGES.txt
CHANGES.txt
+2
-0
setup.py
setup.py
+5
-1
slapos/recipe/gitclone.py
slapos/recipe/gitclone.py
+35
-2
No files found.
CHANGES.txt
View file @
9fff941c
Changes
=======
* gitclone: do not delete the working copy if develop is set
0.12 (2013-09-05)
-----------------
...
...
setup.py
View file @
9fff941c
...
...
@@ -40,5 +40,9 @@ setup(name=name,
'download-unpacked = slapos.recipe.downloadunpacked:Recipe'
,
'gitclone = slapos.recipe.gitclone:Recipe'
,
'npm = slapos.recipe.npm:Npm'
,
]},
],
'zc.buildout.uninstall'
:
[
'gitclone = slapos.recipe.gitclone:uninstall'
,
],
},
)
slapos/recipe/gitclone.py
View file @
9fff941c
...
...
@@ -33,6 +33,7 @@ import traceback
from
zc.buildout
import
UserError
from
subprocess
import
check_call
,
CalledProcessError
import
subprocess
try
:
try
:
...
...
@@ -167,8 +168,13 @@ class Recipe(object):
"""
# If directory already exist: delete it.
if
os
.
path
.
exists
(
self
.
location
):
print
'destination directory already exists. Deleting it.'
print
'destination directory already exists.'
if
not
self
.
develop
:
print
'Deleting it.'
shutil
.
rmtree
(
self
.
location
)
else
:
# If develop is set, assume that this is a valid working copy
return
[
self
.
location
]
git_clone_command
=
[
self
.
git_command
,
'clone'
,
self
.
repository
,
...
...
@@ -234,3 +240,30 @@ class Recipe(object):
self
.
gitReset
(
self
.
revision
)
else
:
self
.
gitReset
(
'@{upstream}'
)
def
uninstall
(
name
,
options
):
"""Keep the working copy if develop is set to true.
"""
force_keep
=
False
if
options
.
get
(
'develop'
,
'no'
).
lower
()
in
(
'1'
,
'yes'
,
'true'
):
p
=
subprocess
.
Popen
([
options
.
get
(
'git_command'
,
'git'
),
'status'
,
'--short'
],
cwd
=
options
[
'location'
],
stdout
=
subprocess
.
PIPE
)
if
p
.
communicate
()[
0
].
strip
():
print
"You have uncommited changes in %s. "
\
"This folder will be left as is."
%
options
[
'location'
]
force_keep
=
True
p
=
subprocess
.
Popen
([
options
.
get
(
'git_command'
,
'git'
),
'log'
,
'--branches'
,
'--not'
,
'--remotes'
],
cwd
=
options
[
'location'
],
stdout
=
subprocess
.
PIPE
)
if
p
.
communicate
()[
0
].
strip
():
print
"You have commits not pushed upstream in %s. "
\
"This folder will be left as is."
%
options
[
'location'
]
force_keep
=
True
if
force_keep
:
# Eventhough this behaviour is not documented, buildout won't uninstall
# anything if we unset __buildout_installed__
options
[
'__buildout_installed__'
]
=
''
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