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
9bd1e7e7
Commit
9bd1e7e7
authored
Feb 05, 2015
by
Cédric de Saint Martin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gitclone: when update(), if repository has local changes, don't do anything but warn user.
commited-but-not-pushed changes will be lost.
parent
efe121bd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
6 deletions
+30
-6
README.rst
README.rst
+14
-0
slapos/recipe/gitclone.py
slapos/recipe/gitclone.py
+16
-6
No files found.
README.rst
View file @
9bd1e7e7
...
...
@@ -167,6 +167,20 @@ When updating, it will do a "git fetch; git reset @{upstream}"::
Fetching origin
HEAD is now at ...
Note: if, during update, the recipe detects that local changes have been made
the recipe will warn the user, won't change content of the repository and
will succeed::
>>> print system('echo kept > parts/git-clone/local_change')
...
>>> print system(buildout)
Updating git-clone.
Warning: since you have local changes in this repository it is left untouched.
>>> print system('cat parts/git-clone/local_change')
kept
>>> print system('rm parts/git-clone/local_change')
Specific branch
~~~~~~~~~~~~~~~
...
...
slapos/recipe/gitclone.py
View file @
9bd1e7e7
...
...
@@ -122,6 +122,15 @@ def download_network_cached(path, name, revision, networkcache_options):
networkcache_options
.
get
(
'signature-certificate-list'
),
)
def
hasLocalChanges
(
location
,
git_command
=
'git'
):
"""Check if repository has local changes."""
p
=
subprocess
.
Popen
([
git_command
,
'status'
,
'--short'
],
cwd
=
location
,
stdout
=
subprocess
.
PIPE
)
if
p
.
communicate
()[
0
].
strip
():
return
True
return
False
class
Recipe
(
object
):
"""Clone a git repository."""
...
...
@@ -242,6 +251,9 @@ class Recipe(object):
"""
if
self
.
develop
:
return
if
hasLocalChanges
(
self
.
location
,
self
.
git_command
):
print
"Warning: since you have local changes in this repository it is left untouched."
return
# first cleanup pyc files
self
.
deletePycFiles
(
self
.
location
)
...
...
@@ -262,17 +274,15 @@ def uninstall(name, options):
if
not
os
.
path
.
exists
(
options
[
'location'
]):
return
force_keep
=
False
git_command
=
options
.
get
(
'git-executable'
,
'git'
)
if
options
.
get
(
'develop'
,
'yes'
).
lower
()
in
TRUE_VALUES
:
p
=
subprocess
.
Popen
([
options
.
get
(
'git-executable'
,
'git'
),
'status'
,
'--short'
],
cwd
=
options
[
'location'
],
stdout
=
subprocess
.
PIPE
)
if
p
.
communicate
()[
0
].
strip
():
if
hasLocalChanges
(
options
[
'location'
],
git_command
):
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-executable'
,
'git'
)
,
'log'
,
'--branches'
,
'--not'
,
'--remotes'
],
p
=
subprocess
.
Popen
([
git_command
,
'log'
,
'--branches'
,
'--not'
,
'--remotes'
],
cwd
=
options
[
'location'
],
stdout
=
subprocess
.
PIPE
)
if
p
.
communicate
()[
0
].
strip
():
...
...
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